mirror of
https://github.com/samsonjs/sectorlisp.git
synced 2026-04-27 14:57:41 +00:00
Fix things
This commit is contained in:
parent
8ad3d4822f
commit
3eb0db0a7a
1 changed files with 35 additions and 19 deletions
54
brainfuck.S
54
brainfuck.S
|
|
@ -18,25 +18,28 @@
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
|
||||||
// compliant brainfuck in 82 bytes
|
// compliant brainf*#k in 99 bytes
|
||||||
// boots from bios on pc w/ 128kb+
|
// ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++
|
||||||
|
// ..+++.>>.<-.<.+++.------.--------.>>+.>++.[]$
|
||||||
|
|
||||||
.code16
|
.code16
|
||||||
.globl _start
|
.globl _start
|
||||||
_start: mov $0x10000>>4,%di
|
_start: mov $0x7e00,%di
|
||||||
push %di
|
push %di
|
||||||
pop %ds
|
Load: xor %ax,%ax
|
||||||
push %di
|
|
||||||
pop %es
|
|
||||||
mov %si,%dx
|
|
||||||
Brain: xor %ax,%ax
|
|
||||||
cmp %dx,%si
|
|
||||||
jb Fuck
|
|
||||||
int $0x16
|
int $0x16
|
||||||
mov %al,(%si)
|
stosb
|
||||||
inc %dx
|
cmp $'[',%al
|
||||||
Fuck: lodsb
|
je Lsb
|
||||||
|
cmp $']',%al
|
||||||
|
je Rsb
|
||||||
|
cmp $'$',%al
|
||||||
|
jne Load
|
||||||
|
pop %si
|
||||||
|
Brain: lodsb
|
||||||
cbw
|
cbw
|
||||||
|
mov $0x0e,%bh
|
||||||
|
mov (%di),%bl
|
||||||
sub $'+',%al
|
sub $'+',%al
|
||||||
jz Inc # + 43
|
jz Inc # + 43
|
||||||
dec %ax
|
dec %ax
|
||||||
|
|
@ -53,12 +56,14 @@ Fuck: lodsb
|
||||||
je Loop # ] 91 45
|
je Loop # ] 91 45
|
||||||
cmp $'['-'.',%al
|
cmp $'['-'.',%al
|
||||||
jne Brain # [ 93 47
|
jne Brain # [ 93 47
|
||||||
Do: push %si
|
Do: cmp $1,%bl
|
||||||
Loop: pop %ax
|
sbb %bl,%bl
|
||||||
cmpb %ah,(%di)
|
Loop: test %bl,%bl
|
||||||
|
lodsw
|
||||||
jz Brain
|
jz Brain
|
||||||
push %ax
|
|
||||||
xchg %ax,%si
|
xchg %ax,%si
|
||||||
|
inc %si
|
||||||
|
inc %si
|
||||||
.byte 0x80
|
.byte 0x80
|
||||||
Inc: incb (%di)
|
Inc: incb (%di)
|
||||||
jmp Brain
|
jmp Brain
|
||||||
|
|
@ -70,7 +75,18 @@ Dec: decb (%di)
|
||||||
.byte 0x3C
|
.byte 0x3C
|
||||||
Right: inc %di
|
Right: inc %di
|
||||||
.byte 0x84
|
.byte 0x84
|
||||||
Put: mov $0x0e,%ah
|
Put: xchg %bx,%ax
|
||||||
mov (%di),%al
|
|
||||||
int $0x10
|
int $0x10
|
||||||
jmp Brain
|
jmp Brain
|
||||||
|
Rsb: pop %si
|
||||||
|
mov %di,(%si)
|
||||||
|
xchg %si,%ax
|
||||||
|
.byte 0x3c
|
||||||
|
Lsb: push %di
|
||||||
|
stosw
|
||||||
|
jmp Load
|
||||||
|
|
||||||
|
Sig: .fill 510 - (. - _start), 1, 0xce
|
||||||
|
.word 0xAA55
|
||||||
|
.type Sig,@object
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue