Spectrum ROM | Routines |
Prev: 12308 | Up: Map |
This subroutine is called by GET_HLxDE and by multiply to perform the 16-bit multiplication as stated.
Any overflow of the 16 bits available is dealt with on return from the subroutine.
|
|||||||
HL_HLxDE | 12457 | PUSH BC | BC is saved. | ||||
12458 | LD B,16 | It is to be a 16-bit multiplication. | |||||
12460 | LD A,H | A holds the high byte. | |||||
12461 | LD C,L | C holds the low byte. | |||||
12462 | LD HL,0 | Initialise the result to zero. | |||||
HL_LOOP | 12465 | ADD HL,HL | Double the result. | ||||
12466 | JR C,HL_END | Jump if overflow. | |||||
12468 | RL C | Rotate bit 7 of C into the carry. | |||||
12470 | RLA | Rotate the carry bit into bit 0 and bit 7 into the carry flag. | |||||
12471 | JR NC,HL_AGAIN | Jump if the carry flag is reset. | |||||
12473 | ADD HL,DE | Otherwise add DE in once. | |||||
12474 | JR C,HL_END | Jump if overflow. | |||||
HL_AGAIN | 12476 | DJNZ HL_LOOP | Repeat until 16 passes have been made. | ||||
HL_END | 12478 | POP BC | Restore BC. | ||||
12479 | RET | Finished. |
Prev: 12308 | Up: Map |