Assembly Language Programming
Chapter 2
8088 Microprocessor
control bus
data bus
address bus
8088 Hardware Configuration
8088
MPU
External Memory
several
control lines
8 data lines
20 address
lines
8088 Hardware Configuration
8088
MPU
External Memory
control bus
data bus
(8 data lines)
address bus
(20 address
lines)
8088 Hardware Configuration
8088
MPU
How many
memory locations
can the 8088
microprocessor
access?
2
20
or 1,048,576
memory locations
External Memory
control bus
data bus
(8 data lines)
address bus
(20 address
lines)
8088 Hardware Configuration
8088
MPU
External Memory
00000
00001
00002
:
:
:
:
43249
4324A
4324B
:
:
:
:
FFFFD
FFFFE
FFFFF
How many
memory locations
can the 8088
microprocessor
access?
2
20
or 1,048,576
memory locations
control bus
data bus
(8 data lines)
address bus
(20 address
lines)
8088 Hardware Configuration
8088
MPU
External Memory
00000
00001
00002
:
:
:
:
43249
4324A
4324B
:
:
:
:
FFFFD
FFFFE
FFFFF What is the size of
each memory
location?
8 bits
control bus
data bus
(8 data lines)
address bus
(20 address
lines)
8088 Hardware Configuration
8088
MPU
External Memory
0000003
000019B
000028A
:
:
:
:
7C
DA
FF
00
3F
43249
4324A
4324B
:
:
:
:
FFFFD
FFFFE
FFFFF5A What is the size of
each memory
location?
8 bits
8088 Hardware Configuration
•20 address lines
•8 data lines
•several control lines
•considered as a 16-bit microprocessor
8088 Software Architecture
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
8088 Software Architecture
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
8088 Software Architecture
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
Write a program that initializes memory
location 00002 with 3F?
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
8088 Software Architecture
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Write a program that initializes memory
location 00002 with 3F?
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
8088 Software Architecture
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Write a program that initializes memory
location 00002 with 3F?
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
8088 Software Architecture
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Write a program that initializes memory
location 00002 with 3F?
External Memory
00000
00001
000023F
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
8088 Software Architecture
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
Write a program that initializes memory
location FFFFE with A2?
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
8088 Software Architecture
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, FFFFE
mov [BX], A2
Write a program that initializes memory
location FFFFE with A2?
What’s wrong
with this
program?
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
8088 Software Architecture
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, FFFFE
mov [BX], A2
Write a program that initializes memory
location FFFFE with A2?
BX cannot hold
the value FFFFE
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
8088 Software Architecture
External Memory8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
mov BX, FFFFE
mov [BX], A2
Write a program that initializes memory
location FFFFE with A2?
Does that mean I
can access only
memory locations
0000 to FFFF?
8088 Software Architecture
External Memory8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
mov BX, FFFFE
mov [BX], A2
Write a program that initializes memory
location FFFFE with A2?
No, aside from
memory locations
0000 to FFFF, you
can still access
memory locations
10000 to FFFFF
through a concept
called
MEMORY
SEGMENTATION
Memory Segmentation
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
dictates where your code is located
dictates where your
variables are located
dictates where your stack is located
will tell you the purpose of this
near the end of the term
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
this supposedly
mean: copy the
value 3F to
memory location
0002
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
000023F
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
this supposedly
mean: copy the
value 3F to
memory location
0002
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
000023F
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
this supposedly
mean: copy the
value 3F to
memory location
0002
...THIS IS NOT
ALWAYS TRUE
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
000023F
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
...THIS IS ONLY
TRUE IF the value
of DS is 0000
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
0000
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
000023F
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
...THIS IS ONLY
TRUE IF the value
of DS is 0000
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
...What if DS has a
different
value?...Let’s say
DS has a value of
1000
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
100023F
:
:
FFFFD
FFFFE
FFFFF
...Then memory
location 10002 will
have a value of 3F
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
100023F
:
:
FFFFD
FFFFE
FFFFF
...Then memory
location 10002 will
have a value of 3F
WHY?
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
100023F
:
:
FFFFD
FFFFE
FFFFF
...because as
mentioned earlier,
the data segment
(DS) dictates the
location of the
variables
Memory Segmentation
A value of 1000 for the Data Segment (DS)
means....
1000 + FFFF
10000
1FFFF
...the variables are located between memory
locations 10000 to 1FFFF
Memory Segmentation
8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
0002
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov BX, 2
mov [BX], 3F
Let’s go back to the program earlier...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
100023F
:
:
FFFFD
FFFFE
FFFFF
...this means that
if DS has a value
of 1000 and BX
has a value of
0002, the value 3F
will be written in
memory location
1000 x 10 + 0002
or
10002
Memory Segmentation
In general...
DS BX SEGMENT REG. OFFSETPHYSICAL ADDRESS = X 10 +
Memory Segmentation
•Q: In the instruction mov [BX], AL, what
should be the value of DS and BX to write to memory
location 87B24?
•A: DS = 8000 and BX = 7B24
•Q: Similar to the previous question, if DS has a value
of 8700, what should be the value of BX to write to
memory location 87B24?
•A: BX = 0B24
•Q: In the instruction mov [BX], AL, if DS has a value of
9A00 and BX has a value of 84BA, which memory
location will be accessed?
•A: memory location A24BA
Registers
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
Registers
External Memory8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
00000
:
:
FFFFF
Recall the program in Chapter 1...
Take note that the
MPU FETCHES,
DECODES,
EXECUTES an
INSTRUCTION.
83000C6
8300106
8300200
8300301
8300405
83005A0
8300600
8300701
8300804
8300903
8300AA2
8300B00
8300C02
mov byte ptr beta, 5
mov al, beta
add al, 3
mov alpha, al
Registers
External Memory8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
00000
:
:
FFFFF
Recall the program in Chapter 1...
In this example,
the MPU fetches
the instruction C6
from memory
location 83000...
83000C6
8300106
8300200
8300301
8300405
83005A0
8300600
8300701
8300804
8300903
8300AA2
8300B00
8300C02
mov byte ptr beta, 5
mov al, beta
add al, 3
mov alpha, al
Registers
External Memory8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
00000
:
:
FFFFF
Recall the program in Chapter 1...
In this example,
the MPU fetches
the instruction C6
from memory
location 83000...
...The question is,
how does the
MPU know where
to fetch the
instruction?
83000C6
8300106
8300200
8300301
8300405
83005A0
8300600
8300701
8300804
8300903
8300AA2
8300B00
8300C02
mov byte ptr beta, 5
mov al, beta
add al, 3
mov alpha, al
Registers
External Memory8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP
00000
:
:
FFFFF
Recall the program in Chapter 1...
...Through the CS
and IP
The CS and IP
holds the address
of the memory
location
containing the
next instruction to
be fetched.
83000C6
8300106
8300200
8300301
8300405
83005A0
8300600
8300701
8300804
8300903
8300AA2
8300B00
8300C02
mov byte ptr beta, 5
mov al, beta
add al, 3
mov alpha, al
Registers
External Memory8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
8000
SS
DS
CS
IP 3000
00000
:
:
FFFFF
Recall the program in Chapter 1...
...Through the CS
and IP
The CS and IP
holds the address
of the memory
location
containing the
next instruction to
be fetched.
83000C6
8300106
8300200
8300301
8300405
83005A0
8300600
8300701
8300804
8300903
8300AA2
8300B00
8300C02
mov byte ptr beta, 5
mov al, beta
add al, 3
mov alpha, al
Registers
External Memory8088 MPU
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
8000
SS
DS
CS
IP 3000
00000
:
:
FFFFF
Recall the program in Chapter 1...
What really happens
is:
1.MPU fetches
instruction from
memory location
CSx10 + IP
2.MPU increments
IP by 1
3.MPU decodes
instruction
4.If instruction is
not complete go
back to step 1
5.MPU executes
instruction
83000C6
8300106
8300200
8300301
8300405
83005A0
8300600
8300701
8300804
8300903
8300AA2
8300B00
8300C02
mov byte ptr beta, 5
mov al, beta
add al, 3
mov alpha, al
Registers
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
Registers
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
used to access the top of the stack
Registers
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
used to access any value
inside the stack
Registers
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
will tell you the purpose of this
near the end of the term
Memory Segmentation
8088 MPU
ODITSZAPC
DI 1654
BCA2SI
BP
SP
DX 3BDA
24CB
53BA
1234
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov SI, 3245
Look at the program...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
Memory Segmentation
8088 MPU
ODITSZAPC
DI 1654
3245SI
BP
SP
DX 3BDA
24CB
53BA
1234
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov SI, 3245
Look at the program...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
Memory Segmentation
8088 MPU
ODITSZAPC
DI 1654
3245SI
BP
SP
DX 3BDA
24CB
53BA
1234
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov AX, 41FE
Look at the OTHER program...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
Memory Segmentation
8088 MPU
ODITSZAPC
DI 1654
3245SI
BP
SP
DX 3BDA
24CB
53BA
41FE
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov AX, 41FE
Look at the OTHER program...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
What if I want to
change the lower
byte of AX to 3B?
(i.e. the value of
AX, which is 41FE,
will become 413B)
Memory Segmentation
8088 MPU
ODITSZAPC
DI 1654
3245SI
BP
SP
DX 3BDA
24CB
53BA
41FE
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov AL, 3B
Look at the NEW program...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
What if I want to
change the lower
byte of AX to 3B?
(i.e. the value of
AX, which is 41FE,
will become 413B)
Memory Segmentation
8088 MPU
ODITSZAPC
DI 1654
3245SI
BP
SP
DX 3BDA
24CB
53BA
413B
CX
BX
AX
ES
1000
SS
DS
CS
IP
mov AL, 3B
Look at the NEW program...
External Memory
00000
00001
00002
:
:
:
0FFFD
0FFFE
0FFFF
10000
10001
10002
:
:
FFFFD
FFFFE
FFFFF
What if I want to
change the lower
byte of AX to 3B?
(i.e. the value of
AX, which is 41FE,
will become 413B)
Registers
DX 3BDA
24CB
53BA
413B
CX
BX
AX
DH 3B
24
53
41
CH
BH
AH
DL DA
CB
BA
3B
CL
BL
AL
Registers
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
Registers
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
WHAT’S THIS?
Registers
8088 MPU
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
status registerSR
Registers
SR
Registers
SR
ODITSZAPC
Registers
8088 MPU
ODITSZAPC
DI destination index
source index
base pointer
stack pointer
SI
BP
SP
DX data
count
base
accumulator
CX
BX
AX
ES extra segment
stack segment
data segment
code segment
SS
DS
CS
IPinstruction pointer
External Memory8088 MPU
Other Examples
ODITSZAPC
DI
SI
BP
SP
DX
CX
BX
AX
ES
SS
DS
CS
IP