Please enable JavaScript.
Coggle requires JavaScript to display documents.
ASSEMBLY (CHAPTER 3 || Addressing Modes (:check: Data - Addressing Modes, …
ASSEMBLY
CHAPTER 3 || Addressing Modes
:check: MOV dest , src
:check: Each statement : LABEL / OPCODE / OPERAND / COMMENT
OPCODE
: holds inst. or opcode
OPERAND
: info used by the opcode
LABEL
: begins with a letter / or one of @ , $, -, or ? / length is from 1 to 35 char
COMMENT
: comments about inst. / always begins with ;
:check: Data - Addressing Modes
Register indirect
MOV [BX] , CL
:explode: Offset add. is held in :
BP
/
BX
/
DI
/
SI
or any Extended REG except
ESP
(
DS
) is used by default with
BX
/
DI
/
SI
(
SS
) is used by default with
BP
:explode:
in REAL mode :
if REG is 32- bit
contents must NEVER exceed 0000 FFFF H
:explode: in
PROTECTED
mode : if REG is 32- bit
any value can be used (but not outside seg)
:explode: sometimes requires specefying the SIZE of DATA by
special assembler directive
: BYTE PTR / WORD PTR / DWORD PTR / QWORD PTR
Base-plus-index
MOV [BX+SI] , BP
BASE REG
holds
beginning location
of a memory array :
BX
/ E
BX
/
BP
/ E
BP
INDEX REG
holds
relative position
of an element in the array :
SI
/
DI
/ E
SI
/ E
DI
/ ECX
both SS and BP generate eff. add.
Direct
MOV [1234H], AX
:arrow_forward: B or W between MEM & REG
:arrow_forward: 2 basics Forms :
DIRECT
: MOV between MEM & (AL or AX or EAX)
3 bytes
DISPLACEMENT
: almost any inst. with ANY REG
4 bytes
:arrow_forward: Address = DS x 10H + Disp
Register relative
MOV CL , [BX + 4]
adds displacement to the contents of REG
Immediate
MOV CH , 3AH
:warning: HEXADEIMAL
H
MOV AX , 44H
:warning: DECIMAL
as it is
MOV BL , 44
:warning: CHAR
‘
MOV AL , ‘A‘
:warning: BINARY
B
MOV EAX , 100B
:warning: LETTER
0
MOV AL , 0AH
Base relative-plus-index
MOV ARRAY[BX + SI] , DX
adds displacement to the contents of REG / uses a BASE REG and an INDEX REG
Register
MOV AX , BX
:red_cross: Segment TO Segment
MOV ES , DS
:red_cross: CS cannot be Dest.
MOV CS , AX
:red_cross: Mixed sizes
MOV BL , DX
Scaled index
MOV [EBX+2 x ESI] , AX
uses 2 32-bit REG (base reg + index reg)
index reg : multiplied by scaling factor , 1x , 2x , 4x , 8x
:check: Stack Memory - Addressing Modes
STACK memory
return addresses used by proc
Stack memory is
LIFO
(last-in, first-out)
PUSH
: data are placed on stack
high-order 8 bits are placed at location addressed by SP - 1
low-order 8 bits are placed at location addressed by SP - 2
WORDS (or dword) of data , never BYTES
from any 16-bit (32 also) REG or Segment REG
PUSHA : all REG except Segment REG on the stack
POP
: data are removed from stack
WORDS (or dword) of data , never BYTES
from any REG or Segment REG
excpet
CS
POPA : all REG except Segment REG on the stack
maintained by 2 REG :
SP
(or ESP) +
SS
in
PROTECTED
mode , SS holds a SELECTOR that accesses a DESCRIPTOR for the base add. of
SS
holds data temporarily