Prev: B916 Up: Map Next: BADC
BACD: Multiply
This multiplies the two 8-bit values in A and E, returning a 16-bit result in HL.
Used by the routine at render_mask_buffer.
Input
A Left hand value.
E Right hand value.
Output
D Zero.
HL Multiplied result.
multiply BACD LD B,$08 Set B for eight iterations (width of multiplicands)
BACF LD HL,$0000 Set our accumulator to zero
BAD2 LD D,H Zero D so that DE holds the full 16-bit right hand value
Start loop
multiply_0 BAD3 ADD HL,HL Double our accumulator (shifting it left)
BAD4 RLA Shift A left. The shifted-out top bit becomes the carry flag
BAD5 JP NC,multiply_1 Jump if no carry
BAD8 ADD HL,DE Otherwise HL += DE
multiply_1 BAD9 DJNZ multiply_0 ...loop
BADB RET Return
Prev: B916 Up: Map Next: BADC