EXPERIMENT- 1 DATE: _____________
Enter following programs and check the results.
A. Add the two 8-bit numbers using immediate addressing mode. Store answer in accumulator .the
sum is of 8-bits.
MVI A, 90H
MVI B, 13H
ADD B
HLT
Program Entry
Memory Instruction Hex Code Comment
Location
Result
Inputs Outputs
Add the same two number using register indirect addressing mode. The numbers are located at 4100
H and 4101 H. The sum (8 bits) should be stored at 4102 H.
LXI H, 4100H
MOV A, M
INX H
ADD M
STA 4102H
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
Repeat the same program in part (B) with one number of 4100 H and other number at 4110 H. The
answer should beat 4150 H.
LXI H, 4100H
MOV A, M
LXI H, 4110H
ADD M
STA 4150H
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
EXPERIMENT- 2 DATE: _____________
Aim: A. Add two 8 bit numbers with sum greater than 8 bits. Use memory locations 4100H onwards for
storing two numbers, sum and carry.
B. Ten data bytes are stored at location starting from 4100 H. Add them and store the 16 bit result at
4700 H and 4701 H.
A.
LXI H, 4100H
MVI C, 00H
MOV A, M
INX H
ADD M
JNC AHEAD
INR C
AHEAD: STA 4102H
MOV A, C
STA 4103H
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
B.
MVI A, 00H OR XRA A
MOV B, A
LXI H, 4100H
MOV A, M
MVI C, 0A H
LOOP: ADD M
JNC NEXT
INR B
NEXT: INX H
DCR C
JNZ LOOP
STA 4700H
MOV A, C
STA 4701H
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
EXPERIMENT- 3 DATE: _____________
Aim: A. Write a program to find the largest number from the array of ten unsigned data bytes stored at
location 4100 H onwards. Store answer at 4200 H.
B. Write a program to determine number of +ve, -ve and zeros from ten signed data bytes stored at
4100 H onwards. Store the answer at location 4200 H onwards.
A.
LXI H, 4100H
MVI C, 09H
MOV A, M
LOOP: INX H
CMP M
JNC AHEAD
MOV A, M
AHEAD: DCR C
JNZ LOOP
STA 4200H
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
B.
LXI H, 4100H
MVI C, 0A H
MVI B, 00H
MVI D, 00H
MVI E, 00H
LOOP: MOV A, M
CPI 00H
JNZ PON
INR B
JMP OVER
PON: RAL
JC NEG
INR D
JMP OVER
NEG: INR E
OVER: INX H
DCR C
JNZ LOOP
LXI H, 4700H
MOV M, B
INX H
MOV M, D
INX H
MOV M,E
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
EXPERIMENT- 4 DATE: _____________
Aim: A. Write a program to multiply two 8 bit numbers using successive addition. Two data bytes are at
locations 4100H and 4101H. The answer is to be stored at 4700H and 4701H.
B. Write a program to divide two 8 bit numbers using successive subtraction. Two data bytes are at
locations 4100H (dividend) and 4101H (divisor). The answer is to be stored at 4700H (quotient) and
4701H (remainder).
A.
LXI H, 4100H
MOV C, M
MVI A, 00H
INX H
MOV B, M
MVI D, 00H
LOOP: ADD C
JNC SKIP
INR D
SKIP: DCR B
JNZ LOOP
STA 4700H
MOV A, D
STA 4701H
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
B.
LXI H, 4100H
MOV A, M
INX H
MOV B, M
MVI C, 00H
LOOP: SUB B
JC SKIP
INR C
JMP LOOP
SKIP: ADD B
STA 4700H
MOV A, C
STA 4701H
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
EXPERIMENT- 5 DATE: _____________
Aim: A. Write a program to arrange (sort) ten data bytes stored at 4100 H onwards into ascending order.
Suggest modifications for descending order arrangement.
B. Write a program to add two BCD numbers stored at 4100 H and 4101 H. store the answer at 4700 H.
and 4701 H.
A.
LXI H, C100H
MVI C, 09H
LOOP2: MOV D, C
LOOP1: MOV A, M
INX H
CMP M
JC SKIP
MOV B, M
MOV M, A
DCX H
MOV M, B
INX H
SKIP: DCR D
JNZ LOOP1
LXI H C100H
DCR C
JNZ LOOP2
HLT
This method is called bubble sorting. Here for e.g. five nos. are given
(1) First (1) & (2) are compared.
(2) And larger no stored at higher location.
(3) Then it will again compare with 3rd no.
(4) And process repeats 4 times.
(5) After one internal loop we get largest no. at highest memory location. Then again remaining four
nos. are sorted and found largest no. and stored at second highest location and so on.
Memory Instruction Hex Code Comment
Location
Inputs Outputs
B.
MVI C, 00H
LXI H, 4100H
MOV A, M
INX H
ADD M
DAA
JNC AHEAD
INR C
AHEAD: STA 4700H
MOV A, C
STA 4701H
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs
EXPERIMENT- 6 DATE: _____________
Aim: A. Write a program to convert a number from hexadecimal to BCD stored at 4100 H. Store answer
at 4700 H onwards.
B. Repeat the above program using subroutine for division process. Write main program at 4200H
onwards and subroutine at 4250H onwards.
A.
LXI H, 4100H
MOV A, M
MVI B, 64H
MVI C, 00H
LOOP: SUB B
JC OVER
INR C
JMP LOOP
OVER: ADD B
MVI D, 00H
MVI B, 0AH
LOOP1: SUB B
JC OVER1
INR D
JMP LOOP1
OVER1: ADDB
LXI H, 4700H
MOV M, C
INX H
MOV M, D
INX H
MOV M, A
HLT
Description: Let the 8-bit hex. no. is FFH.
FFH = 25510
So, three BCD digits result and required to store. If we divide any 3 digit decimal no. by 100 then MSD
will come as dividend now 10010 = 64H
So, divide first hex no by 64H. Store its dividend now its remainder is again divided by 10 10 = 0AH. This
gives the middle digit in dividend and remainder gives the LSD.
Ex. FFH = 25510
FFH ÷ 64H ------------- Dividend – 2 (C) Reg.
Remainder –37H
Then 37H ÷ 0AH ------------ Dividend – 5 (D) Reg.
Remainder – 5 (A) Reg.
The answer is stored as
Reg. C Reg. D Reg. A
MSD Middle digit LSD
Memory Instruction Hex Code Comment
Location
Inputs Outputs
B. MAIN Program DIV: MVI C, 00H
LXI SP, EEEEH LOOP: SUB B
LXI H, 4100H JC SKIP
MOV A, M INR C
MVI B, 64H JMP LOOP
CALL DIV SKIP: ADD B
MOV E, C RET
MVI B, 0AH
CALL DIV
LXI H, 4700H
MOV M, E
INX H
MOV M, C
INX H
MOV M, A
HLT
Memory Instruction Hex Code Comment
Location
Inputs Outputs