/bf64

Brainfuck Interpreter for the C64

Primary LanguageAssemblyMIT LicenseMIT

A brainfuck interpreter for the c64.
All instructions are supported.
Loops cannot be nested more than 255 times.

To enter programming mode POKE 259, 00 then run the program.
In this mode simply enter each instruction (E to Exit).
To enter execute mode POKE 259, 01. The program will now run.
To enter debug print mode POKE 259, 64. The program will now be printed to the screen.
To change the starting location of the code area poke 2061 and 2062 with a new location.
To change the data location poke 2063 and 2064.

Memory locations (in hex):
inst_ptr	FB
data_ptr	FD
next_inst	FF
init_magic	100
temp	101
repl_flag	103
file_name_ptr	104
file_name_ptr_r	106
file_name_ptr_w	108
flogical_r	10A
flogical_w	10B
flogical	10C
fdevice_r	10D
fdevice_w	10E
fdevice	10F
fsecondary_r	110
fsecondary_w	111
fsecondary	112

bfcode_ptr	80D
bfdata_ptr	80F

Repl flag values:
; repl flag
; possible values:
;   00 -> code input mode
;   7th bit = 1 -> output current instruction during execution
;   6th bit = 1 -> ouput program
;   5th bit = 1 -> skip menu
;
;   the following file commands requires the user to set up file_name, flogical, fsecondary and fdevice
;   4th bit = 1 -> set file as input
;   3rd bit = 1 -> set file as output
;   2nd bit = 1 -> load prg from file to bfcode_ptr
;   1st bit = 1 -> save bfcode_ptr contents to file until \0
;
;   0th bit = 1 -> execute code



FAQ:

Q: Why though?
A: Because I can.

Q: How can I run my own program?
A: Simply assemble the rom and .incbin your bf file in the bfcode section.

Q: What is the expected test output of test.bf

A: 0 0 5 5 1 57 0 0 0