Set 2
Set 2
Set 2
MOV destination,source
MOV AX,BX
MOV SUM,EAX
MOV EDX,ARRAY[EBX][ESI]
MOV CL,5
MOV DL,[BX]
Addressing Modes
These are the different ways in which data
may be accessed by the microprocessor.
Immediate.
Register.
Memory.
Direct.
Register indirect.
Base plus index.
Register relative.
Base relative plus index.
Scaled indexed.
Immediate
Directly accessible to the EU.
The address is part of the instruction.
Useful in initializations.
MOV EAX,1111000B
MOV CL, 0F1H
Register
Directly accessible to the EU.
Most compact and fastest executing
instructions.
Operands are encoded in the instruction.
MOV EBX,EDX
MOV AL,CL
Memory
When reading or writing to memory the
execution unit passes an offset value, the
effective address, to the bus interface unit
which then computes the physical
address.
Direct
EA = { [operand] }
PA = {DS}× 16 + { [operand] }
INC BX
INC COUNT
INC DWORD PTR [EBX]
JMP Instruction
JMP label
EIP = label
JMP AGAIN
Accessing Arrays
Assume the following array definition:
Begin:
LEA EBX,DS:ARRAY
L1:
MOV EAX,DS:[EBX]
INC EBX
JMP L1
Begin:
MOV ESI,O
L1:
MOV EAX,DS:ARRAY[ESI]
INC ESI
JMP L1
Begin:
MOV ESI,O
L1:
MOV EAX,DS:ARRAY[ESI*4]
INC ESI
JMP L1
Machine Language
Native binary code that the microprocessor
understand and uses as its instructions to
control its operation.
Their length vary from 1 to 13 bytes.
The instructions for the 8086 through the
80286 have the format shown below.
Address size Operand size Opcode MOD-REG-R/M Scaled index Displacement Immediate
0 to 1 bytes 0 to 1 bytes 1 to 2 bytes 0 to 1 byte 0 to 1 byte 0 to 4 bytes 0 to 4 bytes
Machine Language
The Opcode selects the operation to be
performed by the microprocessor.
The remaining two bits indicate:
D – direction of flow of information:
D=0: R/M←REG;
D=1: REG←R/M.
W – Size of data:
W=0: Byte;
W=1: Word, Doubleword.
Opcode D W
Machine Language
MOD field specifies the addressing mode for the
selected instruction.
REG field indicates a register.
R/M field indicates either a register MOD=11, or a
memory addressing mode.
Word ptr.
Dword ptr.