about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-07-14 01:15:10 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-07-14 01:15:10 -0700
commit648d9432b6fe42589cecdab0a2b5747cb6145559 (patch)
treebe83caecb543b4a3034191e02ca77d660899f202
parente2b6baf1ca41ec0e95faf118dace8257d101ed0a (diff)
downloadmu-648d9432b6fe42589cecdab0a2b5747cb6145559.tar.gz
clarify a corner case in 2's complement integers
https://merveilles.town/@akkartik/106577885001702701
-rw-r--r--126write-int-decimal.subx31
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