mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-26 04:20:30 +00:00
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:
parent
680daf1210
commit
9e3e985ae5
276 changed files with 7026 additions and 3790 deletions
|
@ -29,4 +29,3 @@
|
|||
bcopy: jmp memmove
|
||||
.endfn bcopy,globl
|
||||
.source __FILE__
|
||||
.source __FILE__
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
/ This turns stuff like (char)0xFF into \0377. The returned
|
||||
/ string is word-encoded, e.g. '\\'|'0'<<010|'3'<<020|etc.
|
||||
/
|
||||
/ @param dil contains byte to escape
|
||||
/ @see libc/nexgen32e/cescapec.c
|
||||
cescapec:
|
||||
movzbl %dil,%edi
|
||||
lea -7(%rdi),%ecx
|
||||
cmp $85,%cl
|
||||
ja 1f
|
||||
|
@ -63,12 +65,11 @@ cescapec:
|
|||
ret
|
||||
.LQM:
|
||||
#endif
|
||||
1: movzbl %dil,%eax
|
||||
cmp $127,%eax
|
||||
1: mov %edi,%eax
|
||||
lea -0x20(%rax),%ecx
|
||||
cmp $0x5E,%ecx
|
||||
ja 2f
|
||||
ezlea kCtype,cx
|
||||
testb $16,(%rcx,%rax)
|
||||
jne 3f
|
||||
ret
|
||||
2: and $-64,%eax
|
||||
mov %edi,%ecx
|
||||
and $56,%ecx
|
||||
|
@ -78,7 +79,7 @@ cescapec:
|
|||
or %ecx,%edi
|
||||
lea (%rdi,%rax,4),%eax
|
||||
add $'0<<030|'0<<020|'0<<010|'\\,%eax
|
||||
3: ret
|
||||
ret
|
||||
.endfn cescapec,globl
|
||||
|
||||
.initro 300,_init_cescapec
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
clamp1: .leafprologue
|
||||
minps .Lmax(%rip),%xmm0
|
||||
maxps .Lmin(%rip),%xmm0
|
||||
.leafepilogue
|
||||
.endfn clamp1,globl,hidden
|
||||
|
||||
.rodata.cst16
|
||||
.Lmin: .rept 4
|
||||
.float 0
|
||||
.endr
|
||||
.Lmax: .rept 4
|
||||
.float 0.99609375
|
||||
.endr
|
||||
.source __FILE__
|
|
@ -1,101 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Returns nonzero if %dil ∈ [ \t\v\r\n].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isspace:push $1
|
||||
jmp ctypep
|
||||
.endfn isspace,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [A-Za-z].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isalpha:push $2
|
||||
jmp ctypep
|
||||
.endfn isalpha,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [0-9].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isdigit:push $4
|
||||
jmp ctypep
|
||||
.endfn isdigit,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [0-9A-Za-z].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isalnum:push $6
|
||||
jmp ctypep
|
||||
.endfn isalnum,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [0-9A-fa-f].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isxdigit:push $8
|
||||
jmp ctypep
|
||||
.endfn isxdigit,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [ -~] a.k.a. [\x20-\x7e].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isprint:push $16
|
||||
jmp ctypep
|
||||
.endfn isprint,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [a-z]
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
islower:push $32
|
||||
jmp ctypep
|
||||
.endfn islower,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [A-Z]
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isupper:push $64
|
||||
jmp ctypep
|
||||
.endfn isupper,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [ \t]
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isblank:push $-128
|
||||
/ fallthrough
|
||||
.endfn isblank,globl
|
||||
|
||||
ctypep: pop %rsi
|
||||
movzbl %dil,%edi
|
||||
ezlea kCtype,cx
|
||||
movzbl (%rcx,%rdi),%eax
|
||||
and %esi,%eax
|
||||
ret
|
||||
.endfn ctypep
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
hextoint:
|
||||
.leafprologue
|
||||
.profilable
|
||||
mov %edi,%eax
|
||||
sar $6,%eax
|
||||
and $1,%eax
|
||||
lea (%rax,%rax,8),%eax
|
||||
add %edi,%eax
|
||||
and $15,%eax
|
||||
.leafepilogue
|
||||
.endfn hextoint,globl
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iscntrl:.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
cmp $255,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdi
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rdi),%al
|
||||
shr $4,%al
|
||||
xor $1,%eax
|
||||
and $1,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iscntrl,globl
|
||||
.source __FILE__
|
|
@ -1,38 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
isgraph:.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
cmp $255,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rax
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rax),%al
|
||||
shr $4,%al
|
||||
mov %eax,%edx
|
||||
xor %eax,%eax
|
||||
cmp $32,%edi
|
||||
setne %al
|
||||
and %edx,%eax
|
||||
1: .leafepilogue
|
||||
.endfn isgraph,globl
|
||||
.source __FILE__
|
|
@ -1,41 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Checks for printable characters that aren't space / alnum.
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
ispunct:.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
cmp $255,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdi
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rdi),%dl
|
||||
test $16,%dl
|
||||
je 1f
|
||||
xor %eax,%eax
|
||||
and $7,%dl
|
||||
sete %al
|
||||
1: .leafepilogue
|
||||
.endfn ispunct,globl
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswalnum:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $6,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswalnum,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswalpha:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $2,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswalpha,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswblank:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $-128,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswblank,globl
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswcntrl:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmp $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rax),%al
|
||||
shr $4,%al
|
||||
xor $1,%eax
|
||||
and $1,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswcntrl,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswdigit:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movl %edi,%eax
|
||||
cmpl $127,%edi
|
||||
ja 1f
|
||||
subl $48,%eax
|
||||
cmpl $9,%eax
|
||||
setbe %al
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswdigit,globl
|
||||
.source __FILE__
|
|
@ -1,38 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswgraph:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movl %edi,%eax
|
||||
cmpl $127,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdx
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rdx),%dl
|
||||
shrb $4,%dl
|
||||
cmpl $32,%edi
|
||||
setne %al
|
||||
movzbl %al,%eax
|
||||
andl %edx,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswgraph,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswlower:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $32,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswlower,globl
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswprint:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movl $1,%eax
|
||||
cmpl $127,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdi
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rdi),%al
|
||||
shrb $4,%al
|
||||
andl $1,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswprint,globl
|
||||
.source __FILE__
|
|
@ -1,39 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswpunct:
|
||||
.leafprologue
|
||||
.profilable
|
||||
mov $1,%eax
|
||||
cmp $127,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdi
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rdi),%dl
|
||||
xor %eax,%eax
|
||||
test $16,%dl
|
||||
je 1f
|
||||
xor %eax,%eax
|
||||
and $7,%dl
|
||||
sete %al
|
||||
1: .leafepilogue
|
||||
.endfn iswpunct,globl
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswspace:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $1,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswspace,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswupper:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $64,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswupper,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswxdigit:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $8,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswxdigit,globl
|
||||
.source __FILE__
|
|
@ -1,63 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
.initbss 300,_init_kCtype
|
||||
kCtype: .rept 256
|
||||
.byte 0
|
||||
.endr
|
||||
.endobj kCtype,globl,hidden
|
||||
.previous
|
||||
|
||||
.initro 300,_init_kCtype
|
||||
.LkCtype.rodata:
|
||||
/ ┌─isblank
|
||||
/ │┌─isupper
|
||||
/ ││┌─islower
|
||||
/ │││┌─isprint
|
||||
/ ││││┌─isxdigit
|
||||
/ │││││┌─isdigit
|
||||
/ ││││││┌─isalpha
|
||||
/ │││││││┌─isspace
|
||||
/ ││││││││
|
||||
.byte 9, 0b00000000 # 00─08 ∅─◘
|
||||
.byte 1, 0b10000001 # 09─09 ○
|
||||
.byte 4, 0b00000001 # 0a─0d ◙─♪
|
||||
.byte 18, 0b00000000 # 0e─1f ♫─▼
|
||||
.byte 1, 0b10010001 # 20─20
|
||||
.byte 15, 0b00010000 # 21─2f !─/
|
||||
.byte 10, 0b00011100 # 30─39 0─9
|
||||
.byte 7, 0b00010000 # 3a─40 :─@
|
||||
.byte 6, 0b01011010 # 41─46 A─F
|
||||
.byte 20, 0b01010010 # 47─5a G─Z
|
||||
.byte 6, 0b00010000 # 5b─60 [─`
|
||||
.byte 6, 0b00111010 # 61─66 a─f
|
||||
.byte 20, 0b00110010 # 67─7a g─z
|
||||
.byte 4, 0b00010000 # 7b─7e {─~
|
||||
.byte 129, 0b00000000 # 7f─ff ⌂─λ
|
||||
.endobj .LkCtype.rodata # 32b ─ 13%
|
||||
.byte 0,0 # terminatr
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_kCtype
|
||||
call rldecode
|
||||
.init.end 300,_init_kCtype
|
||||
.source __FILE__
|
|
@ -1,31 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
tolower:.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmp $255,%eax
|
||||
ja 1f
|
||||
ezlea kToLower,cx
|
||||
movzbl (%rcx,%rax),%eax
|
||||
1: .leafepilogue
|
||||
.endfn tolower,globl
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
toupper:.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
cmp $255,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rax
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rax),%al
|
||||
and $32,%eax
|
||||
movzbl %al,%eax
|
||||
andn %edi,%eax,%eax # TODO(jart): FIX
|
||||
1: .leafepilogue
|
||||
.endfn toupper,globl
|
||||
.source __FILE__
|
|
@ -1,36 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
towupper:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movl %edi,%eax
|
||||
cmpl $127,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdx
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rdx),%dl
|
||||
andl $32,%edx
|
||||
movzbl %dl,%edx
|
||||
andn %edi,%edx,%eax
|
||||
1: .leafepilogue
|
||||
.endfn towupper,globl
|
||||
.source __FILE__
|
Loading…
Add table
Add a link
Reference in a new issue