Microprocessor AEE Part2
Microprocessor AEE Part2
Course contents
1. Introduction to microprocessor systems
2. The Intel 8088/8086 microprocessors
3. Assembly programming for 8086
4. Memory and I/O Interfacing
5. Interrupt
6. Didect memory access (DMA)
7. Real life microprocessors
© DHBK 2005 2/Chapter2
Data bus
ALU 16 bit Bus control
logic
Temporary registers (hidden)
External
EU Control Bus
ALU Unit
Arithmetic
Logic Unit
Instruction queue
Flags Register (88: 4 bytes; 86: 6 bytes)
© DHBK 2005 6/Chapter2
CX CH CL
DX DH DL
10000 1000
Physical address=Segment*16 + offset
Segment register
real mode memory managment 00000
© DHBK 2005 10/Chapter2
• Example 2: Given the beginning address of the segment 4900x 10H = 49000
H, determine the ending address: maximum offset (16bit) = FFFF H
© DHBK 2005 11/Chapter2
00000
© DHBK 2005 12/Chapter2
s
t
a d
c a
k 0A480
t 0A47F
a c Stack
o 0A280
d 0A28 SS
0A27F
e Data
0A0F0 0A0F DS
0A0EF
Code
090F0 090F CS
00000
© DHBK 2005 13/Chapter2
CS IP Instruction address
SS SP or BP Stack address
ES DI Destination string
address
© DHBK 2005 16/Chapter2
15 14 2 1 0
O D I T S Z A P C
15 14 2 1 0
O D I T S Z A P C
• 3 control flags
T or TF (trap flag)): TF=1 => CPU will execute only one instruction at a
time
I or IF (Interrupt enable flag): IF=1 => maskable interrupts are enabled
D or DF (direction flag): DF=1 => CPU will work with string from right to
left (instruction STD, CLD)
© DHBK 2005 19/Chapter2
100h
7Fh
+
01h
????
© DHBK 2005 20/Chapter2
without
pipelining F1 D1 E1 F2 D2 E2 F3 D3 E3
t
F1 D1 E1
with pipelining F2 D2 E2
F3 D3 E3
t
© DHBK 2005 22/Chapter2
Extended
memory
08E30
COMMAND.COM
08490
Device drivers (mouse.sys)
02530
MSDOS
01160
IO.SYS
00700
DOS area
00500
BIOS area
00400
00000 Interrupt vector table
© DHBK 2005 30/Chapter2
Reserved area
C8000
Video BIOS ROM
C0000
Video RAM (text)
B0000
Video RAM (graphics)
A0000
© DHBK 2005 31/Chapter2
003FF
Interrupt vectors
00000
© DHBK 2005 32/Chapter2
Extended area
COM1
03F8
Floppy disk controller
03F0
CGA adapter
03D0
LPT1
0378
Hard disk controller
0320
COM2
02F8
8255
0060
Timer (8253)
0040
Interrupt controller
0020
0000 DMA conntroller
© DHBK 2005 33/Chapter2
• Examples:
MOV BX, DX ; Copy the content of DX into BX, the content of DX is
unchanged
MOV AL, BL ;
ADD AL, DL ; AL=AL+DL
© DHBK 2005 35/Chapter2
• Examples:
MOV AL, [ 1234H ] ; Copy the content of memory location with address
DS:1234 into AL
MOV [ 4320H ], CX ; Copy the content of CX into two consecutive memory
locations with addresses DS: 4320 and DS: 4321
© DHBK 2005 37/Chapter2
• Examples:
MOV AX, [BX] [SI]+8 ; Copy the content of two consecutive memory
locations with addresses DS:BX+SI+8 and DS:BX+SI+9 into AX
MOV AX, [BX+SI+8] ;
MOV CL, [BP+DI+5] ; copy the content of memory location with address
SS:BP+DI+5 into CL
© DHBK 2005 41/Chapter2
Register Registers
Direct [offset] DS
Segment override
• Examples:
MOV AL, [BX]; Copy the content of memory location with address DS:BX
into AL
MOV AL, ES:[BX] ; Copy the content of memory location with address
ES:BX into AL
© DHBK 2005 43/Chapter2
Byte Opcode
D W
7 6 5 4 3 2 1 0
1 0 0 0 1 0 1 0 0 0 0 0 1 1 1 1
• MOV
Used to move data amongst registers, between one register and one
memory location or move a constant into a register or a memory location
Syntax: MOV Destination, source
This instruction doesn’t affect flags.
Examples:
MOV AX, BX
MOV AH, ‘A’
MOV AL, [1234H]
© DHBK 2005 50/Chapter2
• PUSHF
Store the content of flag register on top of the stack
© DHBK 2005 53/Chapter2
1300A 1300A
13009 12 13009 12
13008 34 13008 34 SP
13007 78 13007 78
13006 SP 13006
56 56
13005 13005
13004 13004
13003 13003
13002 13002
13001 13001
13000 13000
SS 1300 SS 1300
SP 0006 SP 0008
DX 1234 DX 7856
© DHBK 2005 56/Chapter2
subProgram:
PUSH AX ; Store AX into stack
PUSH BX ; Store BX into stack
PUSHF
MOV AX,0 ;
MOV BX, 10
POPF
POP BX ; Get back the old values of AX, BX
POP AX
RET ;Return to the main program
© DHBK 2005 57/Chapter2
• ADD
Syntax: ADD destination, source
Operation: destination=detination + source
Constraints: both operands must not be memory locations nor segment
registers
This instruction affects the following flags: AF, CF, OF, PF, SF, ZF
Examples:
ADD AX, BX
ADD AX, 40H
© DHBK 2005 60/Chapter2
1 0 1 0 0 1 1 0 1
0 1 0 0 1 1 0 1 1
© DHBK 2005 69/Chapter2
• SHL-SHift Left
Logic shift left, similar to SAL
© DHBK 2005 70/Chapter2
CF AL
0 0 1 0 0 1 0 1 0
• Before: AL=25H=37
• After: AL=4AH=74
© DHBK 2005 71/Chapter2
0
© DHBK 2005 73/Chapter2
1 0 1 0 0 1 1 0
0 1 0 1 0 0 1 1 0
Jump scope: -128 to 127 bytes from the instruction right after JMP instruction
Operation: IP=IP + displacement
Example:
XOR BX, BX
Label1: MOV AX, 1
ADD AX, BX
JMP SHORT Label1
© DHBK 2005 76/Chapter2
E 9 DispLo DispHi
Indirect jump
© DHBK 2005 77/Chapter2
Store CS in stack
Store IP in stack
IP=IP of Tong
CS =CS of Tong
RET: get IP and CS back
from stack
© DHBK 2005 81/Chapter2
Index TI RPL
GDOA Limit
7 00000000 00000000 6 7 Base(B31-B24) 6
V (L19-L16)
5 Access rights Base(B23-B16) 4 5 Access rights Base(B23-B16) 4
3 Base(B15-B0) 2 3 Base(B15-B0) 2
1 Limit(L15-L0) 0 1 Limit(L15-L0) 0