Prev: 44005 Up: Map Next: 44149
44136: Multiply A By DE
Used by the routines at Position_Rope_End and Move_Rope.
Multiplies A by DE, by adding DE to the product for each bit of A that is set. The product is a word.
Input
A The first number
DE The second number
Output
HL Product
MultiplyAByDE 44136 LD HL,0 Set the product so far to 0.
44139 LD B,8 Set the number of bits to 8.
MultiplyAByDE_Loop 44141 ADD HL,HL Double the product.
44142 RLCA Move the next bit of the first number into the carry.
44143 JR NC,MultiplyAByDE_Next Jump to MultiplyAByDE_Next if the bit is clear.
44145 ADD HL,DE Add the second number to the product.
MultiplyAByDE_Next 44146 DJNZ MultiplyAByDE_Loop Decrease the bit counter and loop back until all eight bits of the first number have been used.
44148 RET Return.
Prev: 44005 Up: Map Next: 44149