reverse -> variables, instructions, ...


I - Variables initialisées


[nom_variable] taille valeur

taille définition nombre d’octets aloués
DB Define Byte 1
DW Define Word 2
DL Define Doubleword 4
DQ Define Quadword 8
# exemple de définition de variables
ma_lettre DB 'm'
mon_age	DW 12345
mon_negatif DW -12345
grand_nombre DQ	123456789
reel DD	1.234

II - Variables non initialisées


taille définition nombre d’octets reservé
RESB Reserve Byte 1
RESW Reserve Word 2
RESD Reserve Doubleword 4
RESQ Reserve Quadword 8
REST Reserve Ten Bytes 10

III - Constantes


CONSTANT_NAME EQU expression

TOTAL_STUDENTS equ 50
# numeric constant
%assign TOTAL 10
# both numeric and string constants
%define PTR [EBP+4]

Unary operations

  • DIV divisor ; unsigned data
  • IDIV divisor ; signed data
    • 16-bit: (AX) / 8-bit divisor = AL(quotient) and AH(remainder)
    • 32-bit: (DX AX) / 16-bit divisor = AX(quotient) and DX(remainder)
    • 64-bit: (EDX EAX) / 32-bit divisor = EAX(quotient) and EDX(remainder)
  • idivq S -> RDX:RAX / S = RAX(quotient) and RDX(remainder)
  • divq S -> RDX:RAX / S = RAX(quotient) and RDX(remainder)
instruction description
inc D D = D + 1
dec D D = D - 1
neg D D = -D
not D D = non D

Binary operations

instruction description
leaq S, D D = S
add S, D D = D + S
sub S, D D = D - S
imul S, D D = D - S
xor S, D OU exclusif
or S, D OU logique
and S, D ET logique
instruction définition
MUL multiplier D = D + 1
IMUL multiplier D = D + 1

MUL multiply unsigned data
IMUL integer mutltiply signed data

  • AL * multiplier(of 8-bit) = AH AL = AX
  • AX * multiplier(of 16-bit) = DX AX
  • EAX * multiplier(of 32-bit) = EDX EAX
  • imulq S -> RAX * S(of 32-bit) = RDX:RAX
  • mulq S -> RAX * S(of 32-bit) = RDX:RAX

V - Instructions logiques



VI - Conditions


# compare desti à src avec soustraction
CMP desti, src

CMP DX,	00
JE  L7
...
L7: ... 
INC	EDX
CMP	EDX, 10	; Compares whether the counter has reached 10
JLE	LP1     ; If it is less than or equal to 10, then jump to LP1
# faire un saut sur un label
JMP	label
instruction description
cmp S2, S1 set condition codes to S1-S2
test S2, S1 set condition codes to S1 & S2
jump définition flags touchés
jump Label jump to label  
jump Addr jump to address  
je/jz Label jump equal/zero ZF
jne/jnz Label jump not equal/nonzero ZF
js Label jump if negative SF
jns Label jump if nonnegative SF
jg/jnle Label jump if greater OF, SF, ZF
jge/jnl Label jump if greater or Equal OF, SF
jl/jnge Label jump if less OF, SF
jle/jng Label jump if less or equal OF, SF, ZF

VII - Data movement


Instruction with one suffix

instruction description
mov S, D move source to destination
push S push source onto stack
pop D pop to of stack into destination

Instruction wih two suffix

instruction description
mov S, D move source to destination
push S push source onto stack

Instructions with no suffixes

instruction description
cwtl convert word in %ax to doubleword in %aex
cttq convert doubleword in %eax to quadword in %rax
cqto convert quadword in %rax to octoword in %rdx:%rax