( usage: cat program.bf | uxncli brainfuck.rom ) |10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 |0100 @on-reset ( -> ) ;on-console .Console/vector DEO2 BRK @on-console ( -> ) .Console/read DEI DUP #20 GTH ?{ POP #0000 .Console/vector DEO2 #010f DEO BRK } [ LIT2 &ptr =program ] INC2k ,&ptr STR2 STA BRK @ ( -- ) [ LIT2r =on-console/ptr ] LDA2r ;program &while ( -- ) LDAk [ LIT "+ ] NEQ ?{ LDAkr STHr INC STH2kr STA } LDAk [ LIT "- ] NEQ ?{ LDAkr STHr #01 SUB STH2kr STA } LDAk [ LIT "> ] NEQ ?{ INC2r } LDAk [ LIT "< ] NEQ ?{ [ LIT2r 0001 ] SUB2r } LDAk [ LIT ". ] NEQ ?{ LDAkr [ LITr 18 ] DEOr } LDAk [ LIT "[ ] NEQ ?{ goto-next } LDAk [ LIT "] ] NEQ ?{ goto-back } INC2 LDAk ?&while POP2 POP2r JMP2r @goto-next ( `mem* prg* -- ) OVR2r LDAr STHr ?{ JMP2r } [ LITr 00 ] INC2 &loop ( -- ) LDAk [ LIT "[ ] NEQ ?{ INCr } LDAk [ LIT "] ] NEQ ?{ STHkr ?{ POPr JMP2r } [ LITr 01 ] SUBr } INC2 !&loop @goto-back ( `mem* prg* -- ) OVR2r LDAr STHr ?{ JMP2r } [ LITr 00 ] #0001 SUB2 &loop ( -- ) LDAk [ LIT "] ] NEQ ?{ INCr } LDAk [ LIT "[ ] NEQ ?{ STHkr ?{ POPr JMP2r } [ LITr 01 ] SUBr } #0001 SUB2 !&loop @program