Ch2 Architecture
Ch2 Architecture
Chapter 2
Machine Language
Binary Instructions
Difficult to decipher and write
Error-prone
All programs converted into machine language for
execution
Assembly Language
Machine instructions represented in
mnemonics
One-to-one correspondence
Efficient execution and use of memory
Machine-specific
High-Level Languages
BASIC, C, and C++
Written in statements of spoken languages
Machine independent
Easy to write and troubleshoot
Larger memory and less efficient execution
Hardware models:
Von Neumann Model.
The System Bus Model.
Harvard Model
µP
Program Data
memory memory
µP Data
Program
memory memory
Nibble 4 bit
Byte bit 8
Word bit 16
Consists of:
Arithmetic logic unit (ALU)
This is a combinational circuit that
performs arithmetic and logic operations.
Control unit
This is a state machine that generates
control signals that control the ALU and
memory transfers.
Registers
These are storage locations in the CPU
Sometimes there is a special register
called an accumulator that is used for
most instructions.
OE : Output Enable
WE : Write Enable
Data : D0 D1 D2 D3 D4 D5 D6 D7
Fall 2023-2024 Abdulbaset Ashour P 27
Ch
Memory (Read)
8x8bit memory
Decoder
Control
1 1 0 1 1 0 0 0
Mem. Read=1 0 1 1 1 0 1 0 0
Mem.Write=0 1 0 1 0 0 0 1 0
00 10 11 10 11 0
1 01 0
Address
0 1 1 1 0 0 1 1
A0=1
0 1 0 0 1 1 0 1
A1=1
0 1 1 0 0 1 1 0
A2=0
1 1 0 1 1 0 0 1
Data : D0 D1 D2 D3 D4 D5 D6 D7
8x8bit memory
Decoder
Control
1 1 0 1 1 0 0 0
Mem. Read=0 0 1 1 1 0 1 0 0
Mem.Write=1 1 0 1 0 0 0 1 0
0 0 1 0 1 1 1 0
Address
0 1 1 1 0 0 1 1
A0=1
0 1 1 0 0 1 0
A1=0
0 1 1 0 0 1 1 10
A2=1
1 1 0 1 1 0 0 1
0 0 0 1 1 1 0 0
Data : D0 D1 D2 D3 D4 D5 D6 D7
BIU contains:
Instruction queue.
Segment registers.
Instruction pointer.
Address adder.
6
5
4
3
2
1
(1MByte) in memory.
Four segment registers in the BIU are used
to hold the upper 16 bits of the starting Stack Segment 64 KB
addresses of four memory segment:
1.Extra Segment (ES) register.
2.Stack Segment (SS) register.
Code Segment
3.Code Segment ( CS) register. 64 KB
Data Segment
64 KB
CS Register
DS Register
SS Register First Memory Address 00000H
ES Register
= B 0000 0000 0000 0000 0000
address.
Stack Segment: is a section of memory set aside
to store addresses and data while a subprogram
Code Segment
executes, the stack segment register is used to 64 KB
Top of Extra
7FFFFH
Segment
The address bus of 8086 is 20 bit
Extra Segment
The 20 bit physical address (also called real or
absolute address) can be represented by 2 X 16 bit Bottom of Extra
Segment
70000H
Bottom of Code
Segment 348A0H
Address
Generation
Top of Data
2FFFFH
Segment
First Memory
Fall 2023-2024 Abdulbaset Ashour 00000H
P 38
Address
Ch
Physical Address Generation
Offset address
1 0 1 0 0 0 0 1 0 0 0 0 1 0 1 1
1 0 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 1 1
Fall 2023-2024 Abdulbaset Ashour P 39
Ch
Physical Address Generation
• The BIU has a dedicated adder for determining physical
memory addresses.
Adder
:Offset 1001010000000000
:Segment 00000000000010000000
:Address 01000000000010001001
Address 0002H
Generation 0001H ?
0000H ?
CS=3000H
DS
SS
ES
IP =0005H
Control Unit
ALU
The AX, BX, CX, and DX registers can be considers as two 8-bit registers, a High
byte and a Low byte. These are referred to as general-purpose registers (GPR).
The advantage of using GPR: Since the data is already In the EU, it can be
accessed much more quickly than it could be accessed in external memory.
AX
Accumulator Register
Preferred register to use in arithmetic, logic
and data transfer instructions because it
generates the shortest Machine Language
Code.
Must be used in multiplication and division
operations.
Must also be used in I/O operations.
BX
Base Register.
Also serves as an address register.
CX
Count register.
Used as a loop counter.
Used in shift and rotate operations.
DX
Data register.
Used in multiplication and division.
Also used in I/O operations.
Carry flag
Overflow
Direction Parity flag
• AF (auxiliary carry) Contains carry out of bit 3 into bit 4 for specialized
arithmetic (BCD).
• PF (parity) set if parity (the number of "1" bits) in the low-order byte of
the result is even.
15 8 7 0
EU registers
AX AH AL Accumulator
BX BH BL Base Register
CX CH CL Count Register
DX DH DL Data Register
SP Stack Pointer
BP Base Pointer
SI Source Index Register
DI Destination Index Register
FLAGS Flag Register
References:
Text Books.
Microprocessors lecture slides from Eng. Jalal Miladi.
Readings:
Douglas Hall, Ch2, pp 28-32.