MPMC Manual R20
MPMC Manual R20
(AFFILIATED TO JNTUK, KAKINADA) (RECOGNISED BY ALL INDIA COUNCIL FOR TECH. EDN., NEW DELHI)
ACCREDITED BY NBA & NAAC ‘A+’ Grade
Recognized as a Scientific and Industrial Research Organization
CHINNA AMIRAM. (P.O): BHIMAVARAM: W.G.DT., A.P., INDIA: PIN: 534204
Prepared By
Signature:
Name: N.Kishore Chandra Dev
Microprocessors and Microcontrollers Lab Manual
Syllabus
SYLLABUS
Experiments Based On 8085:
a) Assume that a byte of data is stored in memory location ‘X’. Write an ALP that tests
bit5 of this data. Write ‘FF’ in the location ‘X+1’ if bit 5 is ‘1’ or Write ‘00’ if bit 5 is ‘0’.
1 b) For data value in the location ‘X’ compute the number of logic 1’s and store the result in
the location ‘Y+1’.
Write an ALP to transfer a block of data from one memory location to another memory
2
location
Two 16-bit numbers are stored at memory locations ‘X’ and ‘X+2’.Write an ALP to add
3 these numbers without using DAD instruction and store the result from location Y onwards
Two 8-bit numbers 34H and 43H are stored in locations ‘X’ and ‘X+1’ to compute the
4 product of these two numbers using the repetitive addition method.
The number of the bytes of a block of data is in location ‘X’ and data starts from location
5 ‘X+1’onwards. By defining a stack pointer, write an ALP to arrange this data sequence
in reverse order. Keep the reverse sequence from ‘Y’ onwards
SRKREC, ECE Department 1
Microprocessors and Microcontrollers Lab Manual
Reference Books:
Microprocessors: The 8086/8088, 80186/80286, 80386/80486 and the Pentium Family.
1.
Nilesh B. Bahadure, Phi Learning Pvt. Ltd., 2010
The 8051 Microcontroller and Embedded Systems using assembly and C-Muhammad Ali
2.
Mazidi and Janice Gillespie Mazidi and Rollin D.Mc Kinlay; PHI, 2013/Pearson ,2013
3. Lab Manual
e-Resources:
1. www.sim8085.com
Additional Experiments:
CHAPTER–I
Data Transfer Group: The data transfer instructions move data between registers or
between memory and registers.
MOV Move
MVI Move Immediate
LDA Load Accumulator Directly from Memory
STA Store Accumulator Directly in Memory
LHLD Load H & L Registers Directly from Memory
SHLD Store H & L Registers Directly in Memory
An 'X' in the name of a data transfer instruction implies that it
deals with a register pair (16-bits);
LXI Load Register Pair with Immediate data
LDAX Load Accumulator from Address in Register Pair
STAX Store Accumulator in Address in Register Pair
XCHG Exchange HL Register Pair contents with DERegister Pair
Logical Group: This group performs logical (Boolean) operations on data in registers
and memory and on condition flags. The logical AND, OR, and Exclusive OR
instructions enable you to set specific bits in the accumulator ON or OFF.
ANA Logical AND with Accumulator
ANI Logical AND with Accumulator Using Immediate Data
ORA Logical OR with Accumulator
OR Logical OR with Using Immediate Data
XRA Exclusive Logical OR with Accumulator
XRI Exclusive OR Using Immediate Data
CMP Compare
CPI Compare Using Immediate Data
Rotate instructions shift the contents of the accumulator one-bit position
Branch Group: The branching instructions alter normal sequential program flow,
either unconditionally or conditionally. The unconditional branching instructions
are as follows:
JMP Jump
CALL Call
RET Return
Conditional branching instructions examine the status of one of four condition
flags to determine whether the specified branch is to be executed. The conditions
that may be specified are as follows:
NZ Not Zero (Z = 0) Z Zero (Z = 1)
NC No Carry (C = 0) C Carry (C = 1)
PO Parity Odd (P = 0)
PE Parity Even (P = 1)
P Plus (S = 0)
M Minus (S = 1)
Thus, the conditional branching instructions are specified as follows:
Stack I/O, and Machine Control Instructions: The following instructions affect the
Stack and/or Stack Pointer:
PUSH Push Two bytes of Data onto the Stack
POP Pop Two Bytes of Data off the Stack
XTHL Exchange Top of Stack with H & L
SPHL Move content of H & L to Stack Pointer
I/0 instructions are as follows:
IN Initiate Input Operation
OUT Initiate Output
Operation Machine Control
instructions are as follows:
EI Enable Interrupt System
DI Disable Interrupt System
HLT Halt
NOP No Operation
These instructions are used to transfer the data from the source operand to the
destination operand. Following is the list of instructions under this group −
➔ MOV − Used to copy the byte or word from the provided source to the
provided destination.
➔ PUSH − Used to put a word at the top of the stack.
➔ POP − Used to get a word from the top of the stack to the provided location.
➔ PUSHA − Used to put all the registers into the stack.
➔ POPA − Used to get words from the stack to all registers.
➔ XCHG − Used to exchange the data from two locations.
➔ XLAT − Used to translate a byte in AL using a table in the memory.
➔ IN − Used to read a byte or word from the provided port to the accumulator.
SRKREC, ECE Department 7
Microprocessors and Microcontrollers Lab Manual
➔ OUT − Used to send out a byte or word from the accumulator to the provided
port.
➔ LEA − Used to load the address of the operand into the provided register.
➔ LDS − Used to load DS register and other provided register from the memory
➔ LES − Used to load ES register and other provided register from the memory.
➔ LAHF − Used to load AH with the low byte of the flag register.
➔ SAHF − Used to store AH register to low byte of the flag register.
➔ PUSHF − Used to copy the flag register at the top of the stack.
➔ POPF − Used to copy a word at the top of the stack to the flag register.
Arithmetic Instructions
➔ DIV − Used to divide the unsigned word by byte or unsigned double word by
word.
➔ IDIV − Used to divide the signed word by byte or signed double word by
word.
➔ AAD − Used to adjust ASCII codes after division.
➔ CBW − Used to fill the upper byte of the word with the copies of sign bit of
the lower byte.
➔ CWD − Used to fill the upper word of the double word with the sign bit of the
lower word.
These instructions are used to perform operations where data bits are involved, i.e.
operations like logical, shift, etc.
➔ SHL/SAL − Used to shift bits of a byte/word towards left and put zero(S) in
SRKREC, ECE Department 9
Microprocessors and Microcontrollers Lab Manual
LSBs.
➔ SHR − Used to shift bits of a byte/word towards the right and put zero(S) in
MSBs.
➔ SAR − Used to shift bits of a byte/word towards the right and copy the old
MSB into the new MSB.
➔ ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and
to Carry Flag [CF].
➔ ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to MSB
and to Carry Flag [CF].
➔ RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to CF and
CF to MSB.
➔ RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF
to LSB.
String Instructions
into AX.
➔ CALL − Used to call a procedure and save their return address to the stack.
➔ RET − Used to return from the procedure to the main program.
➔ JMP − Used to jump to the provided address to proceed to the next
instruction.
setting/resetting the flag values. Following are the instructions under this
group −
These instructions are used to execute the given instructions for a number of
times. Following is the list of instructions under this group −
Interrupt Instructions
These instructions are used to call the interrupt during program execution.
➔ INT − Used to interrupt the program during execution and calling service
specified.
➔ INTO − Used to interrupt the program during execution if OF = 1
➔ IRET − Used to return from interrupt service to the main program
Arithmetic Instructions
Using Arithmetic Instructions, you can perform addition, subtraction,
multiplication, and division. The arithmetic instructions include increment by one,
decrement by one, and a special instruction called Decimal Adjust Accumulator.
Microcontroller Instruction Set is:
➔ ADD
➔ ADDC
➔ SUBB
➔ INC
➔ DEC
➔ MUL
➔ DIV
➔ DA A
The operations performed by the arithmetic instructions affect flags like carry,
overflow, zero, etc. in the PSW Register.
Logical Instructions
Logical Instructions are performed on Bytes of data on a bit-by-bit basis.
Mnemonics associated with Logical Instructions are as follows:
➔ ANL
➔ ORL
➔ XRL
➔ CLR
➔ CPL
➔ RL
➔ RLC
➔ RR
➔ RRC
➔ SWAP
➔ JBC
➔ ANL
➔ ORL
➔ CPL
CHAPTER2
1.1 Introduction: This manual provides all the necessary information to perform
simple software and hardware interface experiments based on INTEL 8085
Microprocessors by undergraduate engineering students.
1.2 General: This lab is mainly equipped with ALS-SDA-85M and VMC-85/9
single board Microprocessor Training Kits, which are provided with 8085-A as
CPU. The clock frequency for these systems is 3.07MHZ and is generated from a
crystal of 6.14MHZ.8085 has got 8 data lines & 16 address lines. The total memory
can be expanded up to 64K bytes.
1.3 User’s RAM: The user’s RAM of 2K bytes starts from C000 H for ALS and
2000 H for VMC kits.
1.4 Keyboard Description: The function of the keys in the keyboard which are
useful to perform experiments are explained below.
Note: 1. For a more detailed explanation students are advised to refer to the user's
manual.
2. The Keys specified in parenthesis are meant for VMC-85 Kit.
Program execution
9. Press the Reset button
10. Press the GO button Enter Starting address of the program (COOO) and then
press the EXEC button. It will show the E symbol on the screen.
Procedure:- (a)
C007 DCR B 05
C00B JC BACK DA 12 C0
C00E INX H 23
C011 HLT 76
C015 HLT 76
C040 47 INPUT
C041 00 OUTPUT
Procedure:b)
C00C INR D 14
C015 HLT 76
C040 47 INPUT
C061 04 OUTPUT
2.a) An array of data is stored from location X onwards. The first byte specifies the number of
data bytes in that array. The actual data starts from the next location. Write an ALP to
transfer the above data to another memory location.
Procedure:
a)
C003 MOV D, M 56
C004 INX H 23
C009 STAX B 02
C00A INX H 23
C00B INX B 03
C00C DCR D 15
C010 HLT 76
C040 07 INPUT
C041 01 INPUT
C042 02 INPUT
C043 03 INPUT
C044 04 INPUT
C045 05 INPUT
C046 06 INPUT
C047 07 INPUT
OUTPUT
C061 01 OUTPUT
C062 02 OUTPUT
SRKREC, ECE Department 22
Microprocessors and Microcontrollers Lab Manual
C063 03 OUTPUT
C064 04 OUTPUT
C065 05 OUTPUT
C066 06 OUTPUT
C067 07 OUTPUT
3.a) Two 16-bit numbers are stored at memory locations ‘X’ and ‘X+1’.Write an ALP to add
these numbers without using DAD instruction and store the result from location Y onwards
Procedure:
C005 MOV A, M 7E
C006 INX H 23
C007 INX H 23
C008 ADD M 86
C009 JNC * D2 0E C0
C011 DCX H 2B
C012 MOV A, M 7E
C013 ADD D 82
C016 INX H 23
C017 INX H 23
C018 ADD M 86
C019 JNC** D2 1E C0
C021 MOV A, D 7A
C025 HLT 76
C040 34 INPUT
C041 12 INPUT
C042 65 INPUT
C043 F7 INPUT
C060 99 OUTPUT
C061 09 OUTPUT
C062 01 OUTPUT
4) Two 8 bit numbers 34 H and 43H are stored in locations ‘X’ and ‘X+1’ compute the product
of these two numbers using
a) Repetitive addition method b) Shift and add method
Procedur
a)
C008 INX H 23
C00D INR C 0C
C019 HLT 76
C040 34 INPUT
C041 43
C050 9C OUTPUT
C051 0D
b)
C00F RAL 17
C013 DAD D 19
C01B HLT 76
C040 34 INPUT
C041 43 INPUT
C060 9C OUTPUT
C061 0D OUTPUT
5) The number of bytes of a block of data is in location ‘X’ and data starts from location
‘X+1’ onwards defining stack pointers. Write an ALP to arrange this sequence of data in
reverse order. Keep the reverse sequence from ‘Y’ onwards.
Procedure
C00B DCR B 05
C014 INX H 23
C015 DCR C 0D
C019 HLT 76
C050 04
C051 11 INPUT
C052 22
C053 33
C054 44
C060 44
OUTPUT
C061 33
C062 22
C063 11
Z space starting address of the program, ending address of program and press enter
It shows the loaded program in the assembler. Keep on pressing enter it shows
the step by step of loaded program.
FOR EXECUTION:
Go Space Starting Adress Of the Program And Then Press Enter
GO 5000 ENTER
It will show Executing….
To stop execution press INT Button on the kit.
6) Write an 8086 ALP to add two-32 bit numbers stored in the memory location 6000H and
6004H. Store the result at location 6008H.
Input: Output:
Procedure:
MOV SI,6000 H
MOV AX,[SI]
INC SI
INC SI
MOV BX,[SI]
INC SI
INC SI
MOV CX,[SI]
INC SI
INC SI
MOV DX,[SI]
ADD AX, CX
INC SI
INC SI
MOV [SI], AX
ADC BX, DX
INC SI
INC SI
MOV [SI], BX
MOV CL,00 H
ADC CL, CL
INC SI
INC SI
MOV [SI], CL
HLT
Write an 8086 ALP to subtraction of two-32 bit numbers stored in the memory location 6000H
and 6004H. Store the result at location 6008H.
Input: Output:
Procedure:
MOV SI,6000 H
MOV AX,[SI]
INC SI
INC SI
MOV BX,[SI]
INC SI
INC SI
MOV CX,[SI]
INC SI
INC SI
MOV DX,[SI]
SUB AX, CX
SBB BX, DX
MOV CL,00
JNC STORE
NOT AX
NOT BX
ADD AX,0001 H
ADC BX,0000 H
MOV CL,01 H
STORE: INC SI
INC SI
MOV [SI], AX
INC SI
INC SI
MOV [SI], BX
INC SI
INC SI
MOV [SI], CL
HLT
7) Write an 8086 ALP to multiply two 16-bit numbers stored in the memory location 9000H and
9002H. Store the result at location 9004H.
Input: Output:
Procedure:
MOV SI,9000 H
MOV AX,[SI]
INC SI
INC SI
MOV BX,[SI]
MUL BX
INC SI
INC SI
MOV [SI], AX
INC SI
INC SI
MOV [SI], DX
HLT
Write an 8086 ALP to divide a 32-bit dividend with 16-bit divisor stored in the memory location
6000H and 6004H respectively. Store the quotient at location 6006H and the remainder at
location 6008H.
Input: Output:
Procedure:
MOV SI,6000 H
MOV AX,[SI]
INC SI
INC SI
MOV DX,[SI]
INC SI
INC SI
MOV BX,[SI]
DIV BX
INC SI
INC SI
MOV [SI], AX
INC SI
INC SI
MOV [SI], DX
HLT
SRKREC, ECE Department 38
Microprocessors and Microcontrollers Lab Manual
8) Write an 8086 µP ALP to find factorial of a given number (given number < 9) is at ‘X’ and
store the result at X+1 location
Procedure:
MOV SI, 6000H
MOV AX,[SI]
MOV BX, AL
DEC BX
UP: MUL BX
DEC BX
JNZ UP
INC SI
INC SI
MOV [SI], AX
INC SI
INC SI
MOV [SI], DX
HLT
9) Write an 8086 μP ALP to convert 8 bit BCD number into HexaDecimal or HexaDecimal into
BCD
Procedure:
MOV SI, 6000H
CMP AL,00H
JE DOWN 1 ;JE/JZ
DAS
INC BL
CMP AL,00H
JNE UP ;JNE/JNZ
INC SI
HLT
Procedure:
MOV AX,0000 H ;Clear AX Reg. to store output
CMP CL,00 H
JZ DOWN1
DAA
JNC DOWN2
INC AH
DOWN2: DEC CL
JNZ UP
HLT
10) Write an 8086 program to add four digit BCD numbers present in memory location 6000H
and 6002H. Store the result at memory location 6004H.
Input: Output:
6000 H = LSB of first 16-bit BCD number 6004 H = Byte0 of BCD result
6001 H = MSB of first 16-bit BCD number 6005 H = Byte1 of BCD result
6002 H= LSB of second 16-bit BCD number 6006 H = Byte2 of BCD result (Carry)
Procedure:
MOV SI,6000 H
MOV AX,[SI]
INC SI
INC SI
ADD AL,[SI]
DAA
INC SI
INC SI
MOV [SI], AL
DEC SI
MOV AL,[SI]
DEC SI
DEC SI
ADC AL,[SI]
DAA
MOV AH,00 H
ADC AH, AH
MOV SI,6005 H
MOV [SI], AX
HLT
11) Write an 8086 μP Assembly Program to find the largest/smallest element in the given array/
Procedure:
MOV SI, 6000H
MOV CH,00H
INC SI
UP1:UP2: INC SI
CMP AL,[SI]
MOV [SI],AL
HLT
12) Write an 8086 program to sort the given block of the data using the Bubble sorting
technique. Assuming a number of bytes of the block of data stored in location 6000H and actual
data stored on 6001H onwards.
Procedure:
MOV SI,6000H
MOV CL,[SI]
DEC CL
MOV SI,6001H
MOV BL,[SI+1]
CMP AL, BL
JC DOWN
MOV BL,[SI]
XCHG BL,[SI+1]
MOV [SI], BL
DOWN: INC SI
DEC DL
JNZ U1
DEC CL
JNZ U2
HLT
Alternative Program:
Procedure:
MOV SI, 6000H
DEC CL
INC SI
CMP AL, BL
JNC DOWN
MOV [SI], AL
DEC SI
MOV [SI], BL
DOWN: INC SI
DEC DL
JNZ UP1
DEC CL
JNZ UP2
HLT
EXECUTION:
G space Starting address of Program enter Break enter
Eg. G 8000 enter Break Enter
Procedure:
MOV A,@R0
MOV @R1, A
UP: INC R0
MOV A,@R0
INR R1
MOV @R1, A
DJNZ R7, UP
Procedure:
MOV R0,#60H
MOV DPTR,#9000H
MOV A,@R0
MOV R7, A
MOVX @DPTR, A
UP: INC RO
MOV A,@R0
INC DPTR
MOVX @DPTR, A
DJNZ R7, UP
Two bytes are stored at 9000H and 9001H respectively and store the result at 9002H and
9003H
Input
9000H BYTE1
9001H BYTE2
Output
MUL AB -->A*B= B A
MOVX A,@DPTR
MOV B, A
INC DPTR
MOVX A,@DPTR
MUL AB
INC DPTR
MOVX @DPTR, A
INC DPTR
MOV A, B
MOVX @DPTR, A
Two bytes are stored at 9000H and 9001H respectively and store the result at 9002H (Quotient) and
9003H(Remainder)
Input
9000H BYTE1
9001H BYTE2
Output
9002H QUOTIENT
9003H REMAINDER
Procedure:
MOV DPTR,#9000H
MOVX A,@DPTR
MOV B,A
INC DPTR
MOVX A,@DPTR
DIV AB
INC DPTR
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
15) Write an ALP to count the number of logic one’s(1’s) zero’s(0’s) in a given byte at location
60H and store the result in the R5 register(number of 1’s) & R4 register (number of 0’s)
Procedure:
MOV R0, #60H
MOV A, @R0
MOV R7,#08H
UP: RRC A
JNC DOWN1
INC R5
SJMP DOWN 2
DOWN1: INC R4
16) Write an 8051 μC Assembly Program to find the largest element in given array
NE: JC SKIP ;if not equal check for carry, if carry go to skip
17) Write an ALP to add the first ten natural numbers(1+2+3+…+A)and store the result at R5
register.
Procedure:
MOV A,#00H
MOV R0,#00H
UP : INC R0
ADD A, R0
DJNZ R7, UP
MOV R5, A
Additional Experiments:
1) By using 8279 in auto-increment mode, generate a message of 6 characters and make the
display ON and OFF for every 0.5 sec.
Procedure:
97 96 95 94 93 92
dp g f e D c b a
LED Buffers
a b c d e F g dp
Control bytes of LEDs
2)By using the data field of the display unit, Obtain a count of 00 to 59 with a delay of 1
second after every count. Keep the character code from location “X” onwards.
Procedure:
87 86 85 84 83 82
LED Buffer :
. g f e d c b a
Note: Stack has to be at the beginning of the program so that the registers used in the main program
can also be used in subroutines. This can be done by using PUSH & POP instructions with LIFO
logic
Delay Calculation:
Clock Frequency = 3.07 MHz
The total No.of T states = N[6+4+4+10]+10+10+7-10
To get 0.5 sec delay = N[24]+17 = 1535*103 => N = (63958)D = (F9D6)H5.
3) The number of bytes of a block of data is location ‘X’ and data starts from location
‘X+1’onwards. Arrange this block of data in ascending order by using the bubble sorting
technique
Procedure:
C003 MOV C, M 4E
C004 DCR C 0D
C00A INX H 23
C00B CMP M BE
C00C JC AHEAD DA 15 C0
C00F MOV D, A 57
C010 MOV A, M 7E
C011 MOV M, D 72
C012 DCX H 2B
C013 MOV M, A 77
C014 INX H 23
C019 DCR C 0D
C01D HLT 76
C040 08
C041 40
C042 20
C043 30
C044 10
C041 10
C042 20
C043 30
C044 40
4) Using 8279 write an ALP to generate the message of 4 characters. Activate the LEDs
individually and make the display ON & OFF every 0.5 seconds.
Procedure:
C002 OUT D1 D3 D1
C006 OUT D0 D3 D0
C00A OUT D1 D3 D1
C00D OUT D0 D3 D0
C011 OUT D1 D3 D1
C016 OUT D0 D3 D0
C01B OUT D1 D3 D1
C021 OUT D0 D3 D0
C025 MVI A, DF 3E DF
C026 OUT D1 D3 D1
C064 OR A, H 7D
C065 MOV A, L B4
C069 RET C9
f b
g
e c
d .dp
dp g f e D c b a
LED Buffers
LED Buffers.
a b c d e F g dp
Dp g f e : d c b a
A 1 0 0 0 : 1 0 0 0 88
B 1 0 0 0 : 0 0 0 0 80
C 1 1 0 0 : 0 1 1 0 C6
D 1 1 0 0 : 0 0 0 0 C0
MOV SI, 5000 : load the value 5000 into offset SI.
MOV DI, 6000 : load the value 6000 into offset DI.
MOV CL, [SI] : load the data of offset SI into the CL register.
MOV CH, 00 : load value 00 into CH register.
INC SI : increment the value of SI by one.
CLD : clears the directional flag i.e. DF=0.
REP : repeat until value of CX is not equal to zero and decrement
the value of CX by one at each step.
MOVSB : transfer the data from the source memory location to the
destination memory location.
HLT : end.
MOVS/MOVSB/MOVSW
This instruction copies a byte or a word from a location in the data segment [DS:SI] to a location
in the extra segment [ES:DI]. The offset in the data segment for the source is to be stored in the SI
register and the offset for the destination in the extra segment is to be stored in the DI register.
For multiple byte/word movement, the value stored in the CX register by the user functions as a
counter. After each move, SI and DI are automatically adjusted to point to the next source and
destination respectively.
➔ The Direction Flag (DF) value determines whether SI and DI are to be incremented (DF = 0) or
decremented (DF = 1) after each move.
➔ The MOVSB instruction tells the assembler to move data as bytes; the MOVSW implies the string is
to be moved as words.
➔ MOVSB instruction is used to transfer bytes only from the source memory location (MADS) to the
destination memory location (MAES).
➔ CLD instruction is used to clear the directional flag, i.e., DF=0. Now, the value of SI and DI will be
increased.
➔ REP instruction is used to repeat the step until the value of CX is not equal to zero and the value of
CX is decremented by one at every step
Usage
MOVS dest, src (This usage is misleading; movement of data still happens from DS: SI to
ES: DI)
MOVSB
MOVSW
6)Write an ALP to count the Even and Odd numbers from the series of 100 numbers present in
the memory location from 6000:61000H . Store the even count in register BX and the odd count
in register DX.
MOV AX,6000H
MOV DS,AX
MOV SI,0100H
XOR BX,BX
XOR DX,DX
CLD
L1: LODSW
ROR AX, 1
JC ODD
JMP NEXT
NEXT: LOOP L1
HLT
L1: JC L2 ; Is [A]<[R5]? Ye,s jump to L2. If there is a carry go to the next step.
MOV 04,@R0 ;copy [[R0]] to R4. Now the small number is in R4. Since [[R0]]=[R5]
MOV @R0,A ; copy a large number from A to the current memory location pointed by R0.
MOV A,52H ; get the hexadecimal number from memory location 52H
8085 Architecture
Arithmetic and Logic Unit: The ALU performs the actual numerical and logical operations
such as Addition (ADD), Subtraction (SUB), AND, OR etc.
➔ It uses data from memory and from the Accumulator to perform operations.
➔ The results of the arithmetic and logical operations are stored in the accumulator.
Registers: The 8085 includes six registers, one accumulator, and one flag register.
➔ In addition, it has two 16-bit registers: stack pointer and program counter.
➔ The 8085 has six general-purpose registers to store 8-bit data; these are identified as
B, C, D, E, H, and L.
➔ They can be combined as register pairs - BC, DE, and HL to perform some 16- bit
operations.
SRKREC, ECE Department 69
Microprocessors and Microcontrollers Lab Manual
W and Z register : These registers are also used to hold temporary values. It is used by the
control section of the microprocessor to store the data during operations.
Program Counter (PC) This 16-bit register deals with sequencing the execution of
instructions.
➔ This register is a memory pointer. The microprocessor uses this register to sequence the
execution of the instructions.
➔ The function of the program counter is to point to the memory address from which the
next byte is to be fetched.
➔ When a byte is being fetched, the program counter is automatically incremented by one
to point to the next memory location.
Stack Pointer (SP) The stack pointer is also a 16-bit register, used as a memory pointer. It
points to a memory location in R/W memory, called the stack.
➔ The beginning of the stack is defined by loading a 16-bit address in the stack pointer.
Instruction Register & Decoder: It is an 8-bit register that temporarily stores the current
instruction of a program.
➔ Latest instruction was sent here from memory prior to execution.
➔ The decoder then takes instruction and decodes or interprets the instruction. Decoded
instructions are then passed to the next stage.
Timing and control Unit: We use the Timing and Controlling unit in 8085 for the generation of
timing signals and the signals to control.
➔ This circuit basically sends the control signals to the various units of the microprocessor
to execute the instruction.
➔ All the operations and functions of both the interior and exterior of a microprocessor are
controlled by this unit.
Interrupt control: Whenever a microprocessor is executing the main program and if suddenly
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 microprocessors: INTR, TRAP, RST 7.5, RST 6.5,
and RST 5.5.
➔ Priorities of Interrupts: TRAP > RST 7.5 > RST 6.5 > RST 5.5 > INTR
Address bus and data bus: The data bus is bidirectional and carries the data which is to be
stored. The address bus is unidirectional and carries the location where data is to be stored.
Serial Input/output control: It controls the serial data communication by using Serial input
data and Serial output data.
BIU mainly contains the 4 Segment registers, the Instruction Pointer, a prefetch queue and an
Address Generation Circuit.
Segment Registers: A segment register contains the addresses of instructions and data in
memory which are used by the processor to access memory locations. It points to the starting
address of a memory segment currently being used.
There are 4 segment registers in 8086 as given below:
➔ Code Segment Register (CS): The code segment of the memory holds the instruction
codes of a program.
➔ Data Segment Register (DS): The data, variables, and constants given in the program
are held in the data segment of the memory.
➔ Stack Segment Register (SS): The stack segment holds addresses and data of
subroutines. It also holds the contents of registers and memory locations given in
PUSH instruction.
➔ Extra Segment Register (ES): Extra segment holds the destination addresses of some
data of certain string instructions.
Instruction Queue: It is a 6-byte queue (FIFO). Fetching the next instruction (by BIU from CS)
while executing the current instruction is called pipelining. It gets flushed whenever a branch
instruction occurs.
Instruction Pointer (IP): The instruction pointer in the 8086 microprocessor acts as a program
counter. It indicates the address of the next instruction to be executed.
Address Generation Circuit: The BIU has a Physical Address Generation Circuit. It generates
the 20-bit physical address using Segment and Offset addresses using the formula:
EU Contains
➔ General purpose registers,
➔ Stack pointer, Base pointer, and Index registers,
➔ ALU
➔ Flag Registers (FLAGS),
➔ Instruction decoder, and timing and control unit.
8086 has four 16-bit general-purpose registers AX, BX, CX, and DX. Store
intermediate values during execution. Each of these has two 8-bit parts (higher and lower).
Arithmetic Logic Unit (16 -bit): Performs 8 and 16-bit arithmetic and logic operations.
Instruction Register and Instruction Decoder: The EU fetches an opcode from the queue
into the instruction register. The instruction decoder decodes and sends the information to the
control circuit for execution.
Flag/Status register (16 bits): It has 9 flags that help change or recognize the state of the
microprocessor.
6 Status flags: Status flags are updated after every arithmetic and logic operation.
➔ carry flag(CF)
➔ parity flag(PF)
➔ auxiliary carry flag(AF)
➔ zero flag(Z)
➔ sign flag(S)
➔ overflow flag (O)
3 Control flags: These flags can be set or reset using control instructions like CLC, STC, CLD,
STD, CLI, STI, etc. The Control flags are used to control certain operations.
➔ trap flag(TF)
➔ interrupt flag(IF)
➔ direction flag(DF)
Components:
1. BUS
2. Central Processor Unit (CPU)
3. Interrupts
4. Oscillator
5. Memory
6. Input/Output Port
7. Serial Port
8. Timers
BUS Bus is a collection of wires which work as a communication channel or medium for the
transfer of Data. These buses consist of 8, 16, or more wires of the microcontroller.
➔ Thus, these can carry 8 bits, and 16 bits simultaneously. There are two types of buses
that are shown below
◆ Address Bus
◆ Data Bus
Address Bus: Microcontroller 8051 has a 16-bit address bus for transferring the data.
➔ It is used to address memory locations and to transfer the address from the CPU to
the Memory of the microcontroller.
➔ It has four addressing modes that are
➢ Immediate addressing modes.
➢ Bank address (or) Register addressing mode.
➢ Direct Addressing mode.
➢ Register indirect addressing mode.
Data Bus: Microcontroller 8051 has 8 bits of the data bus, which is used to carry data for
particular applications.
Central Processor Unit (CPU)
The CPU is the brain of any processing device of the microcontroller.
➔ The CPU is the primary device in communicating with peripheral devices like Memory,
Input, and Output.
➔ It monitors and controls all operations that are performed on the Microcontroller units.
➔ It reads programs written in ROM memory and executes them and does the expected
task of that application.
➔ CPU consists of ALU and CU.
➔ Arithmetic Logic Unit(ALU) performs the Arithmetical and Logical Operations.
➔ Control Unit (CU)is responsible for the timing of the communication process between
the CPU and its peripherals.
Interrupts
Interrupt is a subroutine call that interrupts the microcontroller's main
operations or work and causes it to execute any other program, which is more
important at the time of operation.
➔ The feature of Interrupt is very useful as it helps in case of emergency operations.
➔ Generally five interrupt sources are there in the 8051 Microcontroller.
Oscillator
Microcontroller requires clock pulses for its operation
➔ For this purpose, microcontroller 8051 has an on-chip oscillator that works as a clock
source for the Central Processing Unit of the microcontroller.
➔ An on-chip crystal oscillator has a crystal frequency of 12 MHz.
➔ The output pulses of the oscillator are stable.
➔ Therefore, it enables synchronized work of all parts of the 8051 Microcontroller.
Program Memory
The instructions of the CPU are stored in the Program Memory.
➔ It is usually implemented as a Read Only Memory or ROM, where the Program
written into it will be retained even when the power is down or the system is reset.
SRKREC, ECE Department 76
Microprocessors and Microcontrollers Lab Manual
Data Memory
Data Memory in a Microcontroller is responsible for storing values of variables,
temporary data, intermediate results , and other data for the proper operation of the
program.
➔ Data Memory is often called RAM (Random Access Memory), which is a type of
volatile memory.
➔ It is generally organized as registers and includes both Special Function Registers
(SFRs) and user accessible memory locations.
➔ 8051 has 128 bytes of data memory or RAM.
Input and Output Ports
➔ There are four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports.
➔ Port 0 occupies a total of 8 pins (pins 32-39) It can be used for input or output. To use
the pins of port 0 as both input and output ports.
➔ Port 0 is also designated as AD0-AD7, allowing it to be used for both address and
data.
➔ Port 1& Port 2 are used as simple I/O with no external memory connection.
➔ When external memory is connected Port 2 must be used along with Port 0 to
provide a 16-bit address for external memory.
➔ Port 3 is used as input or output.