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.
This commit is contained in:
Kartik K. Agaram 2021-05-29 15:40:58 -07:00
parent 210553ac68
commit 8dc3c85a03
2 changed files with 34 additions and 0 deletions

31
318counter.subx Normal file
View File

@ -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

3
400.mu
View File

@ -34,6 +34,9 @@ sig turn-off-debug-print
sig abort e: (addr array byte)
sig dump-call-stack
sig count-event
sig count-of-events -> _/eax: int
# streams
sig clear-stream f: (addr stream _)
sig rewind-stream f: (addr stream _)