Microprocessor Programming Lab Manual
Microprocessor Programming Lab Manual
ALGORITHM:
PROGRAM:
OBSERVATION:
Input: 80 (4150)
80 (4251)
Output: 00 (4152)
01 (4153)
RESULT: Thus the program to add two 8-bit numbers was executed.
Prg #2, SUBTRACTION OF TWO 8 BIT NUMBERS
ALGORITHM:
PROGRAM:
MVI C, 00 Initialize C to 00
SUB B
Input: 06 (4150)
02 (4251)
Output: 04 (4152)
01 (4153)
RESULT: Thus the program to subtract two 8-bit numbers was executed.
Prg #3, MULTIPLICATION OF TWO 8 BIT NUMBERS
ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
7) Check whether repeated addition is over and store the value of product and carry
in memory location.
PROGRAM:
MVI D, 00 Initialize register D to 00
LXI H, 4150
INX H
MOV A, D
Input: FF (4150)
FF (4151)
Output: 01 (4152)
FE (4153)
RESULT: Thus the program to multiply two 8-bit numbers was executed.
Prg #4, DIVISION OF TWO 8 BIT NUMBERS
ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
7) Check whether repeated subtraction is over and store the value of product and carry in memory location.
PROGRAM:
LXI H, 4150
INX H
MOV A, C
OBSERVATION:
Input: FF (4150)
FF (4251)
RESULT: Thus the program to divide two 8-bit numbers was executed.
Prg #5, LARGEST NUMBER IN AN ARRAY OF DATA
AIM: To find the largest number in an array of data using 8085 instruction set.
ALGORITHM:
PROGRAM:
INX H
LOOP: INX H
JNC AHEAD
AHEAD: DCR B
JNZ LOOP Repeat comparisons till count = 0
HLT
OBSERVATION:
0A (4201)
F1 (4202)
1F (4203)
26 (4204)
FE (4205)
Output: FE (4300)
RESULT: Thus the program to find the largest number in an array of data was executed
Prg #6, SMALLEST NUMBER IN AN ARRAY OF DATA
AIM: To find the smallest number in an array of data using 8085 instruction set.
ALGORITHM:
PROGRAM:
INX H
LOOP: INX H
JC AHEAD
AHEAD: DCR B
HLT
OBSERVATION:
0A (4201)
F1 (4202)
1F (4203)
26 (4204)
FE (4205)
Output: 0A (4300)
RESULT: Thus the program to find the smallest number in an array of data was executed
Prg #7, ARRANGE AN ARRAY OF DATA IN ASCENDING ORDER
ALGORITHM:
6. If they are out of order, exchange the contents of A –register and Memory
PROGRAM:
LXI H,4200
MOV C,M
DCR C
LXI H,4201
INX H
CMP M
JC SKIP
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
SKIP: DCR D
JNZ LOOP
DCR C
JNZ REPEAT
HLT
OBSERVATION:
4201 05
4202 04
4203 03
4204 02
4205 01
4201 01
4202 02
4203 03
4204 04
4205 05
RESULT: Thus the given array of data was arranged in ascending order.
Prg #8, ARRANGE AN ARRAY OF DATA IN DESCENDING ORDER
ALGORITHM:
6. If they are out of order, exchange the contents of A –register and Memory
PROGRAM:
LXI H,4200
MOV C,M
DCR C
LXI H,4201
INX H
CMP M
JNC SKIP
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
SKIP: DCR D
JNZ LOOP
DCR C
JNZ REPEAT
HLT
OBSERVATION:
4201 01
4202 02
4203 03
4204 04
4205 05
4201 05
4202 04
4203 03
4204 02
4205 01
RESULT: Thus the given array of data was arranged in descending order.
Prg# 9
AIM: To write a program to find square of any number.
Algorithm –
Program –
MVI H 20 H <- 20
MVI L 50 L <- 50
MVI A 00 A <- 00
MOV B, M B <- M
ADD M A <- A + M
DCR B B <- B – 01
HLT END
Algorithm –
1. Initialize register H with 30 and register L with 50, so that indirect memory M points to memory location 3050.
2. Initialize register B with 00, register C with 08 and register D with 01.
3. Move the content of B in M.
4. Increment M by 1 so that M points to next memory location.
5. Move the content of D in M.
6. Move the content of B in accumulator A.
7. Add the content of D in A.
8. Move the content of D in B.
9. Move the content of A in D.
10. Increment M by 1 so that M points to next memory location.
11. Move the content of A in M.
12. Decrements C by 1.
13. Jump to memory location 200C if ZF = 0 otherwise Halt the program.
Program –