Make terminal ui binaries work well everywhere

Here's some screenshots of an emulator tui program that was compiled on
Linux, then scp'd it to Windows, Mac, and FreeBSD.

https://justine.storage.googleapis.com/blinkenlights-cmdexe.png
https://justine.storage.googleapis.com/blinkenlights-imac.png
https://justine.storage.googleapis.com/blinkenlights-freebsd.png
https://justine.storage.googleapis.com/blinkenlights-lisp.png

How is this even possible that we have a nontrivial ui binary that just
works on Mac, Windows, Linux, and BSD? Surely a first ever achievement.

Fixed many bugs. Bootstrapped John McCarthy's metacircular evaluator on
bare metal in half the size of Altair BASIC (about 2.5kb) and ran it in
emulator for fun and profit.
This commit is contained in:
Justine Tunney
2020-10-10 21:18:53 -07:00
parent 680daf1210
commit 9e3e985ae5
276 changed files with 7026 additions and 3790 deletions

View File

@@ -57,42 +57,14 @@ _executive:
ud2
#ifdef __PG__
/ Enables plaintext function tracing if --ftrace flag passed.
/
/ The --ftrace CLI arg is removed before main() is called. This
/ code is intended for diagnostic purposes and assumes binaries
/ are trustworthy and stack isn't corrupted. Logging plain text
/ allows program structure to easily be visualized and hotspots
/ identified w/ sed | sort | uniq -c | sort. A compressed trace
/ can be made by appending --ftrace 2>&1 | gzip -4 >trace.gz to
/ the CLI arguments. Have fun.
/
/ @see libc/runtime/ftrace.greg.c
/ @see libc/crt/crt.S
.init.start 800,_init_ftrace
push %rdi
push %rsi
xor %edx,%edx
loadstr "--ftrace",di
xor %ecx,%ecx
0: inc %ecx
mov (%r13,%rcx,8),%rsi
test %edx,%edx
jz 1f
mov %rsi,-8(%r13,%rcx,8)
1: test %rsi,%rsi
jz 2f
test %edx,%edx
jnz 0b
call tinystrcmp
test %eax,%eax
setz %dl
jmp 0b
2: sub %rdx,%r12
test %edx,%edx
jz 2f
mov %r12d,%edi
mov %r13,%rsi
call ftrace_init
2: pop %rsi
mov %eax,%r12d
pop %rsi
pop %rdi
.init.end 800,_init_ftrace
#endif /* -pg */
#endif