Routines |
Prev: 3014 | Up: Map | Next: 30C0 |
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 | 30A9 | PUSH BC | BC is saved. | |||||||||||
30AA | LD B,$10 | It is to be a 16-bit multiplication. | ||||||||||||
30AC | LD A,H | A holds the high byte. | ||||||||||||
30AD | LD C,L | C holds the low byte. | ||||||||||||
30AE | LD HL,$0000 | Initialise the result to zero. | ||||||||||||
HL_LOOP | 30B1 | ADD HL,HL | Double the result. | |||||||||||
30B2 | JR C,HL_END | Jump if overflow. | ||||||||||||
30B4 | RL C | Rotate bit 7 of C into the carry. | ||||||||||||
30B6 | RLA | Rotate the carry bit into bit 0 and bit 7 into the carry flag. | ||||||||||||
30B7 | JR NC,HL_AGAIN | Jump if the carry flag is reset. | ||||||||||||
30B9 | ADD HL,DE | Otherwise add DE in once. | ||||||||||||
30BA | JR C,HL_END | Jump if overflow. | ||||||||||||
HL_AGAIN | 30BC | DJNZ HL_LOOP | Repeat until 16 passes have been made. | |||||||||||
HL_END | 30BE | POP BC | Restore BC. | |||||||||||
30BF | RET | Finished. |
Prev: 3014 | Up: Map | Next: 30C0 |