about summary refs log tree commit diff stats
path: root/subx/apps/hex.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-05-25 23:47:49 -0700
committerKartik Agaram <vc@akkartik.com>2019-05-25 23:47:49 -0700
commit561028444397d2722130ef3bbf4a403acf7964b4 (patch)
tree1917d966a501d5a24aa51ddf08c9d1a5c5dd2c65 /subx/apps/hex.subx
parentbd31dbe85418b05a5f9e101525a829c48aa9bf37 (diff)
downloadmu-561028444397d2722130ef3bbf4a403acf7964b4.tar.gz
new primitive: parse-array-of-ints
Mostly for tests. For every new type we want to compare in a test, we're
now going to start using some primitive that can parse its value from string. In this manner we can get syntax for literals in machine code.

Open question: parsing aggregates of aggregates. Like an array of structs.

This is the first time we allocate from the heap in standard library tests.
So we now need to start initializing the heap in all our apps.
Diffstat (limited to 'subx/apps/hex.subx')
-rw-r--r--subx/apps/hex.subx9
1 files changed, 9 insertions, 0 deletions
diff --git a/subx/apps/hex.subx b/subx/apps/hex.subx
index 3730351f..6b82a1e9 100644
--- a/subx/apps/hex.subx
+++ b/subx/apps/hex.subx
@@ -18,6 +18,15 @@
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
 Entry:  # run tests if necessary, convert stdin if not
+    # initialize heap
+    # . Heap = new-segment(64KB)
+    # . . push args
+    68/push  Heap/imm32
+    68/push  0x10000/imm32/64KB
+    # . . call
+    e8/call  new-segment/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
 
 #?     # for debugging: run a single test
 #?     e8/call test-convert-next-octet-aborts-on-single-hex-byte/disp32