Prev: 54514 Up: Map Next: 54536
54521: 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 54521 PUSH BC Stash BC on the stack.
54522 LD HL,0 Set the product to zero.
54525 LD B,8 Set the number of bits to 8.
MultiplyAByDE_Loop 54527 ADD HL,HL Double the product.
54528 RLCA Move the next bit of the first number into the carry.
54529 JR NC,MultiplyAByDE_Next Jump to MultiplyAByDE_Next if it is not set.
54531 ADD HL,DE Add the second number.
MultiplyAByDE_Next 54532 DJNZ MultiplyAByDE_Loop Jump to MultiplyAByDE_Loop until all of the bits are done.
54534 POP BC Restore BC from the stack.
54535 RET Return.
View the equivalent code in;
Prev: 54514 Up: Map Next: 54536