8085 Architecture & �Its Assembly language programming
Dr A Sahu
Dept of Computer Science & Engineering
IIT Guwahati
Outline
W
Z
B
C
D
E
H
L
SP
PC
Inc/Dec. ter
Add latch
MUX
Bus 8 Bit
Interrupt Control
Serial I/O Control
IR
I Decode
&
M/C
Encoding
tmp R
ACC
Timing and Control
ALU
Add Buff
Data/Add Buff
Flag
INTR
INTA
RST5.5
ReSeT6.5
RST7.5
TRAP
SID
SOD
8085 Microprocessor Architecture
8085
MPU
A15
A0
D0
D7
Address Bus (16bit)
Memory
I/P
Data Bus (8bit)
O/P
Control Bus (8bit)
Assumption
Simple Assembly Program
MVI A, 24H // load Reg ACC with 24H
MVI B , 56H // load Reg B with 56H
ADD B // ACC= ACC+B
OUT 01H // Display ACC contents on port 01H
HALT // End the program
Result: 7A (All are in Hex)
DAA operation for Decimal Adjust A+6=10H
Flowchart to multiply two number
Start
LDA 2000 // Load multiplicant to accumulator
MOV B,A // Move multiplicant from A(acc) to B register
LDA 2001 // Load multiplier to accumulator
MOV C,A // Move multiplier from A to C
MOV C,A // Move multiplier from A to C
MVI A,00 // Load immediate value 00 to ACC
ADD B // Add B(multiplier) with A
DCR C // Decrement C, it act as a counter
JNZ L // Jump to L if C!=0
STA 2010 // Store result in to memory
HLT // End
Code to multiply two number
LDA 2000 // Load multiplicant to accumulator
MOV B,A // Move multiplicant from A(acc) to B register
LDA 2001 // Load multiplier to accumulator
MOV C,A // Move multiplier from A to C
MVI A,00 // Load immediate value 00 to a
L: ADD B // Add B(multiplier) with A
DCR C // Decrement C, it act as a counter
JNZ L // Jump to L if C reaches 0
STA 2010 // Store result in to memory
HLT // End
Delay of Instructions
MVI C, FFH 7 T-State
LOOP: DCR C 4 T-State
JNZ LOOP 7/10 T-State
ADD R 4 T-State
ADD M 7 T-State
CALL addr 18 T-State
F
R
F
F
R
R
F
F
R
S
R
R
W
W
Time Delay Loop
MVI C, FFH 7 T-State
LOOP: DCR C 4 T-State
JNZ LOOP 7/10 T-State
TL= T x Loop T-States x N10
where T=System clock period
N10= Equiv. decimal value of count loaded to C
TL= 0.5x10-6 x (14 x 255)=1.8ms (ignore 10 T-State)
F
R
F
F
R
R
Time Delay: Nested Loop
MVI C, FFH 7 T-State
MVI D, FFH 7 T-State
LOOP1: DCR C 4 T-State
LOOP2: DCR D 4 T-State
JNZ LOOP2 7/10 T-State
JNZ LOOP1 7/10 T-State
TNL= N110 x T x ( L1_TStates+ L2_TStates x N210 )
F
R
F
F
R
R
F
R
F
R
R
F
Traffic Light Control: Counter & Delay
LOOP: MVI A 01H
OUT 01H
LD B DELAY_RED
CALL DELAY
Load DelayRed
Time Delay
Turn Signal to Red
Load DelayYellow
Time Delay
Turn Signal to Yellow
Load DelayGreen
Time Delay
Turn Signal to Green
MVI A 02H
OUT 01H
LD B DELAY_YELLOW
CALL DELAY
MVI A 03H
OUT 01H
LD B DELAY_GREEN
CALL DELAY
JMP LOOP
Stack Pointer (SP) & Stack Memory
bottom of the stack (SP)
and the stack grows up into �reducing address range.
Memory
Bottom
of the
Stack
The Stack
grows
backwards
into memory
Stack Memory
LXI SP, FFFFH
Saving Information on the Stack
B
C
SP
FFFF
FFFE
FFFD
FFFC
FFFB
F3
12
F3
12
Stack/LIFO use in CALL/RET
Before any routine CALL do this
PUSH B
PUSH D
PUSH PSW
After RETURN from call do this
POP PSW
POP D
POP B
Subroutines
CALL/RET Instruction
17
PC
SP
FFFF
FFFE
FFFD
FFFC
FFFB
2 0 0 3
03
20
2000 CALL 5000
2003
Call by References
18
Stack/LIFO use in CALL/RET
Before any routine CALL do this
PUSH B
PUSH D
PUSH PSW
After RETURN from call do this
POP PWD
POP D
POP B
Factorial of a number
LXI SP, 27FFH // Initialize stack pointer
LDA 2200H // Get the number
CPI 02H // Check if number is greater than 1
JC LAST
MVI D, 00H // Load number as a result
MOV E, A
DCR A
MOV C,A // Load counter one less than number
CALL FACTO // Call subroutine FACTO
XCHG // Get the result in HL // HL with DE
SHLD 2201H // Store result // store HL at 0(16bit)
JMP END
LAST: LXI H, 000lH // Store result = 01
END: SHLD 2201H
HLT
Sub Routine for FACTORIAL
FACTO:LXI H, 0000H
MOV B, C // Load counter
BACK: DAD D // double add ; HL=HL+DE
DCR B
JNZ BACK //Multiply by successive addition
XCHG // Store result in DE // HL with DE
DCR C // Decrement counter
CNZ FACTO // Call subroutine FACTO
RET // Return to main program
Assignment I
Introduction to �8086 & i386 processor
8086 Architecture
AH
AL
BH
BL
CH
CL
DH
DL
SI (Source Idx )
DI (Dest. Idx)
BP (Base Ptr )
SP (Stack Ptr)
Z (Flag Reg)
CS (Code Seg Reg)
DS (Data Seg Reg )
ES (Extra Seg Reg )
SS (Stack Seg Reg)
IP (Intr Ptr)
Operand
InDirect
Temp A
Temp B
Temp C
Q6
Q5
Q4
Q3
Q2
Q1
Sequencer
Bus Interface Unit
Execution
Unit
SUM
C BUS
A BUS
ALU
8086 Registers
AH
AL
BH
BL
CH
CL
DH
DL
SI (Source Idx )
DI (Dest. Idx)
BP (Base Ptr )
SP (Stack Ptr)
CS (Code Seg Reg)
DS (Data Seg Reg )
ES (Extra Seg Reg )
SS (Stack Seg Reg)
IP (Intr Ptr)
Z (Flag Reg)
8086 Architecture
Next Class Agenda
Thanks