stack memory 00000 h 00001 h fffff h ffffe h ss 0105 sp 0008 tos bos bos = 01050+ffff = 1104f h...
TRANSCRIPT
Stack Memory
00000H
00001H
FFFFFH
FFFFEH
SS0105
SP0008
TOS
BOS
BOS = 01050+FFFF
= 1104FH
01058H
1104FH
PUSH AX
TOS
1234HAX
1058H
XXH
XXH
XXH
XXH
XXH
XXH
XXH
1057H
1056H
1055H
Before execution
1058H
XXH
XXH
XXH
34H
12H
XXH
XXH
1057H
1056H
1055H
TOS
After execution
POP BX
1234HBX
Before execution
1058H
XXH
XXH
XXH
34H
12H
XXH
XXH
1057H
1056H
1055H
TOS
After execution
1058H
XXH
XXH
XXH
34H
12H
XXH
XXH
1057H
1056H
1055H
XXXXHBX
TOS
I/O address space
open
open
reserved00F8H
00FFH
0000H
FFFFH
A separate 64 Kbyte address space is provided where I/O interfaces are implemented.
Certain I/O instructions can only perform operations to I/O devices located in this I/O address space.
Addressing modes of the 8086 / 8088 μP
Register addressing modeMOV AX, BX
MOV destination operand, source operand
XXXXHAX
1234HBX
Before the execution
1234HAX
1234HBX
After the execution
Coding in machine language
opcode D W
Operation code
D= 1 direction is to the register specified in byte 2
D=0 direction is from the register specified in byte 2
Byte 1 Byte 2
mod reg R/M
W=0 8 bit data w=1 16 bit data
00 memory mode no displacement
01 Memory mode, 8 bit displacement
10 Memory mode 16 bit displacement
11 Register mode no displacement
mod
Except when R/M =110, 16 bit displacement follows
MOD = 11 Effective address ( offset ) calculation
000 AL AX 000 [BX]+[SI] [BX]+[SI]+D8 [BX]+[SI]+D16
001 CL CX 001 [BX]+[DI] [BX]+[DI]+D8 [BX]+[DI]+D16
010 DL DX 010 [BP]+[SI] [BP]+[SI]+D8 [BP]+[SI]+D16
011 BL BX 011 [BP]+[DI] [BP]+[DI]+D8 [BP]+[DI]+D16
100 AH SP 100 [SI] [SI]+D8 [SI]+D16
101 CH BP 101 [DI] [DI]+D8 [DI]+D16
110 DH SI 110 Direct address [BP]+D8 [BP]+D16
111 BH DI 111 [BX] [BX]+D8 [BX]+D16
R/M W=0 W=1 R/M MOD=00 MOD=01 MOD=10
General Instruction Format
Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6
MOV BL,AL
Register / memory to/ from register
100010dw Mod reg r/m Displ-lo Displ-hi
Machine code
10001000 11 000 011
8 8 c 3 H
Assembly code
Immediate addressing mode
MOV AL, 15H
MOV destination operand, immediate source operand
XXXXHAX
Before the execution
XXA5HAX
After the execution
Immediate operand must begin with 0-9
MOV AL, 0A5H
Immediate to register 1011 w reg data Data if w=1
MOV AL, 15H 10110000 00010101
Assembly code Machine code
B015H
Direct addressing mode
The memory locations following the instruction op code hold an effective memory address
MOV AX, [0004]
Register / memory to / from register
100010dw Mod reg r/m Disp-lo Disp-hi
10001011 00000110 00000100 00000000
8 b 0 6 04 00
The logical address is [DS] : [ 0004]
μP
0000IP
0100
0200
XXXX
CS
DS
SS
ES
AX
μP
0004IP
0100
0200
BEED
CS
DS
SS
ES
AX
8B
06
04
00
ED
BE
8B
06
0400
ED
BE
01000
0100101002
01003
02004
02005
01000
0100101002
01003
02004
02005
XX
MOV AX, [0004]
Before execution After execution
Direct addressing mode
Register indirect addressing mode
MOV AX, [SI]
The logical address is [DS] : [BX]
or [DS] : [SI]
or [DS] : [DI]
μP0000IP
0100
0200
1234
XXXX
CS
DS
SI
AX
8B
04
XX
XX
ED
BE
01000
0100101002
01003
03234
03235
μP0002IP
0100
0200
1234
BEED
CS
DS
SI
AX
8B
04
XX
XX
ED
BE
01000
0100101002
01003
03234
03235
MOV AX, [SI]Register / memory to/ from register
100010dw Mod reg r/m Displ-lo Displ-hi
Machine code
10001011 00 000 100
8 B 0 4 H
Assembly code
Indexed addressing mode
Logical address = [ DS] : [SI] + direct or indirect displacement
[DS] : [DI] + direct or indirect displacementor
MOV AL,[SI]+1234H
Register / memory to / from register
100010dw Mod reg r/m Disp-lo Disp-hi
10001010 10000100 00110100 00010010
8 A 8 4 34 12
Based addressing mode
Logical address = [ DS] : [BX] + direct or indirect displacement
[SS] : [BP] + direct or indirect displacementor
MOV [BX]+1234H,AL
Register / memory to / from register
100010dw Mod reg r/m Disp-lo Disp-hi
10001000 10000111 00110100 00010010
8 8 8 7 34 12
Based addressing mode
MOV [BX]+1234H, AL
μP0000IP
0100
0200
1234
BEED
CS
DS
SI
AX
88
87
34
12
XX
XX
01000
0100101002
01003
04234
04235
μP0004IP
0100
0200
1234
BEED
CS
DS
SI
AX
8B
04
XX
XX
ED
XX
01000
0100101002
01003
04234
04235
1000BX
Indexed addressing mode
MOV AL,[SI]+1234H
μP0000IP
0100
0200
2000
XXXX
CS
DS
SI
AX
8A
84
34
12
BE
01000
0100101002
01003
05234
μP0004IP
0100
0200
1234
XXBE
CS
DS
SI
AX
8A
84
34
12
BE
01000
0100101002
01003
05234