Fix division and modulo for very large negative numbers (#1790)

This commit is contained in:
Rangi
2025-08-11 20:46:47 -04:00
committed by GitHub
parent 30a8503dcd
commit 7df9c12a6c
5 changed files with 91 additions and 10 deletions

47
test/asm/div-negative.asm Normal file
View File

@@ -0,0 +1,47 @@
MACRO test
def num = \1
def den = \2
def quo = num / den
def rem = num % den
def rev = quo * den + rem
assert num == rev
println "{ 11d:num} (${08x:num}) / { 11d:den} (${08x:den}) = { 11d:quo} (${08x:quo}) R { 11d:rem} (${08x:rem})"
ENDM
test $8000_0000, $8000_0000
test $8000_0000, $c000_0000
test $8000_0000, $f000_0000
test $8000_0000, $f800_0000
test $8000_0000, $ff00_0000
test $c000_0000, $8000_0000
test $c000_0000, $c000_0000
test $c000_0000, $f000_0000
test $c000_0000, $f800_0000
test $c000_0000, $ff00_0000
test $f800_0000, $8000_0000
test $f800_0000, $c000_0000
test $f800_0000, $f000_0000
test $f800_0000, $f800_0000
test $f800_0000, $ff00_0000
test $0000_0000, $8000_0000
test $0000_0000, $c000_0000
test $0000_0000, $f000_0000
test $0000_0000, $f800_0000
test $0000_0000, $ff00_0000
test $0080_0000, $ff80_0000
test $0300_0000, $fd00_0000
test $0300_0000, $ff00_0000
test $0300_0000, $ff80_0000
test $6000_0000, $fd00_0000
test $6000_0000, $ff00_0000
test $6000_0000, $ff80_0000
test $7f00_0000, $fd00_0000
test $7f00_0000, $ff00_0000
test $7f00_0000, $ff80_0000