Multiplication of Two 8 Bit Number
Sunny Bhaskar
11/6/20241 min read
Algorithm
Load the first number (04H) into register B.
Load the second number (02H) into register C (to use as a count).
Initialize the accumulator with 00H to store the result.
Perform the following in a loop until the count in C becomes zero:
Add the value in B to the accumulator.
Decrement C by 1.
Store the result in a specified memory location (e.g., 2052H).
Halt the program.
Program
MVI B, 04H ; Load 04H into register B (first number)
MVI C, 02H ; Load 02H into register C (second number, used as a count)
MVI A, 00H ; Clear accumulator A to store the result (initialize to 0)
MULT_LOOP:
ADD B ; Add B to A
DCR C ; Decrement C (counter)
JNZ MULT_LOOP ; Repeat if C is not zero
STA 2052H ; Store the result (08H) at memory location 2052H
HLT ; Halt the program