![]() |
Routines |
| Prev: CF5B | Up: Map | Next: CF95 |
|
Used by the routine at ScaleDisplacement.
Multiplies the byte in D by the byte in C.
|
||||||||||||||
|
The byte in D is multiplied by the byte in C. Eight bits are tested, and each bit that is set adds the shifted byte into the product.
|
||||||||||||||
| Multiply | CF7E | LD H,$00 | The product starts at zero, with eight bits to test. | |||||||||||
| CF80 | LD B,H | |||||||||||||
| CF81 | LD L,H | |||||||||||||
| CF82 | LD E,D | |||||||||||||
| CF83 | LD A,$08 | |||||||||||||
| CF85 | JR Multiply_Bit | Test the first bit. | ||||||||||||
| Multiply_Loop | CF87 | DEC A | One fewer bit remains. | |||||||||||
| CF88 | RET Z | The product is ready. | ||||||||||||
| CF89 | SLA C | Shift the other byte up. | ||||||||||||
| CF8B | RL B | |||||||||||||
| Multiply_Bit | CF8D | RR D | The next bit of the byte. | |||||||||||
| CF8F | JR NC,Multiply_Loop | This bit adds nothing. | ||||||||||||
| CF91 | ADD HL,BC | Add the shifted byte into the product. | ||||||||||||
| CF92 | JP Multiply_Loop | The next bit. | ||||||||||||
| Prev: CF5B | Up: Map | Next: CF95 |