Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 5

Programs List:

1. Write an ALP to load register B with with data 14H, register C with FFH, register D with 29
H and register E with 67H
2. Write an ALP to transfer data from B to C register.
3. Write an ALP to store data of B into memory location 2050H
4. Write an ALP to which directly store 56H into memory location 2050H
5. Write an ALP for exchanging two 8 bit numbers stored at locations 2050H and 2051H
6. Write an ALP to interchange 16-bit data stored in register BC and DE with XCHG and
without XCHG.
7. Write an ALP to store the contents of B and C on the stack
8. Write an ALP to add two 8-bit numbers stored at 2050H and 2051H. Store the result in
2052H.
9. Write an ALP to add two 8-bit numbers stored at 2050H and 2055H. Store the result in
2058H.
10. Evaluate the following boolean expression D = (B+C).E
11. Write an ALP to copy a block from 2050H - 2055H to 2060H – 2065H.
12. Write an ALP to test Carry flag.
13. Write an ALP to test Parity flag.
14. Write an ALP to test Auxiliary Carry flag.
15. Write an ALP to test Zero flag.
16. Write an ALP to test Sign flag.
17. Write an ALP to find the sum of all the elements in an array.
18. Write a subroutine for addition, subtraction, masking, ANDing, XORing and Oring.
19. Find 1’s complement of a number, stored at 0000H and store the result in 0001H.
20. Find 2’s complement of a number, stored at 0000H and store the result in 0001H.
21. Pack the two unpacked BCD numbers stored in memory locations 0000H and 0001H. Store
the result in 0002H. Assume the least significant digit is at 0000H.
22. Two digit BCD number is stored at 0000H. Unpack the two BCD numbers and store the
individual numbers at memory locations 0001H and 0002H.
23.
Answers:

1. Write an ALP to load register B with with data 14H, register C with FFH, register D with 29
H and register E with 67H.
MVI B,14H
MVI C,FFH
MVI D,29H
MVI E,67H
HLT
2. Write an ALP to transfer data from B to C register.
MVI B,14H
MOV C, B
HLT

3. Write an ALP to store data of B into memory location 2050H


MVI B, 20H
LXI H, 2050H
MOV M, B
HLT
___________

MVI B,20H
MOV A, B
STA 2050H
HLT
4. Write an ALP to directly store 56H into memory location 2050H
LXI H, 2050H ;Create a pointer to 2050H location
MOV M, 56H ;Transfer 56H to location 2050H
HLT
5. Write an ALP for exchanging two 8 bit numbers stored at locations 2050H and 2051H
LDA 2050H
MOV B,A
LDA 2051H
STA 2050H
MOV A, B
STA 2051H
HLT
6. Write an ALP to interchange 16-bit data stored in register BC and DE with XCHG and
without XCHG.
Without XCHG
MOV H,B
MOV L,C
MOV B,D
MOV C,E
MOV D,H
MOV E,L
HLT
With XCHG
BC <-> DE
LXI B,2050H
LXI D,2010H
MOV H,B
MOV L,C
XCHG
MOV B,H
MOV C,L
HLT
7. Write an ALP to store the contents of B and C on the stack
LXI B,1020H ;BC<-1020H
PUSH B
HLT
8. Write an ALP to add two 8-bit numbers stored at 2050H and 2051H. Store the result in
2052H.
LXI H,2050H ;HL <-2050H
MOV B,M ;B <-M[HL]
INX H ;HL <- HL+1 i.e., 2051H location
MOV A,M ;A <-M[HL]
ADD B ;A <-A+B
STA 2052H ;[2052] <-A
HLT ;STOP
9. Write an ALP to add two 8-bit numbers stored at 2050H and 2055H. Store the result in
2058H.
LXI H,2050H ;HL <-2050H
MOV B,M ;B <-M[HL]
LDA 2055H ;A <- [2055]
ADD B ;A <-A+B
STA 2058H ;[2058] <-A
HLT ;STOP
______________________________________
LXI H,2050H ;HL <-2050H
MOV B,M ;B <-M[HL]
LXI H, 2055H ;HL <-2055H
MOV A,M ;A <-M[HL]
ADD B ;A <-A+B
STA 2058H ;[2058] <-A
HLT ;STOP

10. Evaluate the following boolean expression D = (B+C).E


MVI B,02H
MVI C,04H
MVI E,03H
MOV A,B
ORA C
ANA E
MOV D,A
HLT
11. Write an ALP to copy a block from 2050H - 2055H to 2060H – 2065H.
MVI C,06
LXI H, 2050H
LXI D, 2060H
LOOP:MOV A,M
STAX D
INX H
INX D
DCR C
JNZ LOOP
HLT
12. Write an ALP to test Carry flag.
MVI A,FFH
MVI B,02H
ADD B
HLT
13. Write an ALP to test Parity flag
14. Write an ALP to test Auxiliary Carry flag.
15. Write an ALP to test Zero flag.
16. Write an ALP to test Sign flag.
17. Write a subroutine for addition, subtraction, masking, ANDing, XORing and Oring. Assume
the two values are placed at 0000H and 0001H.
LXI H,0000H
MOV A,M
MOV C,A
INX H
MOV B,M
CALL CADD
STA 0002H
MOV A,C
CALL CSUB
STA 0003H
MOV A,C
CALL CMASK
STA 0004H
MOV A,C
CALL CAND
STA 0005H
MOV A,C
CALL CXOR
STA 0006H
CALL COR
STA 0007H
HLT

CADD: ADD B
RET
CSUB: SUB B
RET
CMASK: ANA B
RET
EX:
ADH AND 0FH = 1010 1101 & 0000 1111 = 0DH
ADH AND F0H = A0H
18.

You might also like