about summary refs log tree commit diff stats
path: root/318counter.subx
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-05-29 15:40:58 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-05-29 15:40:58 -0700
commit8dc3c85a0336acfcb8c0fb67ea10307769f3dad2 (patch)
treef1d1b7fa3e9e5c1e726ece8274b680c04377ef03 /318counter.subx
parent210553ac6803f278e4ec5f604133b3e1e2126276 (diff)
downloadmu-8dc3c85a0336acfcb8c0fb67ea10307769f3dad2.tar.gz
.
Minor counter infrastructure. We invoke next-token 1400 times while loading
the shell's data disk, so we're wasting around 1.4MB during tokenization.
Diffstat (limited to '318counter.subx')
-rw-r--r--318counter.subx31
1 files changed, 31 insertions, 0 deletions
diff --git a/318counter.subx b/318counter.subx
new file mode 100644
index 00000000..74e1f4f8
--- /dev/null
+++ b/318counter.subx
@@ -0,0 +1,31 @@
+# A rudimentary counter that can be called from anywhere.
+
+== code
+
+count-event:
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    #
+    ff 0/subop/increment *Foo
+$count-event:end:
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
+count-of-events:  # -> _/eax: int
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    #
+    8b/-> *Foo 0/r32/eax
+$count-of-events:end:
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
+== data
+Foo:
+  0/imm32