Sap PDF
Sap PDF
Sap PDF
SAP-1
Block Diagram
SAP1 Architecture
Simple-As-Possible.
One output device with 8 LEDs
16 bytes of RAM
5 instructions
3 with 1 operand,
2 with implicit operands.
Accumulator Architecture
Accumulator, Out Register,
B Register, Memory Address Register (MAR)
Instruction Register (IR).
CON CP EP LM CE L1 E1 L A E A SU EU LB LO
CON CP EP LM CE L I E I L A EA SU EU LB LO
= 1 0 1 1 1 1 1 0 0 0 1 1
= B E 3
CON CP EP LM CE L I E I L A EA SU EU LB LO
= 0 0 1 0 0 1 1 0 0 0 1 1
= 2 6 3
The next three states (T4, T5, and T6) are the execution
cycle of SAP-1.
The register transfers during the execution cycle
depend on the particular instruction being executed.
For instance. LDA 9H requires different register
transfers than ADD BH.
What follows are the control routines for different
SAP-1 instructions.
SAP-1
Simulation
0000 1000
of Program
1111
0001 1111
0000
1110 1001
0101
1010
0011
LDA 9H
ADD AH 1010
1001
OUT
0000
0001
1110
1111
HLT
08
Computer
Halted
Thursday, 19 January, 2017
54
Acknowledgement:
Engr. Rashid Farid Chishti
Lecturer, Faculty of Engineering &
Technology
International Islamic university
Islamabad.
Mobile: 0321 5300 497
E-mail: chishti@iiu.edu.pk
LOAD
CLK
Enable
BUS
Architecture
Bus W
Ack Encoder
Hexa A
8
8
In Port 1 8 8 ALU 2 Flag
8
Ready 0
8
Serial In
7 In Port 2 8 TEMP
PC 16
8 B
MAR 16 8 C
16
Memory
8
8 0
IR 8 Out Port 4 7
Serial Out
Ack
8
CON
Input port
Port 1 and Port 2
Port 1
• Hexadecimal keyboard encoder
• Sends ready signal to bit 0 of port 2 (indicates
the data in port 1 is valid)
Port 2
Serial In
Program Counter
16 bit address
LOW CLR’
MAR and MEMORY
16- bit address to MAR (From 0000H FFFFH)
0000 H
ROM
07FF H
0800 H
Same as SAP-1
ALU and Flags
• ALU: Includes both arithmetic and logical
operation
• 4 or more control bits for determining the
operation to be performed
Eg:
LDA 2000H
STA 8000H
MVI
MVI-Move Immediate
MVI A,37H
MVI A,byte
MVI B,byte
MVI c, byte
Register Instruction
MOV
MOV A,B
MOV A,C
MOV B,A
MOV B,C
MOV C,A
MOV C,B
Register Instruction
ADD and SUB
Eg ADD B /SUB B
ADD B
ADD C
SUB B
SUB C
Register Instruction
INR and DCR
INR A/DCR A
INR B/DCR B
INR C/DCR C
Jump And Call Instruction
JMP
JMP 3000H
JM (Jump if Minus)
JZ(Jump if zero)
JNZ(Jump if not zero)
Jump And Call Instruction
CALL
Subroutine ????
• Fetch 3 T-States
• Execution Different instruction requires
different # of T-States
• Ex: ADD B 4
• ANI byte 7
• CALL 18
• JM 10/7
Summary 1
Summary 2
Math-1
Solution of Math-1
Math-2
Solution of Math-2
Thank you
SAP-3
8
In Port 1 8 8 ALU 2 Flag
8
Ready 0
8
Serial In
7 In Port 2 8 TEMP
PC 16
8 B
MAR 16 8 C
16
Memory
8
8 0
IR 8 Out Port 4 7
Serial Out
Ack
8
CON
Architecture (Like as SAP2)
PC A
SP B C
D E
F H L
Program Counter
16 bit address
Same as SAP-1
ALU and Flags
• ALU: Includes both arithmetic and logical
operation
• 4 or more control bits for determining the
operation to be performed
1.Add Carry
2.Sub Borrow
Carry Flag Instructions
• STC SeT Carry (CY =1)
• CMC CompleMent Carry
• CY = 𝐶𝑌
ADD
ADD reg
reg = A, B, C, D, E, H, L
ADC
ADC ADD with Carry (CY).
SUB reg
reg = A, B, C, D, E, H, L
reg = A, B, C, D, E, H, L
Compare Instruction
CMP reg
reg = A, B, C, D, E, H, L
• Z flag effected after the operation
Arithmetic & Logic Immediate
ANI byte
ORI byte
XRI byte
SAP3
• JP (Jump if positive)
• JC ( Jump id Carry)
• JNC ( Jump if not Carry)
• JPE (Jump if Even Parity)
• JPO (Jump if Odd Parity)
Extended Register
• Register pairs 16 bits
• 3 pairs (BC, DE and HL)
Extended Instructions
• X for Extended instruction
LXI B, dble
LXI D, dble
LXI H, dble
HL M
Indirect Write
MOV M, reg
reg = A, B, C, D, E, H, L
M = memory address
HL M
Indirect Immediate Instructions
MVI M, byte
M = memory address
HL M
Other Instructions by HL pointer
• ADD M
• ADC M
• SUB M
• SBB M
• INC M
• DEC M
• ANA M
• ORA M
• XRA M
• CMP M
STACK Instructions
• Begin Address: 20FFh
• End Address: 20E0h
• PUSH, POP
• Before call we need to store registers & Flags
PUSH B (BC)
PUSH D (DC)
PUSH H (HL)
PUSH PSW
PUSH operation
• When PUSH instruction is executed, the
following things happen:
– The SP is decremented to get a new value of SP-1
– The high byte in the specified register pair is
stored in M[SP-1]
– The SP is decremented again to get SP-2
– The low byte in the specified register pair is
stored in M[SP-2]
POP Operation
• When POP is executed, the following happens:
– REVESE of PUSH !!
Call & RET Instructions
CALL
Subroutine ????