2. Main Units of a computer system
4
Input
Central
Processing Unit
Control
ALU
Memory
Instr1
Instr2
Instr3
Data1
Data2
Output
Computer System
Human operator
Sensors
Other computers
Coordinates action
in CPU and
performs
processing
Monitor
Printer
Actuator
Stores instruction
and data
3. Examples of a computer system
• Automatic Door
• Inputs: Sensor
• Output: Motor
• Air Conditioner (AC)
• Inputs: remote, temperature sensor
• Outputs: Cooling unit
• Line tracking robot
• Tracks a line
• Inputs: Left sensor and right
• Outputs: Right and left actuator
• Missile detonation system
• Inputs: Sensor
• Output: Detonator
4. Examples of a computer system…
• Fuel tank
• Inputs: Pressure sensors
• Output: 8 LEDs
Pseduocode
if(count < 32)
No LED on
else if(count >= 32 && count < 64)
One LED on
else if(count >= 64 && count < 96)
Two LEDs on
else if(count >= 96 && count < 128)
Three LEDs on
Input
Pressure
sensor
Central
Processing
Unit
Output
8 LEDs
A/D
converter
8-bit
Analog Digital
else if(count >= 128 && count < 160)
Four LEDs on
else if(count >= 160 && count < 192)
Five LEDs on
else if(count >= 192 && count < 224)
Six LEDs on
else if(count >= 224 && count <245)
Seven LEDs on
else
All LEDs on
5. Memory
Memory Chip
m w
2m × w
CS OE WE
Address
m
Data
w
m: width of the address bus
w: width of the data bus
CS: Chip Select
OE: Output Enable
WE: Write Enable
Memory contains 2m locations
each of w bits
CS
0 1
Chip
disabled OE = 0
WE = 0
No Read/
No Write
OE = 0
WE = 1
Write operation
OE = 1
WE = 0
Read operation
OE = 1
WE = 1
Chip
enabled
6. Memory Access Example
Memory Chip
m = 3 w = 4
2m × w
CS OE WE
1 0 1 0
Memory contains 2m = 23 = 8
locations each of w = 4 bits
Data width = 4
000
0 0 0 1
0 0 0 0
1 0 1 1
001
010
011
1 1 1 1
100
0 0 1 1
1 0 0 0
0 0 1 1
101
110
111
m = 101 CS = 0 OE = 0 WE = 0
No read or write operation
Address
lines m
Data
lines w
m = 101 CS = 1 OE = 1 WE = 0
Read Operation at location 101
w3 w2 w1 w0
= 0 0 1 1
w3 w2 w1 w0
= 1 1 1 0
m = 111 CS = 1 OE = 0 WE = 1
Write Operation at location 111
1 1 1 0
7. Microprocessor (CPU) interface
Microprocessor
(CPU)
Address lines (A)
Data lines (D)
R/W*
AS (Address strobe)
Address lines : To address a particular location in memory
R/W* : To perform a read (R/W* = 1) or a write operation (R/W* = 0)
Data lines: Direction of data determined by R/W* signal
AS = 1 Microprocessor has generated a valid address
AS = 0 The address is invalid
8. How to connect CPU with memory
A11-A00
D07-D00
2A × D
212 × 8
Microprocessor
R/W*
AS
w = 8
m=12
2m × w
212 × 8
Memory Chip
CS OE WE
R/W* = 1/0
0/1
9. Inside the 8086/8088 (Registers)
• Register provides faster access compared to
memory
• In the CPU, registers store information temporarily.
– One or two bytes of data to be processed.
– The address of data.
• General-purpose registers in 8088/86 processors
can be accessed as either 16-bit or 8-bit registers
– All other registers can be accessed only
as the full 16 bits.
• In 8088/86, data types are either 8 or 16 bits
– To access 12-bit data, for example, a 16-bit register
must be used with the highest 4 bits set to 0.
10. Inside the 8086/8088 (Registers)
• The bits of a register are numbered in descending
order, as shown:
• The first letter of each register indicates its use.
– AX is used for the Accumulator (divided into AH/AL).
– BX is a Base addressing register.
– CX is a Counter in loop operations.
– DX points to Data in I/O operations.
Higher byte Lower Byte
11. General purpose registers
AX (Accumulator)
AH AL
BX (Base Register)
BH BL
CX (Used as a counter)
CH CL
DX (Used to point to data in I/O operations)
DH DL
15 8 7 0
Higher byte Lower byte
• Data Registers are normally used for storing temporary results
that will be acted upon by subsequent instructions
• Each register (AX, BX, CX, DX) is 16-bit wide.
• General purpose registers can be accessed as either 16 or 8 bits
-- AH: upper half of AX
-- AL: lower half of AX
12. Register addressing mode
• In register addressing mode, the operand lies in a register.
• The general form of using an immediate addressing mode is mnemonic dest,
source
• The content of dest is changed while the source content remains same
• Register can be used as a source or destination
Instruction AX (AH/AL) BX (BH/BL) CX (CH/CL) DX (DH/DL)
Initial value 0x5421 0xAB12 0x0003 0x0000
MOV AX, BX
Old value
0xAB12 0xAB12 0x0003 0x0000
ADD CX, AX 0xAB12 0xAB12 0xAB15 0x0000
Old value
MOV DH, AL 0xAB12 0xAB12 0xAB15 0x1200
New value
Old value
MOV CL, DL 0xAB12 0xAB12 0xAB00 0x1200
New value
Old value
New value New value
New value
CX = CX + AX
13. Immediate addressing mode
• In Immediate addressing mode, the operand is a part of instruction.
• Immediate addressing mode is used to initialize a constant to a variable (e.g., int
c = 13)
• The variable can be either stored in memory or a register
• The general form of using an immediate addressing mode is mnemonic dest,
value where value is a constant
• Destination can either be a register or a memory
Instruction AX (AH/AL) BX (BH/BL) CX (CH/CL) DX (DH/DL)
Initial value 0x0000 0x0000 0x00AF 0x0001
MOV AX, 2105H
Old value
0x2105 0x0000 0x00AF 0x0001
New value
MOV BX, 65 0x2105 0x0041 0x00AF 0x0001
Old value
New value
New value
MOV CH, 2BH 0x2105 0x0041 0x2BAF 0x0001
New value
Old value
ADD DL, C3H 0x2105 0x0041 0x2BAF 0x00C4
New value
Old value