about summary refs log tree commit diff stats
path: root/baremetal/115write-byte.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-15 21:27:52 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-15 21:27:52 -0800
commit0d246473c5270a0f13a2706a1f0204d375f62d30 (patch)
tree7fc1fa8109a3d929f4197a88c8efe5b0cca6a0f4 /baremetal/115write-byte.subx
parent49424b1933051b6cf1ce3371ada9cd7fa2d31df0 (diff)
downloadmu-0d246473c5270a0f13a2706a1f0204d375f62d30.tar.gz
7524 - bring back some abort messages
Our infrastructure for displaying errors is far more rudimentary in
baremetal. Many ways things can go wrong. But making the attempt seems
better than not.

I'm also making some effort to keep it easy to see what has been copied
over from the top-level, by not modifying copied code to use syntax
sugar and so on. It may not be an important enough reason to mix
notations in a single file.
Diffstat (limited to 'baremetal/115write-byte.subx')
-rw-r--r--baremetal/115write-byte.subx9
1 files changed, 8 insertions, 1 deletions
diff --git a/baremetal/115write-byte.subx b/baremetal/115write-byte.subx
index 3ac587f0..45cf9950 100644
--- a/baremetal/115write-byte.subx
+++ b/baremetal/115write-byte.subx
@@ -22,7 +22,7 @@ append-byte:  # f: (addr stream byte), n: int
     8b/copy                         0/mod/indirect  7/rm32/edi    .           .             .           1/r32/ecx   .               .                 # copy *edi to ecx
     # if (f->write >= f->size) abort
     3b/compare                      1/mod/*+disp8   7/rm32/edi    .           .             .           1/r32/ecx   8/disp8         .                 # compare ecx with *(edi+8)
-    7d/jump-if->=  $append-byte:end/disp8  # TODO: abort
+    7d/jump-if->=  $append-byte:abort/disp8
 $append-byte:to-stream:
     # write to stream
     # f->data[f->write] = LSB(n)
@@ -40,6 +40,13 @@ $append-byte:end:
     5d/pop-to-ebp
     c3/return
 
+$append-byte:abort:
+    (draw-text-wrapping-down-then-right-from-cursor-over-full-screen 0 "append-byte: out of space\n" 3)  # 3=cyan
+    {
+      eb/jump loop/disp8
+    }
+    # never gets here
+
 test-append-byte-single:
     # - check that append-byte writes to first byte of 'file'
     # setup