![]() |
Routines |
| Prev: 41325 | Up: Map | Next: 41386 |
|
Divides the word in HL by the word in DE. Nothing in the game calls it.
|
||||||||||||||||
|
Nothing in the game divides one word by another.
|
||||||||||||||||
| DivideWords | 41345 | PUSH BC | Hold the dividend. | |||||||||||||
| 41346 | LD B,H | |||||||||||||||
| 41347 | LD C,L | |||||||||||||||
| 41348 | PUSH AF | |||||||||||||||
| 41349 | LD HL,0 | The remainder starts at zero, for sixteen bits. | ||||||||||||||
| 41352 | LD A,B | |||||||||||||||
| 41353 | LD B,16 | |||||||||||||||
|
Try the next bit of the dividend.
|
||||||||||||||||
| DivideWords_NextBit | 41355 | SLA C | Bring that bit into the remainder. | |||||||||||||
| 41357 | RLA | |||||||||||||||
| 41358 | ADC HL,HL | |||||||||||||||
| 41360 | SBC HL,DE | See whether the divisor fits. | ||||||||||||||
| 41362 | JR C,DivideWords_1 | |||||||||||||||
| DivideWords_0 | 41364 | INC C | The quotient gains a bit, and the next bit follows. | |||||||||||||
| 41365 | DJNZ DivideWords_NextBit | |||||||||||||||
| 41367 | JR DivideWords_2 | |||||||||||||||
|
The divisor did not fit.
|
||||||||||||||||
| DivideWords_Restore | 41369 | SLA C | Put the remainder back. | |||||||||||||
| 41371 | RLA | |||||||||||||||
| 41372 | ADC HL,HL | |||||||||||||||
| 41374 | ADD HL,DE | |||||||||||||||
| 41375 | JR C,DivideWords_0 | Try the next bit. | ||||||||||||||
| DivideWords_1 | 41377 | DJNZ DivideWords_Restore | ||||||||||||||
| 41379 | ADD HL,DE | |||||||||||||||
|
Nothing in the game uses this quotient.
|
||||||||||||||||
| DivideWords_2 | 41380 | EX DE,HL | Nothing in the game uses this quotient. | |||||||||||||
| 41381 | LD H,A | |||||||||||||||
| 41382 | LD L,C | |||||||||||||||
| 41383 | POP AF | Restore AF and BC from the stack. | ||||||||||||||
| 41384 | POP BC | |||||||||||||||
| 41385 | RET | Return. | ||||||||||||||
| Prev: 41325 | Up: Map | Next: 41386 |