gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit e3b2f469d4211cad07d4458cbda6d3aea49fa299 parent 7a62ba7196a6ea5ed4fc9bb950030f7b96164764 Author: Toxa <56631470+untoxa@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:54:54 +0300 Merge pull request #865 from Phidias618/patch-1 Fix divisions by one Diffstat:
| M | gbdk-lib/libc/asm/sm83/div.s | 17 | ++++++++++++++++- |
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/gbdk-lib/libc/asm/sm83/div.s b/gbdk-lib/libc/asm/sm83/div.s @@ -69,7 +69,12 @@ __divuint:: or l jr z, .division_by_zero - + + ld a, l + and h + inc a + jr z, .division_by_one + ; if X < Y then ; return quotient = 0 and remainder = X ; else @@ -164,6 +169,16 @@ ret_hl_in_de: ; if this is reached, then bc = 0 scf jr ret_hl_in_de +.division_by_one: + ; returns a remainder of 0 and a quotient of X + ld c, e + ld b, d + + ; a is assumed to store 0 + ld d, a + ld e, a + + ret ; mixed sign division
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.