mirror of https://github.com/falsovsky/z80.git
Novo projeto
This commit is contained in:
parent
f759db4d2c
commit
f4a32b91eb
|
|
@ -0,0 +1,31 @@
|
|||
zx-brainfuck
|
||||
=========
|
||||
|
||||
ZX-Brainfuck é um interpretador de [Brainfuck] em Assembly no ZX Spectrum.
|
||||
|
||||
Requisitos
|
||||
-----------
|
||||
|
||||
O unico realmente necessário é o Assembler, mas para ver o resultado convem tambem ter um emulador, os verdadeiros podem converter o ficheiro [tap] para audio, passar para um leitor de mp3 e ligar a um Spectrum real :-D
|
||||
|
||||
* [Pasmo] - Assembler de Z80, é Open Source e Cross Platform
|
||||
* [ZX Spin] - Emulador de ZX Spectrum para Windows que inclui um Debugger
|
||||
|
||||
Instalação
|
||||
--------------
|
||||
|
||||
```sh
|
||||
git clone https://github.com/falsovsky/z80.git
|
||||
cd z80/zx-brainfuck
|
||||
pasmo -v --tapbas --err main.asm main.tap
|
||||
```
|
||||
|
||||
Licença
|
||||
----
|
||||
|
||||
BSD
|
||||
|
||||
[Brainfuck]:http://en.wikipedia.org/wiki/Brainfuck
|
||||
[tap]:http://www.worldofspectrum.org/faq/reference/formats.htm
|
||||
[Pasmo]:http://pasmo.speccy.org/
|
||||
[ZX Spin]:http://www.zophar.net/sinclair/zx-spin.html
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
org 30000
|
||||
|
||||
tv_flag equ $5c3c ; Variavel das flags da tv
|
||||
|
||||
OP_INC_DP equ $3e
|
||||
OP_DEC_DP equ $3c
|
||||
OP_INC_VAL equ $2b
|
||||
OP_DEC_VAL equ $2d
|
||||
OP_OUT equ $2e
|
||||
OP_IN equ $2c
|
||||
OP_JMP_FWD equ $5b
|
||||
OP_JMP_BCK equ $5d
|
||||
|
||||
;brainfuck db "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.", 0
|
||||
brainfuck db "+++++++++++++++++++++++++++++++++.", 0
|
||||
memory_pos db $0,$80
|
||||
|
||||
start ; Começa em $75a2
|
||||
xor a ; O mesmo que LD a, 0
|
||||
ld (tv_flag), a ; Faz com que o rst $10 envie output pra tv
|
||||
push bc ; Guarda BC na stack
|
||||
|
||||
main
|
||||
ld hl, brainfuck
|
||||
read_bf
|
||||
ld a,(hl)
|
||||
|
||||
; EOF
|
||||
cp 0
|
||||
jr z, end_main
|
||||
|
||||
; >
|
||||
cp OP_INC_DP
|
||||
jr z, F_INC_DP
|
||||
|
||||
; <
|
||||
cp OP_DEC_DP
|
||||
jr z, F_DEC_DP
|
||||
|
||||
; +
|
||||
cp OP_INC_VAL
|
||||
jr z, F_INC_VAL
|
||||
|
||||
; +
|
||||
cp OP_DEC_VAL
|
||||
jr z, F_DEC_VAL
|
||||
|
||||
; .
|
||||
cp OP_OUT
|
||||
jr z, F_OUT
|
||||
|
||||
continue
|
||||
inc hl
|
||||
jr read_bf
|
||||
|
||||
end_main
|
||||
pop bc ; Tira o BC da stack
|
||||
ret ; Sai para o BASIC
|
||||
|
||||
F_INC_DP
|
||||
push hl
|
||||
ld hl, (memory_pos)
|
||||
inc hl
|
||||
ld (memory_pos), hl
|
||||
pop hl
|
||||
jr continue
|
||||
|
||||
F_DEC_DP
|
||||
push hl
|
||||
ld hl, (memory_pos)
|
||||
dec hl
|
||||
ld (memory_pos), hl
|
||||
pop hl
|
||||
jr continue
|
||||
|
||||
F_INC_VAL
|
||||
push hl
|
||||
ld hl, (memory_pos)
|
||||
ld a, (hl)
|
||||
inc a
|
||||
ld (hl), a
|
||||
pop hl
|
||||
jr continue
|
||||
|
||||
F_DEC_VAL
|
||||
push hl
|
||||
ld hl, (memory_pos)
|
||||
ld a, (hl)
|
||||
dec a
|
||||
ld (hl), a
|
||||
pop hl
|
||||
jr continue
|
||||
|
||||
F_OUT
|
||||
push hl
|
||||
ld hl, (memory_pos)
|
||||
ld a, (hl)
|
||||
rst $10
|
||||
ld (hl), a
|
||||
jr continue
|
||||
|
||||
end start
|
||||
Binary file not shown.
Loading…
Reference in New Issue