Prev: 52742 Up: Map Next: 52764
52749: 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
Clear the product and count the bits.
MultiplyAByDE 52749 PUSH BC Stash BC on the stack.
52750 LD HL,0 Set HL to 0000.
52753 LD B,8 Set B to 8.
Shift the product and add when the next bit is set.
MultiplyAByDE_Loop 52755 ADD HL,HL Double HL.
52756 RLCA Jump to MultiplyAByDE_Next if the carry flag is not set.
52757 JR NC,MultiplyAByDE_Next
52759 ADD HL,DE Add DE to HL.
MultiplyAByDE_Next 52760 DJNZ MultiplyAByDE_Loop Jump to MultiplyAByDE_Loop until B is zero.
52762 POP BC Restore BC from the stack.
52763 RET Return.
Prev: 52742 Up: Map Next: 52764