From adc92f49dca2951b04d3ea566a2e8134e9a891a7 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 14 May 2021 15:40:49 -0700 Subject: . Move abort to SubX. We'll need to do some unsafe stuff to display the call stack here. --- 317abort.subx | 15 +++++++++++++++ 400.mu | 1 + 501draw-text.mu | 11 ----------- 3 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 317abort.subx diff --git a/317abort.subx b/317abort.subx new file mode 100644 index 00000000..9d196ed8 --- /dev/null +++ b/317abort.subx @@ -0,0 +1,15 @@ +# Dump a stack trace when you abort. + +== code + +abort: # e: (addr array byte) + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp + # + (set-cursor-position-on-real-screen 0 0) + (draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+8) 0xf 0xc) # 0/real-screen, 0xf/fg=white, 0xc/bg=red + # crash + { + eb/jump loop/disp8 + } diff --git a/400.mu b/400.mu index 9fc89689..415c392a 100644 --- a/400.mu +++ b/400.mu @@ -31,6 +31,7 @@ sig debug-print x: (addr array byte), fg: int, bg: int sig debug-print? -> _/eax: boolean sig turn-on-debug-print sig turn-off-debug-print +sig abort e: (addr array byte) # streams sig clear-stream f: (addr stream _) diff --git a/501draw-text.mu b/501draw-text.mu index 79ec1930..8dbe0f4b 100644 --- a/501draw-text.mu +++ b/501draw-text.mu @@ -475,14 +475,3 @@ fn draw-text-wrapping-down-then-right-from-cursor-over-full-screen screen: (addr width, height <- screen-size screen draw-text-wrapping-down-then-right-from-cursor screen, text, 0/xmin, 0/ymin, width, height, color, background-color } - -# hacky error-handling -# just go into an infinite loop -fn abort e: (addr array byte) { - var dummy1/eax: int <- copy 0 - var dummy2/ecx: int <- copy 0 - dummy1, dummy2 <- draw-text-wrapping-right-then-down-over-full-screen 0/screen, e, 0/x, 0x2f/y, 0xf/fg=white, 0xc/bg=red - { - loop - } -} -- cgit 1.4.1-2-gfad0