flat assembler
Message board for the users of flat assembler.

Index > Heap > What assembler syntax is this?

Author
Thread Post new topic Reply to topic
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
Just wondering what assembler syntax is the Intel guy using in this document.
Code:
;#========================== ;# ;# Data Space Initialization ;#
;#==========================
$data->data(<<'DATA'); datablock ; This is data to be encrypted
do 0340737e0a29831318d305a88a8f64331h ;
do 0340737e0a29831318d305a88a8f64332h ;
do 0340737e0a29831318d305a88a8f64333h ;
do 0340737e0a29831318d305a88a8f64334h ;
do 0340737e0a29831318d305a88a8f64335h ;
do 0340737e0a29831318d305a88a8f64336h ;
do 0340737e0a29831318d305a88a8f64337h ;
do 0340737e0a29831318d305a88a8f64338h ;
key do 03c4fcf098815f7aba6d2ae2816157e2bh ; 128 bit key
retdata do 000000000000000000000000000000000h ; where to store encrypted data
keyex_addr: keyex do 000000000000000000000000000000000h ;
DATA
;#========================== ;# ;# Main Code Segment ;#
;#==========================
$code->code(<<'CODE');
;; Enable use of MMX2 from software.
mov rax, CR4 ; Set bit 9 (OSFXSR) and NOT bit 10
or rax, 0200h ; (OSMMEXCPT).
mov CR4, rax
mov eax, 01h ; Verify support in CPU
cpuid
mov eax, 02000000h ; Check if bit #25 is set
and eax, ecx
; jz FAIL
;; GENERATING KEY SCHEDULE
movdqu xmm1, OWORD PTR key ; loading the key
movdqu OWORD PTR keyex, xmm1 ; Store key in memory where all round keys are
stored
mov rcx, OFFSET keyex_addr+16 ; setting store address for key expansion
aeskeygen xmm2, xmm1, 0x1 ; Generating round key 1
call key_expansion_128
aeskeygen xmm2, xmm1, 0x2 ; Generating round key 2
call key_expansion_128
aeskeygen xmm2, xmm1, 0x4 ; Generating round key 3
call key_expansion_128
aeskeygen xmm2, xmm1, 0x8 ; Generating round key 4
call key_expansion_128
aeskeygen xmm2, xmm1, 0x10 ; Generating round key 5
call key_expansion_128
aeskeygen xmm2, xmm1, 0x20 ; Generating round key 6
call key_expansion_128
aeskeygen xmm2, xmm1, 0x40 ; Generating round key 7
call key_expansion_128
White Paper Advanced Encryption Standard (AES) Instructions Set
33
aeskeygen xmm2, xmm1, 0x80 ; Generating round key 8
call key_expansion_128
aeskeygen xmm2, xmm1, 0x1b ; Generating round key 9
call key_expansion_128
aeskeygen xmm2, xmm1, 0x36 ; Generating round key 10
call key_expansion_128
;;
;; PERFORMING ENCRYPTION
mov rdx, OFFSET keyex_addr
movdqu xmm1, OWORD PTR [rdx] ; loading the key for the encryption
movdqu xmm2, OWORD PTR [datablock] ; loading entire data block
movdqu xmm3, OWORD PTR [datablock+0x10] ;
movdqu xmm4, OWORD PTR [datablock+0x20] ;
movdqu xmm5, OWORD PTR [datablock+0x30] ;
movdqu xmm6, OWORD PTR [datablock+0x40] ;
movdqu xmm7, OWORD PTR [datablock+0x50] ;
movdqu xmm8, OWORD PTR [datablock+0x60] ;
movdqu xmm9, OWORD PTR [datablock+0x70] ;
pxor xmm2, xmm1 ; XORing
pxor xmm3, xmm1 ; XORing
pxor xmm4, xmm1 ; XORing
pxor xmm5, xmm1 ; XORing
pxor xmm6, xmm1 ; XORing
pxor xmm7, xmm1 ; XORing
pxor xmm8, xmm1 ; XORing
pxor xmm9, xmm1 ; XORing
mov ecx, 9
main_loop:
add rdx, 0x10
movdqu xmm1, OWORD PTR [rdx] ; loading the key for the encryption
aesenc xmm2, xmm1 ; Encrypting
aesenc xmm3, xmm1 ;
aesenc xmm4, xmm1 ;
aesenc xmm5, xmm1 ;
aesenc xmm6, xmm1 ;
aesenc xmm7, xmm1 ;
aesenc xmm8, xmm1 ;
aesenc xmm9, xmm1 ;
loop main_loop
add rdx, 0x10
movdqu xmm1, OWORD PTR [rdx] ; loading the key for the encryption
aesenclast xmm2, xmm1 ; Last round
aesenclast xmm3, xmm1 ;
aesenclast xmm4, xmm1 ;
aesenclast xmm5, xmm1 ;
aesenclast xmm6, xmm1 ;
aesenclast xmm7, xmm1 ;
aesenclast xmm8, xmm1 ;
aesenclast xmm9, xmm1 ;
movdqu OWORD PTR [datablock], xmm2 ; storing the encrypted block
movdqu OWORD PTR [datablock+0x10], xmm3 ;
movdqu OWORD PTR [datablock+0x20], xmm4 ;
movdqu OWORD PTR [datablock+0x30], xmm5 ;
movdqu OWORD PTR [datablock+0x40], xmm6 ;
movdqu OWORD PTR [datablock+0x50], xmm7 ;
movdqu OWORD PTR [datablock+0x60], xmm8 ;
movdqu OWORD PTR [datablock+0x70], xmm9 ;
mov ebx, 0acedh
hlt;
key_expansion_128:
mov rdx, rcx
pshufd xmm2, xmm2, 0b11111111
pxor xmm2, xmm1
movd eax, xmm2
mov DWORD PTR [rcx], eax
add rcx, 4
pshufd xmm1, xmm1, 011100101b
movd ebx, xmm1
xor eax, ebx
mov DWORD PTR [rcx], eax
add rcx, 4
pshufd xmm1, xmm1, 011100110b
movd ebx, xmm1
xor eax, ebx
mov DWORD PTR [rcx], eax
add rcx, 4
pshufd xmm1, xmm1, 011100111b
movd ebx, xmm1
xor eax, ebx
mov DWORD PTR [rcx], eax
add rcx, 4
movdqu xmm1, OWORD PTR [rdx]
ret
FAIL:
mov ebx, 0deadh
hlt
CODE    


