Professional Documents
Culture Documents
Memory :
14.
8Data Lines
16 Address Lines
64 1024 1 Byte=64 1 K B
IO/ M
10
Frequency of P=
Frequency of Crystal
=3.072 MHz
2
4.
8bit Registers : B , C , D , E , H , L, FR ( Flag Reg ) , A ( Accumulator )
5.
6.
7.
8.
9.
10.
11.
12.
S
Status Lines : S 0 , S 1
S1
M /C
S0
Memory Write
Memory Read
Opcode Fetch
I /O Write
I /O Read
Interrupt Acknowledgement
Halt
IO/ M
WR
3:8 Decoder
RD
O/ P
'
Invalid
MEMR
MEMW
Invalid
Invalid
IOR
AC
CY
ALU Result
ve (Signed Nos)
MSB=1(Unsigned Nos)
00 H
CarryBorrow occurs
CarryBorrow occurs
13.
IOW
S=1
Invalid
Z =1
17.
FLAG
AC=1
Interrupt
P=1
TRAP
CY =1
HOLD=1 Request
HLDA =0 acknowledgement
Device P P Input Device
Input
Hardware Interrupts :
Vector
Masking
Triggering
0024 H
NMI
RST 7.5
003 C H
Maskable
+ve edge
RST 6.5
0034 H
Maskable
level
RST 5.5
002C H
Maskable
level
NVI
Maskable
level
( RST 4.5 )
INTR
Priority
Highest
Lowest
Address
MemoryI /O
2.
1.
Given
Required
No. of Memory I C' s required=
Memory Description :
e . g . N KB isexpanded M KB i. e . 2 B 2 B then ,
1 Byte=1 memory location
10
10
N KB=2 2 Bytes=2
i+10
memory locations
3.
Offset=EA
If SA 00 000 H
Offset =EASA
5.
SA=EAOffset
Device itself . 16 Address Lines are given Memory , out of which 8 LSB
Address Lines areshared by I /O Device . Here memory is not distributed .
Memory
16 ( A15 A 0 )
I /O Device
I /O Mapped I /O
Memory
I /O Device
16 ( A15 A 0 )
8 ( A7 A 0 )
=Unused
IO/ M
RD= MEMR
MEMW
WR=
MEMR
MEMW
Memory
NO . of I /O Devices
64 KB
3 :8 Decoder is required
MEMR
MEMW
IOR
IOW
8
Memory 64 KB
1.
4.
the Memory
2.
5.
Address of a
Opcode of an Instruction
Memory Location
8 bit Data
6.
M /C=F /C + E /C
7.
1 Byte 1 F /C 1 M / C
3.
E . g . MOV C , A
Address
Opcode
an Acknowledge ( DMANVI)
8250 H
4 F H ( Opcode of MOV )
Machine Cycle
POperation
Symbol
8.
2 Byte 2 F /C 2 M / C
States
E . g . MVI B , 2C H
Opcode read
Memory (3 T )
4T
Opcode read
Memory (3 T )
+Opcode Decode ( 1 T )
6T
Memory Read M /C
Memory Write M /C
Memory
8 bit data Write
9.
Address
8250 H
4 F H Opcode of MVI
8251H
2C H 8 bit Data
+ Extension(2 T )
8 bit data Read
LXI B , 3 F 2 C H
R
3T
Address
3T
8250 H
4 F H Opcode of LXI
8251H
2C H Lower Byte
Memory
I /O Read M /C
I /O Write M /C
Hold Acknowledge M /C
Acknowledge M /C
8 bit dataWrite
I /O Device
8252H
I
3T
10.
3 F H Higher Byte
3T
11.
12.
Arithmetic Instructions
1.
Operations happeninside ALU , so all Flags are affected , with few exceptions
2.
B Bytes
X 16bit RegR p
A Accumulator R P 16bit Reg Pair
M MachineCycles
I 816 bit Immediate Data R 8bit Reg M Data HL R P
T T States
Instructions
Operation
ADD R
A +R A
ADC R
A + R+CY A
ADD M
A +M A
ADC M
A + M +CY A
A +8 bit data A
A +8 bit data+ CY A
AR A
SBB R
ARCY A
AM A
SBB M
AM CY A
A8 bit data A
A8 bit dataCY A
INR R
R+1 R
DCR R
R1 R
INR M
M + 1 M
DCR M
M 1 M p
M /C
T States
B|M |T
ADD ADC 1 F
4T
1|1| 4
ADD ADC 1 F
M 1R
4T
3T
1|2|7
ADI ACI 1 F
8 bit data 1 R
4T
3T
2|2|7
SBB 1 F
4T
1|1|7
SBB 1 F
M 1R
4T
3T
1|2|7
SUI SBI 1 F
8 bit data 1 R
4T
3T
2|2|7
INRDCR 1 F
4T
1|1| 4
INRDCR 1 F
M 1 R
M 1W
4T
3T
3T
8bit Registers : A , B , C , D , E , H , L
8bit Registers : A , B , C , D , E , H , L
INX RP
INX SP
RP +1 R P
SP+1 SP
DCX R P
DCX SP
RP 1 R P
SP1 SP
INRDCR 1 S
6 T ( S)
1|1|6
DAD R P
DAD SP
R P + HL HL
SP+ HL HL
DAD 1 F
Bus Idle 2 B
4T
6T
1|3|10
ALU
Logic Instructions
1.
Operations happeninside ALU , so all Flags are affected , with few exceptions
2.
Operation
Legends : Operation
XOR Operation
T States
Instructions
Operation
M /C
ORA R
A R A
ORA 1 F
4T
1|1| 4
ORA M
A M A
ORA 1 F
M1 R
4T
3T
1|2|7
CY =0AC =0
B|M |T
Flags Affected
A 8 bit data A
ORI 1 F
8 bit data 1 R
4T
3T
2|2|7
XRA R
A R A
XRA 1 F
4T
1|1| 4
XRA M
A MA
XRA 1 F
M 1R
4T
3T
1|2|7
8bit Registers : A , B , C , D , E , H , L
A 8 bit data A
XRI 1 F
8 bit data 1 R
4T
3T
2|2|7
XRA A A=00 H CY =0
ANA R
A R A
ANA 1 F
4T
1|1| 4
ANA M
A M A
ANA 1 F
M 1 R
4T
3T
1|2|7
A 8 bit data A
ANI 1 F
8 bit data 1 R
4T
3T
2|2|7
RAL
RAR
MSB CY
CY LSB
MSB CY
MSB LSB
LSB CY
CY MSB
RRC
LSB CY
LSB MSB
CMP R
AR
CMP 1 F
4T
1|1| 4
CMP M
AM
CMP 1 F
M 1 R
4T
3T
1|2|7
CPI 1 F
8 bit data 1 R
4T
3T
RLC
A8 bit data
8bit Registers : A , B , C , D , E , H , L
Only CY Flag isafffected
Operationdoesnt happenALU
1F
4T
1|1| 4
Operationoccurs Accumulator
RLC= A 2
A Condition : Unitl MSB=1
RRC=
2
CMA 1 F
CMA
4T
A A
Operationdoesnt happenALU
1|1| 4
Operationoccurs Accumulator
CMC
CY
CY
CMC 1 F
4T
1|1| 4
STC
CY =1
STC 1 F
4T
1|1| 4
DataTransfer Instructions
Between 2 Registers
Between RegistersMemory
Immediate Data
Immediate Data
Data Transfer is POSSIBLE : { Memory
NO FLAGS ARE AFFECTED
DataTransfer is IMPOSSIBLE : { Between 2 Memory Locations
Instructions
Operation
M /C
MOV R d , R s
Rs R d
F /C : { MOV 1 F
4T
1|1| 4
MOV R d , M
M Rd
F /C : { MOV 1 F
E /C : { M 1 R
4T
3T
1|2|7
MOV M , R s
Rs M
F /C : { MOV 1 F
E /C : { M 1W
4T
3T
8 bit data R d
F /C :
1F
{8 bitMVIdata
1R
T States
4T
3T
B|M |T
1|2|7
2|2|7
CommentsRegisters used
No. of F /C=
No. of
Bytes of Instruction
No. of M /C
No. of
Bytes of Instruction
8bit Registers : A , B , C , D , E , H , L
F /C :
MVI M , 8 bit data
8 bit data M
{8 bitMVIdata1 F1 R
E/C : { M 1 W
LXI RP , 16 bit data
16 bit data R P
16 bit data SP
Instructions
4T
3T
3T
M /C
( 16 bit address ) A
LDA 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
4T
3T
3T
3T
A ( 16 bit address )
{
{
2|3|10
3T
Operation
8 bit data A
LXI 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
4T
3T
T States
STA 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
4T
3T
3T
3T
3|3|10
B|M |T
( 16 bit address ) A
3|4|13
STAX R P
A ( 16 bit address )
8bit data A
4T
3T
1|2|7
8 bit data A
A ( ( RP ) )
CommentsRegisters used
(( R P ) ) A
LDAX R P
16bit Registers : B , D , H , SP
F /C : { LDAX 1 F
E/C : {8 bit data 1 W
4T
3T
1|2|7
( 16 bit address ) L
LHLD 16 bit address
( 16 bit address+1 ) H
L ( 16 bit address )
H ( 16 bit address+1 )
LDA 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
4T
3T
3T
3T
3T
LDA 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
4T
3T
3T
3T
3T
3|5|16
(Unlike )
XCHG
HL DE
F /C : { XCHG 1 F
4T
1|1| 4
PCHL
HL PC
F /C : { PCHL 1 S
6 T ( S)
1|1|6
SPHL
HL SP
F /C : { SPHL 1 S
6 T ( S)
1|1|6
L ( 16 bit address )
H ( 16 bit address+ 1 )
4T
3T
3T
3T
3T
XTHL 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
E/C : Lower Byte 1W
Higher Byte 1 W
HL Top of WZ HL
1|5|16
Instructions
Operation
M /C
PUSH R P
RP H ( ( SP1 ) )
F /C : { PUSH 1 S
T States
6 T ( S)
B|M |T
CommentsRegisters used
1|3|12
RP L ( ( SP2 ) )
PUSH PSW
A ( ( SP1 ))
3T
3T
(UnlikeSHLD operation)
POP PSW
( ( SP ) ) R PL
( ( SP+ 1 ) ) RP H
( ( SP ) ) FlagByte
F /C : { PUSH 1 F
4T
1|3|10
3T
3T
increased by 1
Latest Position of SP+2
( ( SP+ 1 ) ) A
Branching Instructions
PC Register is AFFECTED
Instructions
Operation
M /C
16 bit address PC
JMP 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
4T
3T
3T
JC 16 bit address
If CY =1
JMP 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
4T
3T
3T
16 bit address PC
If CY =0
16 bit address PC
{
{
F /C :
JC 1 F
Lower Byte 1 R
T States
4T
3T
B|M |T
CommentsRegisters used
3|3|10
Unconditional Jump
|32| 107
JZ 16 bit address
JNZ 16 bit address
JM 16 bit address
JP 16 bit address
Instructions
CALL 16 bit address
If CY =0
J 1 F
F /C : Lower Byte 1 R
Higher Byte 1 R
If Z=1
If Z=0
Other
If S=1
wise
If S=0
16 bit
If P=1
J 1 F
F /C :
address PC Lower Byte 1 R
4T
3T
3T
the
4T
3T
If P=0
16 bit addr PC
After F /C PC =PC+3
Operation
M /C
PC H ( ( SP1 ) )
CALL 1 S
F /C : Lower Byte 1 R
Higher Byte 1 R
PC L ( ( SP2 ) )
16 bit address PC
Latest SP=SP2
T States
6 T (S)
3T
3T
3T
3T
B|M |T
CommentsRegisters used
3|5|18
After F /C PC =PC +3
If CY =1
PC H ( ( SP1 ) )
PC L ( ( SP2 ) )
CC 16 bit address
16 bit address PC
6 T (S)
3T
3T
3T
3T
CALL 1 S
F /C : Lower Byte 1 R
Higher Byte 1 R
E/C : Higher Byte 1 W
Lower Byte 1W
PC L ( ( SP2 ) )
F /C :
CC 1 S
Lower Byte 1 R
If CY =0
CZ 16 bit address
If Z=1
If Z=0
CM 16 bit address
If S=1
If S=0
If P=1
If P=0
6 T (S)
3T
|52| 189
16 bit address PC
C 1 F
F /C : Lower Byte 1 R
16 bit address PC
Higher Byte 1 R
4T
3T
3T
RET
Top of the PC
F /C : { RET 1 F
4T
Unconditional
Return
i. e . ( ( SP ) ) PC L
3T
3T
the
If CY =0
PC H ( ( SP1 ) )
1|3|10
Similar POP R P
Latest SP=SP+2
( ( SP+ 1 ) ) PC H
Operation
M /C
NoOperation4 T states
F /C : { NOP 1 F
HLT
Pis Halted
T States
F /C : { HLT 1 F
Halt Acknowledge M /C
4T
4T
1 T
B|M |T
CommentsRegisters used
1|1| 4
1|2| 5
I /O Related Instructions
( I /O Mapped I /O Mode )
Instructions
Operation
8 bit address
[ 8 bit address ] A
1F
F /C : 8 bit address 1 R
8 bit data 1 I
4T
3T
3T
2|3|10
A [ 8 bit address ]
OUT 1 F
F /C : 8 bit address 1 R
8 bit data 1 O
4T
3T
3T
2|3|10
M /C
T States
{
{
B|M |T
CommentsRegisters used
Additional Instructions
Instructions
DI
Operation
Disable Interrupts
M /C
T States
B|M |T
F /C : { DI 1 F
4T
1|1| 4
CommentsRegisters used
DI RST 7.5, 6.5,5.5, INTR are Disabled
EI
Enable Interrupts
F /C : { EI 1 F
4T
1|1| 4
F /C : { DAA 1 F
DAA
2 BCD Digit
4T
1|1| 4
Instructions
Set
Interrupt
Operation
B|M |T
SOD
SDE
Mask
SDE Serial Data Enable
R 7.5
MSE
M 7.5
M 6.5
M 5.5
SOD=0
SOD=1
SDE =0
SDE =1
R 7.5=0
R 7.5=1
MSE=0
MSE=1
M 7.5=0
M 7.5=1
M 6.5=0
M 6.5=1
1|1| 4
M 5.5=0
M 5.5=1
SID
I 7.5
I 6.5
I 5.5
IE
SID=0
SID=1
I 7.5=0
I 7.5 RST 7.5 Interrupt Pending Status
I 7.5=1
I 6.5=0
RIM
Read
Interrupt
I 6.5=1
I 5.5=0
I 5.5 RST 5.5 Interrupt Pending Status
Mask
I 5.5=1
IE=0
IE=1
M 7.5=0
M 7.5=1
M 6.5=0
M 6.5=1
M 5.5=0
M 5.5=1
M 7.5
M 6.5
M 5.5
1|1| 4
Operation
M /C
T States
CommentsRegisters used
B|M |T
( n 8 )10=
16 bit address=00 H
PC H ( ( SP1 ) )
RST n
Instruction
RST 0
0000 H
C 7H
RST 1
0008 H
CF H
RST 2
0010 H
D7 H
is stored
RST 3
0018 H
DF H
RST 4
0020 H
E 7H
Latest SP=SP2
RST 5
0028 H
EF H
RST 6
0030 H
F 7H
RST 7
0038 H
FF H
PC L ( ( SP2 ) )
Similar CALL
( )
Address Opcode
RST 1 S
F /C : Higher Byte 1 W
Lower Byte 1 W
i. e . PC Top of the
6 T ( S)
3T
3T
1|3|12
Externally
INTR=1 ( Short Duration Pulse ) ( P)
2.
Acknowlegment
INTA=0
(Short Duration Pulse)( P)
3.
INTA=0
8 bit Buffer is Enabled
4.
5.
Addressing Modes
Addressing Mode
Operand
Operations
Examples
A + R R , R P + RP R P
ADD B , DAD B
RP
RR
MOV C , A
Direct
Memory Address
( H ) R
LDA H , LDA H
Register Indirect
RP
(( R P ) ) R
8 bit data
16 bit data
Register
Immediate
Implied
( Implicit )
Unique Operand
Delay Programs
Delay
Program
T D =T O + ( Count T L ) Correction
Simple
Delay
T D Total Delay
Program
T D =T O + {Count 2 [ ( Count 1 T L1 ) +T L 2 ] }
Correction
Nested Loop
Delay
Program
T D Total Delay
T O Delay Outside the Loop
T L1 Delay Inside the Loop 1( Inner Loop)
T L2 Delay Inside the Loop 2(Outer Loop)
Count 1 Count of Loop 1( Inner Loop)