Multiplication in 8085 Assembly

Multiplication in 8085 Assembly

Published by Arun Isaac on

Tags: 8085, assembly

This is an implementation of multiplication by shifting and adding in 8085 assembly.

This is an implementation of multiplication by shifting and adding in 8085 assembly.

main:           MVI C, 08h      ;set counter
                LXI D, 0000h    ;clear product

                MVI A, 5Fh      ;load x
                LXI H, 009Ah    ;load y

loop:           RAR             ;shift x

                JNC skip        ;if carry is 0, don't add
                XCHG    
                DAD D           ;add shifted x to y
                XCHG    
skip:           DAD H           ;double y, that is shift it left
                DCR C           ;decrement counter
                JNZ loop        ;loop until counter is zero

                XCHG
                SHLD 4300h      ;store result

                HLT