Sem 6‎ > ‎MPRC LAB‎ > ‎

P5: Multiplication of two 8 bit numbers.

posted Apr 7, 2013, 1:57 AM by Neil Mathew   [ updated Apr 7, 2013, 1:57 AM by Neil Mathew ]
A little intro before I just type the program. 

What is multiplication exactly? 
Repeated addition of the number. 
So if I was to perform 2 x 3, I'd get the answer by adding 2 three times. 2 + 2 + 2.

Take 4 registers. Say A, B, C, D.

A (Accumulator) should store the Product.
B should store the carry, if any.
C should store the first number. (like 2)
D should store the second number. (like 3)


PROGRAM:




MVI B, 00
MVI A,00
LXI H, 2500
MOV C, M
INX H
MOV D, M
LOOP ADD C
JNC AHEAD
INR B
AHEAD DCR D
JNZ LOOP
STA 2503H
RST1



RST1 is a software interrupt which can be used by programmers to interrupt the program. 
Preferred over HLT because that requires a reset using one of the physical buttons of the kit.



Comments