Prev: D4F2 Up: Map Next: D508
D4F9: Multiply A By DE
Used by the routine at FlipSprite.
Multiplies A by DE.
Input
A The first number
DE The second number
Output
HL The product
Shift and add for each of the eight bits.
MultiplyAByDE D4F9 PUSH BC Stash BC on the stack.
D4FA LD HL,$0000 Set the product to zero.
D4FD LD B,$08 Set the number of bits to 08.
MultiplyAByDE_Loop D4FF ADD HL,HL Double the product.
D500 RLCA Move the next bit of the first number into the carry.
D501 JR NC,MultiplyAByDE_Next Jump to MultiplyAByDE_Next if it is not set.
D503 ADD HL,DE Add the second number.
MultiplyAByDE_Next D504 DJNZ MultiplyAByDE_Loop Jump to MultiplyAByDE_Loop until all of the bits are done.
D506 POP BC Restore BC from the stack.
D507 RET Return.
View the equivalent code in;
Prev: D4F2 Up: Map Next: D508