# Program to multiply two 8-bit numbers with 16-bit result # By John Phillips on 11/14/2002 ORG 00h 00 01 26 Init: LOD A, [ZERO] # Init RAM variables 02 02 80 STO [RH], A # Set result high byte to 0 04 02 81 STO [RL], A # Set result low byte to 0 06 01 28 LOD A, [NUM2L] # Load the multiplicand (counter) 08 20 1E LOOP1: JZ DONE # Loop until the counter is zero 0A 02 82 STO [CNTR], A # Store counter value in RAM 0C 01 81 LOD A, [RL] # Load the result low byte 0E 04 27 ADD A, [NUM1L] # Add the multiplier 10 02 81 STO [RL], A # Store result to RAM 12 01 80 LOD A, [RH] # Load the result high byte 14 08 26 ADC A, [ZERO] # Add with carry to the high byte of multiplier (0) 16 02 80 STO [RH], A # Store result to RAM 18 01 82 LOD A, [CNTR] # Load the counter value from RAM 1A 04 29 ADD A, [NEG1] # Add -1 (FF) 1C 10 08 JMP LOOP1 # End of Loop 1E 01 80 DONE: LOD A, [RH] # Load the result high byte 20 02 C2 STO [DISP], A # Display it 22 01 81 LOD A, [RL] # Load the result low byte (display in ACC register) 24 80 80 HLT 26 00 ZERO: DB 00 # Zero (high byte of multiplicand) 27 03 NUM1L: DB 03 # Multiplicand low byte (SET TO WHAT YOU WANT TO MULTIPLY) 28 02 NUM2L: DB 02 # Multiplier low byte (SET TO WHAT YOU WANT TO MULTIPLY) 29 FF NEG1: DB FF # -1 in 2's complement form ORG 80h 80 00 RH: DB 00 # Result high byte variable 81 00 RL: DB 00 # Result low byte variable 82 00 CNTR: DB 00 # Counter variable