mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-27 13:32:08 +00:00
Merge pull request #366 from dbrotz/fix-313
Fix signed integer overflow issues
This commit is contained in:
42
test/asm/overflow.asm
Normal file
42
test/asm/overflow.asm
Normal file
@@ -0,0 +1,42 @@
|
||||
SECTION "sec", ROM0
|
||||
|
||||
print_x: MACRO
|
||||
printv x
|
||||
printt "\n"
|
||||
ENDM
|
||||
|
||||
x = 2147483647
|
||||
x = x + 1
|
||||
dl 2147483647+1
|
||||
print_x
|
||||
|
||||
x = -2147483648
|
||||
x = x - 1
|
||||
dl -2147483648-1
|
||||
print_x
|
||||
|
||||
x = -2147483648
|
||||
x = x * -1
|
||||
dl -2147483648 * -1
|
||||
print_x
|
||||
|
||||
x = -2147483648
|
||||
x = x / -1
|
||||
dl -2147483648 / -1
|
||||
print_x
|
||||
|
||||
x = -2147483648
|
||||
x = x % -1
|
||||
dl -2147483648 % -1
|
||||
print_x
|
||||
|
||||
x = -1
|
||||
x = x << 1
|
||||
dl -1 << 1
|
||||
print_x
|
||||
|
||||
x = 4294967295
|
||||
x = 4294967296
|
||||
|
||||
x = `33333333
|
||||
x = `333333333
|
||||
18
test/asm/overflow.out
Normal file
18
test/asm/overflow.out
Normal file
@@ -0,0 +1,18 @@
|
||||
warning: overflow.asm(24):
|
||||
Division of min value by -1
|
||||
warning: overflow.asm(25):
|
||||
Division of min value by -1
|
||||
warning: overflow.asm(34):
|
||||
Left shift of negative value: -1
|
||||
warning: overflow.asm(35):
|
||||
Left shift of negative value: -1
|
||||
warning: overflow.asm(39):
|
||||
Integer constant '4294967296' is too large
|
||||
warning: overflow.asm(42):
|
||||
Graphics constant '`333333333' is too long
|
||||
$80000000
|
||||
$7FFFFFFF
|
||||
$80000000
|
||||
$80000000
|
||||
$0
|
||||
$FFFFFFFE
|
||||
18
test/asm/overflow.out.pipe
Normal file
18
test/asm/overflow.out.pipe
Normal file
@@ -0,0 +1,18 @@
|
||||
warning: -(24):
|
||||
Division of min value by -1
|
||||
warning: -(25):
|
||||
Division of min value by -1
|
||||
warning: -(34):
|
||||
Left shift of negative value: -1
|
||||
warning: -(35):
|
||||
Left shift of negative value: -1
|
||||
warning: -(39):
|
||||
Integer constant '4294967296' is too large
|
||||
warning: -(42):
|
||||
Graphics constant '`333333333' is too long
|
||||
$80000000
|
||||
$7FFFFFFF
|
||||
$80000000
|
||||
$80000000
|
||||
$0
|
||||
$FFFFFFFE
|
||||
Reference in New Issue
Block a user