Last edited by MazeGen on 10 Apr 2009, 08:49; edited 1 time in total
Post 09 Apr 2009, 15:27
View user's profile Send private message Visit poster's website Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
x86 with AVX extension Wink

_________________
Nil Volentibus Arduum Razz
Post 09 Apr 2009, 15:44
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
This code doesn't need comments, with that alignment it only makes it worse!
Post 09 Apr 2009, 17:31
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
Well, if it is not clear, I ask what assembler is supposed to compile this code Smile
Post 10 Apr 2009, 08:52
View user's profile Send private message Visit poster's website Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Way back in the dark ages, i.e. late 70's, Intel had their own assembler. Perhaps it has been resurrected, updated, i.e. maintained, though not in the public domain?
Question
Post 10 Apr 2009, 09:09
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Usually Intel use MASM assembler syntax, maybe this is
a pseudo assemby code , it's only an example.

_________________
Nil Volentibus Arduum Razz
Post 10 Apr 2009, 15:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17275
Location: In your JS exploiting you and your system
revolution
I like the exit codes.

For success:
Code:
mov ebx, 0acedh    


For failure:
Code:
mov ebx, 0deadh    
Post 10 Apr 2009, 16:00
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
DJ Mauretto wrote:
Usually Intel use MASM assembler syntax, maybe this is
a pseudo assemby code , it's only an example.


Pseudocode wouldn't use such a weird directives like
Code:
$data->data(<<'DATA')    

Code:
$code->code(<<'CODE')    
Post 10 Apr 2009, 16:47
View user's profile Send private message Visit poster's website Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
ok
Ask at the guy that wrote this paper Wink this is the e-mail
shay.gueron@intel.com

_________________
Nil Volentibus Arduum Razz
Post 10 Apr 2009, 17:24
View user's profile Send private message Reply with quote
HyperVista



Joined: 18 Apr 2005
Posts: 691
Location: Virginia, USA
HyperVista
Is it, by any chance, assembly for PowerPC?
Post 10 Apr 2009, 20:45
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
PowerPC has eax and stuff?
Post 11 Apr 2009, 00:50
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Ctrl+F doesn't reveal any strings with 'asm' or 'assembler' inside Smile
Btw, I think that there's still room for 'do' in FASM Smile Of course some might argue that 'ddq' is much more logical, but its a whole char longer.

What would 256-bit locations have as their name or should someone finally say: "ah, F* it!" Razz and write 'em as bits Smile
Post 11 Apr 2009, 09:27
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17275
Location: In your JS exploiting you and your system
revolution
Madis731 wrote:
What would 256-bit locations have as their name or should someone finally say: "ah, F* it!" Razz and write 'em as bits Smile
Simple, follow the pattern, only the last one is problematic.
  • dw word
  • dd d(ouble)word
  • dq q(uadruple)word
  • do o(ctuple)word
  • ds s(exdecuple)word
  • dd d(uotrigenuple)word Embarassed
Post 11 Apr 2009, 10:18
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
So with AES we are saved, but 64 bytes is long enough to hold it in a separate include file Smile Who would write for example:
Code:
dduotrigenuple 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF    
?
Smile I hope I calculated the length correctly
Post 11 Apr 2009, 10:32
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17275
Location: In your JS exploiting you and your system
revolution
No, silly, we write:
Code:
ds 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF    
Post 11 Apr 2009, 10:41
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.