clarify a corner case in 2's complement integers

https://merveilles.town/@akkartik/106577885001702701
This commit is contained in:
Kartik K. Agaram 2021-07-14 01:15:10 -07:00
parent e2b6baf1ca
commit 648d9432b6
1 changed files with 31 additions and 0 deletions

View File

@ -263,6 +263,37 @@ test-write-int32-decimal-negative:
# . end
c3/return
# There's a special bit pattern that corresponds to no 2's complement integer.
# There doesn't seem to be a widespread convention for representing it.
test-write-int32-decimal-indefinite-integer:
# setup
# . clear-stream(_test-stream)
# . . push args
68/push _test-stream/imm32
# . . call
e8/call clear-stream/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
# write-int32-decimal(_test-stream, 0x80000000)
# . . push args
68/push 0x80000000/imm32
68/push _test-stream/imm32
# . . call
e8/call write-int32-decimal/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
# check-stream-equal(_test-stream, "-(", msg)
# . . push args
68/push "F - test-write-int32-decimal-indefinite-integer"/imm32
68/push "-("/imm32
68/push _test-stream/imm32
# . . call
e8/call check-stream-equal/disp32
# . . discard args
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp
# . end
c3/return
test-write-int32-decimal-negative-multiple-digits:
# - check that a multi-digit number converts correctly
# setup