Prev: D02C Up: Map Next: D04B
D03E: Multiply A By DE
Multiplies A by DE.
Input
A The first number
DE The second number
Output
HL The product
Start with a product of zero, and count eight bits.
MultiplyAByDE D03E LD HL,$0000 Set the product to 00.
D041 LD B,$08 Set a count of 08.
Double the product, and add DE if the next bit of A is set.
MultiplyAByDE_Bit D043 ADD HL,HL Double the product.
D044 RLCA Move the next bit of the first number into the carry flag.
D045 JR NC,MultiplyAByDE_Next Jump to MultiplyAByDE_Next if it is not set.
D047 ADD HL,DE Add the second number.
Count down the bits.
MultiplyAByDE_Next D048 DJNZ MultiplyAByDE_Bit Jump to MultiplyAByDE_Bit until all the bits are done.
D04A RET Return.
Prev: D02C Up: Map Next: D04B