mirror of
https://github.com/samsonjs/sectorlisp.git
synced 2026-04-26 14:47:44 +00:00
shave somne bytes
This commit is contained in:
parent
da7ef2f3e7
commit
2378912709
1 changed files with 13 additions and 12 deletions
25
brainfuck.S
25
brainfuck.S
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue