about summary refs log tree commit diff stats
path: root/114error.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-07-05 12:13:28 -0700
committerKartik Agaram <vc@akkartik.com>2020-07-05 12:13:28 -0700
commitc09c91e185aad8e01b570c2569e13c1e429d2f99 (patch)
tree52a5ae1494ad5b7b2319411815dc45510e761c24 /114error.subx
parentf2c5b05374186f9422cfdaf1ada096e39ac91a8b (diff)
downloadmu-c09c91e185aad8e01b570c2569e13c1e429d2f99.tar.gz
6612 - reorganize layers
Diffstat (limited to '114error.subx')
-rw-r--r--114error.subx50
1 files changed, 50 insertions, 0 deletions
diff --git a/114error.subx b/114error.subx
new file mode 100644
index 00000000..c3d8ca68
--- /dev/null
+++ b/114error.subx
@@ -0,0 +1,50 @@
+# Print an error message and exit.
+
+== code
+#   instruction                     effective address                                                   register    displacement    immediate
+# . op          subop               mod             rm32          base        index         scale       r32
+# . 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
+
+# write(out, "Error: "+msg+"\n") then stop(ed, 1)
+error:  # ed: (addr exit-descriptor), out: fd or (addr stream byte), msg: (addr array byte)
+    # . prologue
+    55/push-ebp
+    89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
+    # write(out, "Error: ")
+    # . . push args
+    68/push  "Error: "/imm32
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           0xc/disp8       .                 # push *(ebp+12)
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
+    # write(out, msg)
+    # . . push args
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           0x10/disp8      .                 # push *(ebp+16)
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           0xc/disp8       .                 # push *(ebp+12)
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
+    # write(out, "\n")
+    # . . push args
+    68/push  Newline/imm32
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           0xc/disp8       .                 # push *(ebp+12)
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
+    # stop(ed, 1)
+    # . . push args
+    68/push  1/imm32
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           8/disp8         .                 # push *(ebp+8)
+    # . . call
+    e8/call  stop/disp32
+    # should never get past this point
+$error:dead-end:
+    # . epilogue
+    89/copy                         3/mod/direct    4/rm32/esp    .           .             .           5/r32/ebp   .               .                 # copy ebp to esp
+    5d/pop-to-ebp
+    c3/return
+
+# . . vim:nowrap:textwidth=0