mirror of
https://github.com/samsonjs/sectorlisp.git
synced 2026-04-27 14:57:41 +00:00
Reduce Brainfuck to 82 bytes
This commit is contained in:
parent
2378912709
commit
aa43e770c3
1 changed files with 16 additions and 16 deletions
32
brainfuck.S
32
brainfuck.S
|
|
@ -18,7 +18,7 @@
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
|
||||||
// compliant brainfuck in 83 bytes
|
// compliant brainfuck in 82 bytes
|
||||||
// boots from bios on pc w/ 128kb+
|
// boots from bios on pc w/ 128kb+
|
||||||
|
|
||||||
.code16
|
.code16
|
||||||
|
|
@ -37,30 +37,34 @@ Brain: xor %ax,%ax
|
||||||
inc %dx
|
inc %dx
|
||||||
Fuck: lodsb
|
Fuck: lodsb
|
||||||
cbw
|
cbw
|
||||||
cmp $'>',%al
|
|
||||||
je Right
|
|
||||||
cmp $'<',%al
|
|
||||||
je Left
|
|
||||||
sub $'+',%al
|
sub $'+',%al
|
||||||
je Inc
|
jz Inc # + 43
|
||||||
dec %ax
|
dec %ax
|
||||||
je Get
|
jz Get # , 44
|
||||||
dec %ax
|
dec %ax
|
||||||
je Dec
|
jz Dec # - 45
|
||||||
dec %ax
|
dec %ax
|
||||||
je Put
|
jz Put # . 46
|
||||||
|
cmp $'>'-'.',%al
|
||||||
|
je Right # > 60 14
|
||||||
|
cmp $'<'-'.',%al
|
||||||
|
je Left # < 62 16
|
||||||
cmp $']'-'.',%al
|
cmp $']'-'.',%al
|
||||||
je Loop
|
je Loop # ] 91 45
|
||||||
cmp $'['-'.',%al
|
cmp $'['-'.',%al
|
||||||
jne Brain
|
jne Brain # [ 93 47
|
||||||
Do: push %si
|
Do: push %si
|
||||||
Loop: pop %ax
|
Loop: pop %ax
|
||||||
cmpb %ah,(%di)
|
cmpb %ah,(%di)
|
||||||
jz Brain
|
jz Brain
|
||||||
push %ax
|
push %ax
|
||||||
xchg %ax,%si
|
xchg %ax,%si
|
||||||
jmp Brain
|
.byte 0x80
|
||||||
Inc: incb (%di)
|
Inc: incb (%di)
|
||||||
|
jmp Brain
|
||||||
|
Get: int $0x16
|
||||||
|
stosb
|
||||||
|
Left: dec %di
|
||||||
.byte 0x80
|
.byte 0x80
|
||||||
Dec: decb (%di)
|
Dec: decb (%di)
|
||||||
.byte 0x3C
|
.byte 0x3C
|
||||||
|
|
@ -70,7 +74,3 @@ Put: mov $0x0e,%ah
|
||||||
mov (%di),%al
|
mov (%di),%al
|
||||||
int $0x10
|
int $0x10
|
||||||
jmp Brain
|
jmp Brain
|
||||||
Get: int $0x16
|
|
||||||
stosb
|
|
||||||
Left: dec %di
|
|
||||||
jmp Brain
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue