ECE391: Computer Systems Engineering Fall 2008 Reference: x86 Assembly x86 Assembly Reference Sheet
ECE391: Computer Systems Engineering Fall 2008 Reference: x86 Assembly x86 Assembly Reference Sheet
Fall 2008
32bit 16bit
AX
EAX
BX
EBX
CX
ECX
DX
EDX
SI
ESI
DI
EDI
BP
EBP
SP
ESP
8bit
high low
AH AL
BH BL
CH CL
DH DL
AX
31
16 15
8 7
AH
AL
EAX
jo
jp
below
below or
equal
equal
less
less or
equal
overflow
parity
js
sign
jb
jbe
je
jl
jle
CF is set
CF or ZF
is set
ZF is set
SF 6= OF
(SF 6= OF) or
ZF is set
OF is set
PF is set
(even parity)
SF is set
(negative)
movb
movb
movb
movb
movb
movb
movb
movb
movb
movb
movb
movb
(%ebp),%al
-4(%esp),%al
(%ebx,%edx),%al
13(%ecx,%ebp),%al
(,%ecx,4),%al
-6(,%edx,2),%al
(%esi,%eax,2),%al
24(%eax,%esi,8),%al
100,%al
label,%al
label+10,%al
10(label),%al
#
#
#
#
#
#
#
#
#
#
#
#
AL M[EBP]
AL M[ESP - 4]
AL M[EBX + EDX]
AL M[ECX + EBP + 13]
AL M[ECX * 4]
AL M[EDX * 2 - 6]
AL M[ESI + EAX * 2]
AL M[EAX + ESI * 8 + 24]
AL M[100]
AL M[label]
AL M[label+10]
NOT LEGAL!
movb
movb
label(%eax),%al
7*6+label(%edx),%al
# AL M[EAX + label]
# AL M[EDX + label + 42]
movw
movw
movw
$label,%eax
$label+10,%eax
$label(%eax),%eax
# EAX label
# EAX label+10
# NOT LEGAL!
call
call
call
call
call
printf
*%eax
*(%eax)
*fptr
*10(%eax,%edx,2)
#
#
#
#
#
#
(push
(push
(push
(push
(push
EIP), EIP
EIP), EIP
EIP), EIP
EIP), EIP
EIP), EIP
M[EAX +
printf
EAX
M[EAX]
M[fptr]
EDX*2 + 10]
Conditional branch sense is inverted by inserting an N after initial J, e.g., JNB. Preferred forms in
table below are those used by debugger in disassembly. Table use: after a comparison such as
cmp %ebx,%esi
choose the operator to place between ESI and EBX, based on the data type. For example, if ESI and EBX
hold unsigned values, and the branch should be taken if ESI EBX, use either JBE or JNA. For branches
other than JE/JNE based on instructions other than CMP, check the branch conditions above instead.
return address
a = 10
EBP
...
b = 20
jnae
jb
jna
jbe
jz
je
jnb
jae
jnbe
ja
6=
<
>
jne
jnz
jl
jnge
jle
jng
je
jz
jge
jnl
jg
jnle
/* the function */
/* (returns int in EAX) */
int a func (int a, int b);
unsigned comparisons
signed comparisons
ESP
result
EBP
old EBP
return address
a = 10
/* local variable */
int result;
/* the call */
a func (10, 20);
b = 20
stack growth
ESP
stack growth
preferred form
jnz
jne
...
preferred form