about summary refs log tree commit diff stats
path: root/106size.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-06-14 00:40:16 -0700
committerKartik Agaram <vc@akkartik.com>2020-06-14 00:40:16 -0700
commit5945986cc5c743345938403d553fe9a4edf655fd (patch)
treeadb890474caa06a3a5eb022c465869d1f389d3c9 /106size.subx
parentad61776f498e8117756e4794eac840fab60cfac6 (diff)
downloadmu-5945986cc5c743345938403d553fe9a4edf655fd.tar.gz
6521 - new primitive: array size in bytes
Diffstat (limited to '106size.subx')
-rw-r--r--106size.subx17
1 files changed, 17 insertions, 0 deletions
diff --git a/106size.subx b/106size.subx
new file mode 100644
index 00000000..9d2be695
--- /dev/null
+++ b/106size.subx
@@ -0,0 +1,17 @@
+# Size of an array in bytes.
+
+== code
+
+size:  # in: (addr array _) -> result/eax: int
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # eax = in
+    8b/-> *(ebp+8) 0/r32/eax
+    #
+    8b/-> *eax 0/r32/eax
+$size:end:
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return