From 01ca4af2f919ed2aa312d03ab3250eefb5233d4d Mon Sep 17 00:00:00 2001 From: tkchia Date: Wed, 5 Oct 2022 18:01:43 +0000 Subject: [PATCH] [metal] Add demo of program crash reporting w/ bare metal VGA TTY --- examples/vga2.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/vga2.c diff --git a/examples/vga2.c b/examples/vga2.c new file mode 100644 index 000000000..0343cf211 --- /dev/null +++ b/examples/vga2.c @@ -0,0 +1,33 @@ +#if 0 +/*─────────────────────────────────────────────────────────────────╗ +│ To the extent possible under law, Justine Tunney has waived │ +│ all copyright and related or neighboring rights to this file, │ +│ as it is written in the following disclaimers: │ +│ • http://unlicense.org/ │ +│ • http://creativecommons.org/publicdomain/zero/1.0/ │ +╚─────────────────────────────────────────────────────────────────*/ +#endif +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/isystem/unistd.h" +#include "libc/math.h" +#include "libc/stdio/stdio.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/termios.h" + +/** + * @fileoverview Demo of program crash reporting with Bare Metal VGA TTY. + * + * make -j8 o//examples/vga2.com + * qemu-system-x86_64 -hda o//examples/vga2.com -serial stdio + */ + +STATIC_YOINK("vga_console"); +STATIC_YOINK("_idt"); + +int main(int argc, char *argv[]) { + volatile int x = 1; + volatile int y = 2; + printf("\e[92;44mHello World!\e[0m %d\n", 1 / (x + y - 3)); + for (;;); +}