Hi Friend here i am written ALP For MULTIPLICATION OF TWO 8 BIT NUMBERS
Algorithm
MVI D, 00 Initialize register D to 00
MVI A, 00 Initialize Accumulator content to 00
LXI H, 4150
MOV B, M Get the first number in B - reg
INX H
MOV C, M Get the second number in C- reg.
LOOP: ADD B Add content of A - reg to register B.
JNC NEXT Jump on no carry to NEXT.
INR D Increment content of register D
NEXT: DCR C Decrement content of register C.
JNZ LOOP Jump on no zero to address
STA 4152 Store the result in Memory
MOV A, D
STA 4153 Store the MSB of result in Memory
HLT Terminate the program.
- Start the program by loading HL register pair with address of memory location.
- Move the data to a register (B register).
- Get the second data and load into Accumulator.
- Add the two register contents.
- Check for carry.
- Increment the value of carry.
- Check whether repeated addition is over and store the value of product and carry
- in memory location.
- Terminate the program.
MVI D, 00 Initialize register D to 00
MVI A, 00 Initialize Accumulator content to 00
LXI H, 4150
MOV B, M Get the first number in B - reg
INX H
MOV C, M Get the second number in C- reg.
LOOP: ADD B Add content of A - reg to register B.
JNC NEXT Jump on no carry to NEXT.
INR D Increment content of register D
NEXT: DCR C Decrement content of register C.
JNZ LOOP Jump on no zero to address
STA 4152 Store the result in Memory
MOV A, D
STA 4153 Store the MSB of result in Memory
HLT Terminate the program.
No comments:
Post a Comment