1.
Perform the following Operations related to memory locations
(a) Store the data byte 32H into memory location 4000H
(b Exchange the contents of memory locations 2000H and
4000H.
2. Subtract the contents of memory location 4001h from the memory
location 2000H and place the result in memory location 4002H.
3. Subtract two 8 bit numbers
4. Subtract the 16-bit number in memory locations 4002H and 4003H
from the 16-bit number in memory locations 4000H and 4001H.
The most significant eight bits of the two numbers are in memory
locations 4001H and 4003H. Store the result in memory locations
4004H and 4005H with the most significant byte in memory
location 4005H.
5. Add the contents of memory locations 40001H and 4001H and place
the result in the memory locations 4002Hand 4003H.
6. Add the 16-bit number in memory locations 4000H and 4001H to
the 16-bit number in memory locations 4002H and 4003H. The
most significant eight bits of the two numbers to be added are in
memory locations 4001H and 4003H. Store the result in memory
locations 4004H and 4005H with the most significant byte in
memory location 4005H.
7. Find the l's complement of the number stored at memory location
4400H and store the complemented number at memory location
4300H
8. Find the 2's complement of the number stored at memory location
4200H and store the complemented number at memory location
4300H
9. Pack the two unpacked BCD numbers stored in memory locations
4200H and 4201H and store the result in memory location 4300H.
Assume the least significant digit is stored at 4200H.
10. Two digits BCD number is stored in memory location 4200H.
Unpack the BCD number and store the two digits in memory
locations 4300H and 4301H such that memory location 4300H will
have a lower BCD digit.
1
1. Perform the following Operations related to memory locations
(a ) Store the data byte 32H into memory location 4000H.
MVI A,32H
STA 4000H
HL
OUTPUT: 4000H = 32H
2
(b) Exchange the contents of memory location 2000H and 4000H.
LDA 2000H
MOV B,A
LDA 4000H
STA 2000H
MOV A,B
STA 4000H
HLT
INPUT: 2000H = 32H
4000H = 52H
OUTPUT: 2000H = 52H
4000H = 32H
3
2. Subtract the contents of memory location 4001H from the memory location
2000H and place the result in memory location 4002H.
LDA 4001H
MOV B,A
LDA 2000H
SUB B
STA 4002H
HLT
INPUT : 4001H = 10H
2000H = 20H
OUTPUT : 4002H = 10H
4
3. Subtract two 8 bit numbers.
MVI B,30H
MVI A,50H
SUB B
STA 2000
HLT
Input : B=30H
A=50H
Output : 2000H = 20H
5
4. Subtract the 16-bit number in memory locations 4002H and 4003H from the
16-bit number in memory locations 4000H and 4001H. The most significant
eight bits of the two numbers are in memory locations 4001H and 4003H.
Store the result in memory locations 4004H and 4005H with the most
significant byte in memory location 4005H.
LHLD 4000H
XCHG
LHLD 4002H
MOV A,E
SUB L
MOV L,A
MOV A,D
SUB H
MOV H,A
SHLD 4004H
HLT
Input : At 4000H and 4001H L=05 , H =20
At 4002H and 4003H, L=15 , H=03
Output : At 4004H and 4005H, L=1D , H=F0
6
5. Add the contents of memory locations 4000H and 4001H and place the result
in the memory locations 4002Hand 4003H.
LXI H,4000H
MOV A,M
INX H
ADD M
INX H
MOV M,A
MVI A,00H
ADC A
INX H
MOV M,A
HLT
Input : 4000H = 7FH
4001H = 89H
Output : 4002H = 08H
4003H = 01H
7
6. Add the 16-bit number in memory locations 4000H and 4001H to the 16-bit
number in memory locations 4002H and 4003H. The most significant eight
bits of the two numbers to be added are in memory locations 4001H and
4003H. Store the result in memory locations 4004H and 4005H with the
most significant byte in memory location 4005H.
LHLD 4000H
XCHG
LHLD 4002H
MOV A,E
ADD L
MOV L,A
MOV A,D
ADC H
MOV H,A
SHLD 4004H
HLT
Input : At 4000H and 4001H, L= 08H , H = 04H
At 4002H and 4003H, L= 07H , H = 03H
Output : At 4004H and 4005H, L= 0FH , H = 07H
8
7. Find the l's complement of the number stored at memory location 4400H and
store the complemented number at memory location 4300H
LDA 4400H
CMA
STA 4300H
HLT
Input : 4400H = 08H
Output : 4300H = F7H
9
8. Find the 2's complement of the number stored at memory location 4200H
and store the complemented number at memory location 4300H
LDA 4200H
CMA
ADI 01H
STA 4300H
Input : 4200H = 08H
Output : 4300H = F8H
HLT
10
9. Pack the two unpacked BCD numbers stored in memory locations 4200H and
4201H and store the result in memory location 4300H. Assume the least
significant digit is stored at 4200H.
LDA 4201H
RLC
RLC
RLC
RLC
ANI 0F0H
MOV C,A
LDA 4200H
ADD C
STA 4300H
HLT
Input : 4200H = 04H
4201H = 09H
Output : 4300H = 94H
11
10.Two digits BCD number is stored in memory location 4200H. Unpack the
BCD number and store the two digits in memory locations 4300H and 4301H
such that memory location 4300H will have lower BCD digit.
LDA 4200H
ANI FOH
RRC
RRC
RRC
RRC
STA 4301H
LDA 4200H
ANI OFH
STA 4300H
HLT
Input : 4200H = 58H
Output : 4300H = 08H
4301H = 05H
12