shave somne bytes

This commit is contained in:
Peter Ferrie 2021-12-02 15:23:46 -08:00
parent da7ef2f3e7
commit 2378912709

View file

@ -2,6 +2,7 @@
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2021 Justine Alexandra Roberts Tunney Copyright 2021 Justine Alexandra Roberts Tunney
Some size optimisations by Peter Ferrie
Permission to use, copy, modify, and/or distribute this software for Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the any purpose with or without fee is hereby granted, provided that the
@ -17,7 +18,7 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
// compliant brainfuck in 87 bytes // compliant brainfuck in 83 bytes
// boots from bios on pc w/ 128kb+ // boots from bios on pc w/ 128kb+
.code16 .code16
@ -35,21 +36,22 @@ Brain: xor %ax,%ax
mov %al,(%si) mov %al,(%si)
inc %dx inc %dx
Fuck: lodsb Fuck: lodsb
cbw
cmp $'>',%al cmp $'>',%al
je Right je Right
cmp $'<',%al cmp $'<',%al
je Left je Left
cmp $'+',%al sub $'+',%al
je Inc je Inc
cmp $'-',%al dec %ax
je Dec
cmp $'.',%al
je Put
cmp $',',%al
je Get je Get
cmp $']',%al dec %ax
je Dec
dec %ax
je Put
cmp $']'-'.',%al
je Loop je Loop
cmp $'[',%al cmp $'['-'.',%al
jne Brain jne Brain
Do: push %si Do: push %si
Loop: pop %ax Loop: pop %ax
@ -59,8 +61,6 @@ Loop: pop %ax
xchg %ax,%si xchg %ax,%si
jmp Brain jmp Brain
Inc: incb (%di) Inc: incb (%di)
.byte 0x3C
Left: dec %di
.byte 0x80 .byte 0x80
Dec: decb (%di) Dec: decb (%di)
.byte 0x3C .byte 0x3C
@ -71,5 +71,6 @@ Put: mov $0x0e,%ah
int $0x10 int $0x10
jmp Brain jmp Brain
Get: int $0x16 Get: int $0x16
mov %al,(%di) stosb
Left: dec %di
jmp Brain jmp Brain