Question: Write an assembly language program to add 10 data bytes. Data is stored in memory location starting from 4460H. The result is 8 bits only and in stored in 4480H.

Algorithm

Step 1: Point HL register pair to memory location 4460H

Step 2: Set up a decrement counter, say C from 0AH (for 10 data)

Step 3: Load Accumulator with 00H to clear content

Step 4: Move content of memory location to register B

Step 5: Add B with Accumulator (A) and store to A(ADD command)

Step 6: Increase memory location by one

Step 7: Decrease C counter by one

Step 8: Until C is not equal to 0 repeat program control from Step 4:

Step 9: Store content of Accumulator to memory location 4480H

Step 10: Terminate the program

Assembly Language Program

Label Instruction Comments
LXI H, 4460H ; HL register pair points at memory location 4460H
MVI C, 0A H ; Sets up a decrement counter
MVI A, 00H ; Clears Accumulator
jump1: MOV B, M ; Moves content of memory location to B
ADD B ; Adds A and B and stores result at A
INX H ; HL pair points at M+1 memory location
DCR C ; Decreases C counter by one
JNZ jump1: ; Until C is not control jumps to jump1:
STA 4480H ; Stores result at 4480H (when C=0)
HLT ; Terminates the program

Show 1 Comment

1 Comment

Comments are closed