Chase H.Q. | Routines |
Prev: CD3A | Up: Map | Next: CDEC |
Multiplies C by the top three bits of A then divides by 8 with rounding, on exit.
Used by the routines at CBD6 and main_loop_10.
|
||||||||||
multiply | CDD6 | LD B,$03 | 3 iterations only | |||||||
CDD8 | LD E,A | Copy of multiplier to destroy | ||||||||
CDD9 | XOR A | Initialise total | ||||||||
mult_loop | CDDA | RL E | Shift the most significant bit out of multiplier | |||||||
CDDC | JR NC,mult_continue | If the MSB was set then total += multiplicand | ||||||||
CDDE | ADD A,C | |||||||||
mult_continue | CDDF | ADD A,A | total <<= 1 | |||||||
CDE0 | DJNZ mult_loop | While iterations remain, goto mult_loop | ||||||||
CDE2 | RRA | Undo final shift | ||||||||
CDE3 | SRA A | Divide by 8 with rounding | ||||||||
CDE5 | SRA A | |||||||||
CDE7 | SRA A | |||||||||
CDE9 | ADC A,$00 | |||||||||
CDEB | RET | Return |
Prev: CD3A | Up: Map | Next: CDEC |