about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-02-01 23:51:58 -0800
committerKartik Agaram <vc@akkartik.com>2019-02-01 23:51:58 -0800
commit77aa333c3c89eaa5a1a8d695e03d3e553207587a (patch)
tree172df24de2a91db1a3b2f26222bb8539157a7819 /subx
parent0ad068dd1da3d463f71c4b63028278767d62af9c (diff)
downloadmu-77aa333c3c89eaa5a1a8d695e03d3e553207587a.tar.gz
4946
Diffstat (limited to 'subx')
-rwxr-xr-xsubx/apps/packbin16303 -> 16512 bytes
-rw-r--r--subx/apps/pack.subx68
2 files changed, 66 insertions, 2 deletions
diff --git a/subx/apps/pack b/subx/apps/pack
index 162559e0..b48c40b2 100755
--- a/subx/apps/pack
+++ b/subx/apps/pack
Binary files differdiff --git a/subx/apps/pack.subx b/subx/apps/pack.subx
index 3d70d666..20116c2d 100644
--- a/subx/apps/pack.subx
+++ b/subx/apps/pack.subx
@@ -779,8 +779,6 @@ test-emit-hex-multiple-byte:
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
     # . end
     c3/return
-    # . end
-    c3/return
 
 test-emit-hex-zero-pad:
     # setup
@@ -842,4 +840,70 @@ test-emit-hex-zero-pad:
     # . end
     c3/return
 
+test-emit-hex-negative:
+    # 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
+    # . clear-stream(_test-buffered-file+4)
+    # . . push args
+    b8/copy-to-EAX  _test-buffered-file/imm32
+    05/add-to-EAX  4/imm32
+    50/push-EAX
+    # . . call
+    e8/call  clear-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # emit-hex(_test-buffered-file, -1, 2)
+    # . . push args
+    68/push  2/imm32
+    68/push  -1/imm32
+    68/push  _test-buffered-file/imm32
+    # . . call
+    e8/call  emit-hex/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
+    # flush(_test-buffered-file)
+    # . . push args
+    68/push  _test-buffered-file/imm32
+    # . . call
+    e8/call  flush/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # check(_test-stream->data == 'ff ff ')
+    # . check-ints-equal(_test-stream->data[0..3], 'ff f', msg)
+    # . . push args
+    68/push  "F - test-emit-hex-negative/1"/imm32
+    68/push  0x66206666/imm32
+    # . . push *_test-stream->data
+    b8/copy-to-EAX  _test-stream/imm32
+    ff          6/subop/push        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           0xc/disp8       .                 # push *(EAX+12)
+    # . . call
+    e8/call  check-ints-equal/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
+    # . check-ints-equal(_test-stream->data[4..7], 'f ', msg)
+    # . . push args
+    68/push  "F - test-emit-hex-negative/2"/imm32
+    68/push  0x2066/imm32
+    # . . push *_test-stream->data
+    b8/copy-to-EAX  _test-stream/imm32
+    ff          6/subop/push        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           0x10/disp8      .                 # push *(EAX+16)
+    # . . call
+    e8/call  check-ints-equal/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
+    # . end
+    c3/return
+
+== data
+
+_test-slice-negative-two:
+    2d/- 32/2
+_test-slice-negative-two-end:
+
 # . . vim:nowrap:textwidth=0