Microprocessor Lab Manual
Students are required to use the simulator to get the
output and print the output for lab file.
Note: DO NOT COPY RESULT OF OTHER STUDENTS. (KEEP
FRIENDSHIP AWAY DURING LEARNING PHASE)
EVERY INDIVIDUAL MUST BE ABLE TO EXECUTE AND FIND OUT
THE OUTPUT ON THEIR OWN.
1. Write an ALP to add two 8 bit numbers.
MVI C 00h
LDA 2300h
MOV B A
LDA 2301h
ADD B
JNC LOOP
INR C
LOOP: STA 2302h
MOV A C
STA 2303h
HLT
2. Write an ALP to subtract two 8 bit numbers.
MVI C 00h
LDA 2300h
MOV B A
LDA 2301h
SUB B
JNC LOOP
INR C
LOOP: STA 2302h
MOV A C
STA 2303h
HLT
3. Write an ALP to multiply two 8 bit numbers
MVI D 00h
MVI A 00h
LXI H 2150h
MOV B M
INX H
MOV C M
LOOP: ADD B
JNC NEXT
INR D
NEXT: DCR C
JNZ LOOP
STA 2152h
MOV A D
STA 2153h
HLT
4. Write an ALP to divide two 8 bit numbers
LXI H 2150h
MOV B M
INX H
MOV A M
ADI 00h
MOV A B ; A gets dividend
MOV B M ; B gets divisor
MVI C 00h
NEXT: CMP B
JC LOOP
SUB B
INR C
JMP NEXT
LOOP: STA 2152h ; store remainder
MOV A C
STA 2153h ; store quotient
HLT
5. Write an ALP to find the largest number in an array.
LXI H 2200h
MOV B M
INX H
MOV A M
DCR B
LOOP: INX H
CMP M
JNC SKIP
MOV A M
SKIP: DCR B
JNZ LOOP
STA 2250h
HLT
6. Write an ALP to find the smallest number in an array.
LXI H 2200h
MOV B M
INX H
MOV A M
DCR B
LOOP: INX H
CMP M
JC SKIP
MOV A M
SKIP: DCR B
JNZ LOOP
STA 2250h
HLT
7. Write an ALP to generate first 10 natural numbers.
MVI B 01h
MVI C 0Ah
LXI H 2200h
LOOP: ADD B
MOV M A
INX H
DCR C
JNZ LOOP
HLT
8. The following block of data is stored in memory location from 2055
to 205A.Transfer the entire block of data to the locations 2080 to
2085 in reverse order.
LXI H 2055h
LXI D 2085h
MVI B 06h
NEXT: MOV A M
STAX D
INX H
DCX D
DCR B
JNZ NEXT
HLT
9. Write an ALP to find larger of two numbers. 1st number in 2401 and
2nd number in 2402 and result in 2403.
LXI H 2401h
MOV A M
INX H
CMP M
JNC LOOP
MOV A M
LOOP: STA 2403h
HLT
10. The following block of data is stored in memory location from
2050 to 2054.Transfer the entire block of data to the locations
2100 to 2104 in normal order.
LXI H 2050h
LXI D 2100h
MVI B 05h
NEXT: MOV A M
STAX D
INX H
INX D
DCR B
JNZ NEXT
HLT
11. Write an ALP to multiply two numbers: example: 06 * 07
MVI A 00h
MVI B 07h
MVI C 06h
LOOP: ADD B
DCR C
JNZ LOOP
STA 2400h
HLT
12. Write an ALP to count the number of 1 in the given string
‘10100110’ and display the result at 2400H.
MVI A A6h
MVI B 00h
MVI C 08h
LOOP1: RAL
JNC LOOP2
INR B
LOOP2: DCR C
JNZ LOOP1
MOV A B
STA 2400h
HLT
13. The following data are stored in memory location starting from
2180 to 2189.Take a test number 48. Find out how many times the
number 48 is repeated. Display the result at 2400.
Data: 12 23 34 45 48 56 48 67 48 89
LXI H 2180h
MVI B 00h
MVI C 0Ah
LOOP1: MOV A M
CPI 48h
JNZ LOOP2
INR B
LOOP2: INX H
DCR C
JNZ LOOP1
MOV A B
STA 2400h
HLT
14. Write an ALP to find whether a number is odd or even.
LDA 2500h
ANI 01h
JZ SKIP
MVI A 0Dh // 0D= odd
JMP LOOP
SKIP: MVI A 0Eh // OE= even
LOOP: STA 2505h
HLT
15. Write an ALP to find the sum of numbers from 1 to 10.
MVI B 01h
MVI C 0Ah
MVI A 00h
LOOP: ADD B
INX H
INR B
DCR C
JNZ LOOP
STA 2055h
HLT
//The result will be 37 which is hexadecimal equivalent of 55.
16. Write an ALP display first 10 odd numbers.
LXI H 2050h
MVI B 01h
MVI C 0Ah
LOOP: MOV M B
INX H
INR B
INR B
DCR C
JNZ LOOP
HLT
17. Write an ALP display first 10 even numbers.
LXI H 2050h
MVI B 00h
MVI C 0Ah
LOOP: MOV M B
INX H
INR B
INR B
DCR C
JNZ LOOP
HLT
18. Write an ALP to find the smallest between two 8 bit numbers.
LDA 2050h
MOV B A
LDA 2051h
CMP B
JC LOOP
MOV A B
LOOP: STA 2055h
HLT
19. Write an ALP to find 1’s complement of a number.
LDA 2050h
CMA
STA 2052h
HLT
20. Write an ALP to find 2’s complement of a number.
LDA 2050h
CMA
ADI 01h
STA 2052h
HLT