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

@ -90,7 +90,6 @@ systemfive:
.quad 0
.endobj systemfive,globl,hidden
.previous
.Lanchorpoint:
systemfive.linux:
movswl %ax,%eax
@ -104,24 +103,31 @@ systemfive.linux:
cmp $-4095,%rax
jae systemfive.error
ret
.endfn systemfive.linux,globl,hidden
systemfive.error:
neg %eax
/ 𝑠𝑙𝑖𝑑𝑒
.endfn systemfive.error
systemfive.errno:
mov %eax,errno(%rip)
pushpop -1,%rax
push $-1
pop %rax
stc
ret
.endfn systemfive.errno
systemfive.enosys:
mov ENOSYS(%rip),%eax
jmp systemfive.errno
.endfn systemfive.enosys
systemfive.openbsd:
shr $48,%rax
jmp systemfive.bsd
.endfn systemfive.openbsd,globl,hidden
systemfive.freebsd:
shr $32,%rax
movzwl %ax,%eax
/ 𝑠𝑙𝑖𝑑𝑒
.endfn systemfive.freebsd,globl,hidden
systemfive.bsd:
cmp $0xfff,%ax
jae systemfive.enosys
@ -132,26 +138,21 @@ systemfive.bsd:
pop %rbp
jc systemfive.errno
ret
.endfn systemfive.bsd
systemfive.xnu:
/ Do this
/ 0x35022721530005
/
/
/ 0x00000002000153
/ do this to rax
/ 0x????????2153????
/
/
/ 0x0000000002000153
mov %eax,%r11d
shr $0x10,%eax
and $0xfff,%eax
shr $0x1c,%r11d
shl $0x18,%r11d
shr $4*7,%r11d
shl $4*6,%r11d
shl $4*1,%eax
shr $4*5,%eax
or %r11d,%eax
jmp systemfive.bsd
.endfn systemfive.errno,globl,hidden
.endfn systemfive.error,globl,hidden
.endfn systemfive.enosys,globl,hidden
.endfn systemfive.xnu,globl,hidden
.endfn systemfive.freebsd,globl,hidden
.endfn systemfive.openbsd,globl,hidden
.endfn systemfive.linux,globl,hidden
.previous
/ Initializes System Five system call support.