assembly - Assembler i8080 Multiplying two 16bits numbers -
i have prepare program i8080 processor. program have multiplying 2 16b numbers. don't know how check multiplier bit bit.
e.g 1111 * 1011 = first bit of 1011 1 add 1111 second bit 1 add 11110 third bit 0 don't add 111100 forth 1 add 1111000
result 1111+11110+1111000=10100101
and problem how chceck bits of multiplier?
thanks help
probably easiest way shift right , check carry, otherwise have keep changing bit test , that's hard, register pair. shifting bit annoying on 8080 since a
can rotated. let's multiplier in bc
(and multiplicand in hl
, result in de
can shift multiplicand dad h
, takes xchg
add-to-result happens less often)
mov a, b ora ; reset carry rar mov b, mov a, c rar mov c, jnc skipadd
using ora a
ensures multiplier goes zero, allows exit test such as:
mov a, b ora c jnz looptop
if unroll 16 can fill bc
left carry left shift of multiplicand, won't make difference.
Comments
Post a Comment