Routines
| Prev: A419 | Up: Map | Next: A480 |
A476: Divide HL by DE: A = quotient, HL = remainder
|
||||||||||||||||
| A476 | LD A,$FF | Load A with $FF - Divide HL by DE by repeated subtraction: A counts from -1 (so A = the quotient) | ||||||||||||||
| A478 | INC A | Add one to A | ||||||||||||||
| A479 | AND A | Clear the carry flag, so that the subtraction that follows is a plain one (a compare) | ||||||||||||||
| A47A | SBC HL,DE | Subtract DE from HL (a compare: carry = HL was smaller, zero = equal) | ||||||||||||||
| A47C | JR NC,$A478 | If it did not go below zero, go back to A478 | ||||||||||||||
| A47E | ADD HL,DE | Add DE to HL - Add the divisor back: HL = the remainder | ||||||||||||||
| A47F | RET | Return to the caller | ||||||||||||||
| Prev: A419 | Up: Map | Next: A480 |