git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit a107f3d0bc9536bd982b9a5f12b384298d7fa46a
parent 5c3df55198b4c555f794c39d8baad18608b0d65c
Author: Toxa <untoxa@mail.ru>
Date:   Wed, 22 Nov 2023 11:51:02 +0300

GB: fix 8-bit signed modulus

Diffstat:
Mgbdk-lib/libc/asm/sm83/div.s16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gbdk-lib/libc/asm/sm83/div.s b/gbdk-lib/libc/asm/sm83/div.s @@ -31,6 +31,7 @@ ;; Originally from GBDK by Pascal Felber. .module divmod .area _CODE + .globl __divsuchar .globl __modsuchar .globl __divuschar @@ -72,10 +73,9 @@ __divuschar: jp .div16 __moduschar: - ld e, a ld d, #0 - ld a,c ; Sign extend + ld c, a ; Sign extend rlca sbc a ld b,a @@ -217,7 +217,7 @@ signexte: ;; Take absolute value of divisor bit 7,d jr Z,.chkde ; Jump if divisor is positive - sub a ; Substract divisor from 0 + sub a ; Subtract divisor from 0 sub e ld e,a sbc a ; Propagate borrow (A=0xFF if borrow) @@ -227,7 +227,7 @@ signexte: .chkde: bit 7,b jr Z,.dodiv ; Jump if dividend is positive - sub a ; Substract dividend from 0 + sub a ; Subtract dividend from 0 sub c ld c,a sbc a ; Propagate borrow (A=0xFF if borrow) @@ -241,7 +241,7 @@ signexte: pop af ; recover sign of quotient and #0x80 jr Z,.dorem ; Jump if quotient is positive - sub a ; Substract quotient from 0 + sub a ; Subtract quotient from 0 sub c ld c,a sbc a ; Propagate borrow (A=0xFF if borrow) @@ -252,7 +252,7 @@ signexte: pop af ; recover sign of remainder and #0x80 ret Z ; Return if remainder is positive - sub a ; Substract remainder from 0 + sub a ; Subtract remainder from 0 sub e ld e,a sbc a ; Propagate remainder (A=0xFF if borrow) @@ -303,14 +303,14 @@ signexte: ;; If remainder is >= divisor, next bit of quotient is 1. This ;; bit goes to carry push bc ; Save current remainder - ld a,c ; Substract divisor from remainder + ld a,c ; Subtract divisor from remainder sbc e ld c,a ld a,b sbc d ld b,a ccf ; Complement borrow so 1 indicates a - ; successful substraction (this is the + ; successful subtraction (this is the ; next bit of quotient) jr C,.drop ; Jump if remainder is >= dividend pop bc ; Otherwise, restore remainder

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.