Professional Documents
Culture Documents
Unit-I (First Half)
Unit-I (First Half)
Address Bus
Unidirectional and carries address from CPU to memory, input and output
devices.
Eg: 16 address lines ( A15, A14, A13, A12,……A2,A1,A0) / 16bit address bus
32 bit address bus(A31,,,, A1,A0)
Addressable memory locations/devices = 2^16 (65536)/1024= 64kb ,
Address lines: 10,14,16,20,24,32,36,40
Data Bus
Bi Directional and carries the data between CPU, memory and input and
output devices.
Eg: 16 data lines (D15, D14, D13, D12,…..D2,D1,D0) / 16 bit data bus
8 data line: 1111 0000
Size of data carried out is determined by data bus.
Size of Processor: 8 bit, 16 bit,32 bit, 64 bit
Control Bus
Carries the control signal between CPU, memory, and input and output
devices.
Eg: RD, WR, DT/R, CS, etc
Evolution of microprocessor
i) 4004 – 4 bit
ii) 8080, 8085 – 8 bit
iii) 8086, 80186, 80286, 80386(4GB), 80486 – 16 bit
Pentium, Pentium Pro, Pentium-II, III, IV-32 bit
iv) Dual core processor – 64 bit, (1 TB), 2.93GHz
Quad Core Processor – 64 bit, (1TB), 3.16GHz
Number System
0000 0000 – 00
0000 0001- 01
0000 0010 - 02
1100 1001 0000 0011 - C9 03; 05h + 05h =10: 0A
1000 0000 - 80
……..
1111 1110 -FE
1111 1111 - FF
Memory
1KB= 1K x B
1024 x 8bits – (2^10 x 8bits) 2kb – 1024*2 x 8bits = 2048=2^11
00 0000 0000 000 H
00 0000 0001 MOV A,B 001 H
00 0000 0010 MOV B,A 002 H
00 0000 0011 003 H
……….. 004H
………..
10 0000 0000 200 H
………..
11 1111 1110 3FE H
11 1111 1111
3FF H
Memory Size: 2Kb, 4Kb, 16Kb, 64Kb, 1Mb, 16Mb, 4Gb, 64Gb, 1 Tb
i) 8 bit microprocessor
ii) data bus – 8 lines, Address bus-16 lines (A15-A0),
2^16=65536/1024=64KB
iii) Interrupt sources – 5 hardware , 8- software
iv) Serial input/output – 1
v) Clock frequency -3MHz
vi) Operating voltage – 5v.
Pin Diagram of 8085
Status signals
S1 S0 Status
0 1 write
1 0 read
1 1 Opcode fetch
0 0 HALT
Example: IO/M- 1, S1-1, S0-0 - read- I/O
IO/M-0, S1-0, SO-1- write - memory
HOLD and HLDA
From Second Clock cycle onwards till the execution of current instruction:
1) ALU
As the name suggests, it performs arithmetic and logical operations like Addition,
Subtraction, AND, OR, etc. on 8-bit data.
2) Registers
Accumulator:
These registers can work in pair to hold 16-bit data and their pairing combination is like
B-C (B), D-E(D) & H-L(HL).
Program counter
Stack pointer
Temporary register
It is an 8-bit register, which holds the temporary data of arithmetic and logical
operations.
Flag register
It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1
depending upon the result stored in the accumulator.
D7 D6 D5 D4 D3 D2 D1 D0
S Z - AC - P - CY
Sign (S)
Zero (Z)
Auxiliary Carry (AC)
Parity (P)
Carry (C)
Interrupt control
As the name suggests it controls the interrupts during a process. When a
microprocessor is executing a main program and whenever an interrupt occurs, the
microprocessor shifts the control from the main program to process the incoming
request. After the request is completed, the control goes back to the main program.
There are 5 interrupt signals in 8085 microprocessor: INTR, RST 7.5, RST 6.5, RST 5.5,
TRAP.
It controls the serial data communication by using these two instructions: SID
(Serial input data) and SOD (Serial output data).
It is for the generation of timing signals and the signals to control. All the
operations and functions both interior and exterior of a microprocessor are controlled
by this unit.
Example for flag register
1) FE h+ 35 h = __133_____
2) 53 h – 45h =_____0E___
8421
1) 1111 1110
0011 0101
Mnemonics operands
MVI B, 67H
The operand is present in the memory but memory location is not directly
specified in the instruction. HL – pointer register
MOV A, M
Implicit addressing mode
Notations
MOV B, C ; (C ) B; x=y
MOV H, L ; (L ) H
MOV A, E ;
MVI B, 28h;
MVI D, 2A;
MVI M, 22h
4) LXI Rp, 16 bit data ; (Load 16 bit register with 16 bit data), SP, PC
LXI H, 3355h ; 33 H, 55 L
If BC register pair holds (points) the memory address – 4500, then content
in the above address will be copied to A.
4500 29
After execution A has 29.
LXI B, 4500H
LDAX B
LDA 4500H
STAX D : DE register pair holds memory address, content in the Accumulator will
be copied to memory address pointed by DE register pair.
LXI D, 5300H
STAX D
After execution
5300 87
11) XCHG (Exchange the contents of HL register pair with DE register pair)
HL – 3355 & DE – 7788
After execution of XCHG, HL has – 7788 and DE has 3355.
Method 1
LDA 2300; (2300)placed in A
MOV B, A
LDA 2301; (2301) is placed in A
MOV C, A
Method 2
LHLD 2300; 2300 to L register, 2301 H
MOV B,L ; contents in L is copied to B.
MOV C, H; contents in H is copied to C.
13) SBI 8bit data (subtract immediate value from Accumulator with borrow)
x=x+1; x++
FF +1= 1 00H-> B
INX H ; (HL) + 1 HL
INX B, INX D
DCX D; (DE) - 1 DE
FF+1= 1 00; 00H-1=
MOV A, D
STA 6000
2) MVI C, 88
MOV A, C;
STA 7000
3) ADD D ( A) + (D) A
STA 4500.
1) Place/Load the value 88h in A reg. and 99h in E reg., add these two
registers and store the sum in memory address of 8900.
2) Write a program to subtract the contents of H reg. from A reg. and store
the remainder in memory address of 9000 H.
3) Add the contents present in the memory locations 4000h and 4001 and
store the sum in 4002.
MOV A, C ;
STA 7000.
MOV A, D
STA 8001
Method2:
1) ADD E
STA 2000.
2) MVI A,88H
MVI E, 99H
ADD E
STA 8900h
3) SUB H
STA 9000H
LDA 4000h
MOV B, A
LDA 4001h
STA 4002
Write a program to subtract the contents of 8005 from contents of 8000. Store
the remainder in 9000.
LOGICAL INSTRUCTIONS
CPI A5;
ANI 25;
12) XRI 8bit data (Logical XOR immediate value with accumulator)
CY D7 D6 D5 D4 D3 D2 D1 D0
D7 D6 D5 D4 D3 D2 D1 D0 D7
D7 D6 D5 D4 D3 D2 D1 D0 CY
CY D7 D6 D5 D4 D3 D2 D1 D0
DO D0 D7 D6 D5 D4 D3 D2 D1
CY D7 D6 D5 D4 D3 D2 D1 D0
DO CY D7 D6 D5 D4 D3 D2 D1
0100 0101
1000 1010
0001 0101
0010 1010
0101 0100
1) MVI A, 88h
MVI E, 99h
ADD E
STA 8900h
2) SUB H
STA 9000h
3) LDA 4000h
MOV C, A
LDA 4001h
ADD C
STA 4002h
Load Accumulator with 45h and perform 2’s complement for the contents of
accumulator.
MVI A, 45h
CMA
Branching Instructions
Branching instructions are used to change the sequence of program
execution, ie, moves from one memory address to another memory address.
JMP 2300h
LDA 4000h
MOV C, A
LDA 4001h
JMP 5600h
ADD C
5600: STA 4002h
2) JC 16bit address (Jump if carry flag is set/ jump on carry)
JC 1200
LDA 4000h
MOV C, A
LDA 4001h
ADD C
JC 5600h (loop1)
STA 4002h
-------
-------
Loop1(5600): STA 7600
JP 2301h
JM 4503h
JNZ 3001h
26) RST 0, RST 1, RST 2, RST 3, RST 4, RST 5, RST 6, RST 7 (restart)
MVI A, 55h
CMA
2) HLT (Halt)
3) DI (Disable Interrupt)
4) EI (Enable Interrupt)
PUSH D 2302 D
2303 C
SP-1
2304 B
SP-1
2305
(Top of stack) SP
After execution of PUSH, SP decremented by 2.
2) POP Rp (Pop the contents of memory locations of stack onto register pair)
POP D, POP B
4502 22E
(Top of stack) SP
4505 0AB
IN 28H ( (28) A)
MVI A, 77H
IN 67H
MOV C, A
STA 8300H
1) Write a program to add 2 8bit numbers present in the memory address of 2002
and 2003. Store the sum in the memory address of 4000 if carry is not set else
store it in 4500.
In Two byte instructions, first byte represents the opcode and second refers
8bit operand/8 bit address.
In three byte instructions, first byte represents the opcode, and second and
third bytes represent either 16bit data or 16 bit address.
Hardware Interrupts:
When microprocessors receive interrupt signals through pins (hardware) of
microprocessor, they are known as Hardware Interrupts. There are 5
Hardware Interrupts in 8085 microprocessor. They are – INTR, RST 7.5, RST
6.5, RST 5.5, TRAP
Software Interrupts
Software Interrupts are those which are inserted in between the program
which means these are mnemonics of microprocessor. There are 8 software
interrupts in 8085 microprocessor. They are – RST 0, RST 1, RST 2, RST 3, RST
4, RST 5, RST 6, RST 7.
Vectored Interrupts
Vectored Interrupts are those which have fixed vector address (starting
address of sub-routine) and after executing these, program control is transferred
to that address. Vector Addresses are calculated by the formula 8 * TYPE
Hardware Interrupts vector addresses are
RST 0 0000 H
RST 1 0008 H
RST 2 0010 H
RST 3 0018 H
RST 4 0020 H
RST 5 0028 H
RST 6 0030 H
RST 7 0038 H
Maskable interrupt:
EI
SIM
D7 D6 D5 D4 D3 D2 D1 D0
M M M
0000 1011
D7 D6 D5 D4 D3 D2 D1 D0
M0 M0 M1
1) Write a program to add 2 8bit numbers present in the memory address of 2002
and 2003. Store the sum in the memory address of 4000 if carry is not set else
store it in 4500.
LDA 2002H
MOV B, A
LDA 2003
ADD B
JNC loop1
STA 4500
JMP loop2
Loop2: HLT
***************
JC loop1
STA 4000H
JMP loop2
Loop1:STA 4500H
Loop2: HLT
Write a program to add two 8 bit numbers present in the memory address of
2000 and 2001. Store the sum and carry in the memory address of 3000 and 3001
respectively.
FE
FF
1111 1110
1111 1111
1 1111 1101 1 FD
MVI D, 00h
LDA 6000h
MOV B, A
LDA 6001h
ADD B
JNC loop1
INR D
MOV A, D
STA 7001h
0101 0101
0101 0101
A A 1010
MVI D, 00
LDA 2000
MOV B, A
LDA 2001
ADD B
JNC loop1
INR D
MOV A, D
STA 3001
Write a program to subtract the data present in memory address of 5000h from
the data present in memory address of 5001h. Store the remainder in 6000h and
borrow in 6001h.
MVI D, 00
LDA 5000h
MOV B, A
LDA 5001
SUB B
JNC loop1
INR D
MOV A, D
STA 6001