diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-07-14 01:15:10 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-07-14 01:15:10 -0700 |
commit | 648d9432b6fe42589cecdab0a2b5747cb6145559 (patch) | |
tree | be83caecb543b4a3034191e02ca77d660899f202 | |
parent | e2b6baf1ca41ec0e95faf118dace8257d101ed0a (diff) | |
download | mu-648d9432b6fe42589cecdab0a2b5747cb6145559.tar.gz |
clarify a corner case in 2's complement integers
https://merveilles.town/@akkartik/106577885001702701
-rw-r--r-- | 126write-int-decimal.subx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/126write-int-decimal.subx b/126write-int-decimal.subx index f2754fda..d30cb762 100644 --- a/126write-int-decimal.subx +++ b/126write-int-decimal.subx @@ -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 |