-
Format of an assembly instruction:
-
LABEL:
-
Stores a symbolic name for the memory location that it represents.
-
OPERANDS:
-
A register, an immediate or a memory address holding the values on which the operation is performed.
-
There can be from 0 to 3 operands.
-
Data movement instructions move data (bytes, words and doublewords) between registers and between registers and memory.
-
Only the
movs
instruction can have both operands in memory.
-
Most data transfer instructions do not change the
EFLAGS
register.
-
Format:
-
opcode
destination
,
source
-
Direct (eax), Displacement (other regs)
-
Any of
eax
,
ebx
,
ecx
,
edx
,
ebp
,
edi
or
esi
may be used.
-
Any combination of
eax
,
ebx
,
ecx
,
edx
,
ebp
,
edi
or
esi
.
-
A second variation includes:
mov
eax
,
[
ARR+
ebx
]
-
A second variation includes:
mov
eax
,
[
ebx
+
edi
+4]
-
A second variation includes:
mov
eax
,
ebx
*2+
ecx
+offset
-
Scaling factors can be 2X, 4X or 8X.
-
Note:
mov
really COPIES data from the source to destination register.
-
Never mix an 16-bit register with a 32-bit, etc.
-
None of the
mov
instruction effect the EFLAGS register.
-
Immediate addressing:
-
The value of the operand is given as a constant in the instruction stream.
-
Use
b
for binary,
q
for octal and nothing for decimal.
-
ASCII data requires a set of apostrophes:
-
Register and immediate addressing example:
-
Direct addressing:
-
Transfers between memory and
al
,
ax
and
eax
.
-
Usually encoded in 3 bytes, sometime 4:
-
Displacement instructions are encoded with up to 7 bytes (32 bit register and a 32 bit displacement).
-
Direct and displacement addressing example:
-
Note: Direct addressing (using al) requires 3 bytes to encode while Displacement (using bx) requires 4.
-
Register Indirect addressing:
-
Offset stored in a register is added to the segment register.
-
The memory to memory
mov
is allowed with string instructions.
-
Register Indirect addressing (cont)
-
Any register EXCEPT
esp
for the 80386 and up.
-
For
eax
,
ebx
,
ecx
,
edx
,
edi
and
esi
: The data segment is the default.
-
For
ebp
: The stack segment is the default.
-
Some versions of register indirect require special assembler directives
byte, word
, or
dword
-
Does [
edi
] address a byte, a word or a double-word?
-
The assembler can't determine the size of 0x10 !