From 4a19b81bacf40581b5b06f88859cc5b1cfaf06d2 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Mon, 24 Mar 2025 23:09:48 -0400 Subject: [PATCH] bfc cleanup --- bfc.tal | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/bfc.tal b/bfc.tal index 31f73e682f4df5fcf9fdc2f4eaf28fce933cbc26..cb0fc832561477628f38f5998f52c73cb810fe53 100644 --- a/bfc.tal +++ b/bfc.tal @@ -1,16 +1,6 @@ |0 @System &pad $e &debug $1 &state $1 |10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 -( program structure: - 0x00 .. 0xff = brainfuck tape - 0x0100..0xffff = program rom - - stack contents between instructions: ( addr val ) - return stack always stores 0x01 - - [ +++ ] => @l0000 DUP #00 EQU ?{ INC INC INC !l0000 } -) - %dbg { LIT2 01 -System/debug DEO } |100 @@ -21,12 +11,14 @@ BRK @on-console ( -> ) - .Console/type DEI #04 NEQ ?{ + .Console/type DEI #04 NEQ ?{ ( EOF handling ) Loops/not-empty? ?{ ;errs/mismatch errs/die } } .Console/read DEI + DUP [ LIT "[ ] NEQ ?{ Loops/open } DUP [ LIT "] ] NEQ ?{ Loops/close } + Code/emit BRK @@ -88,13 +80,13 @@ @Loops/open ( -- ) [ LIT2 &ctr $2 ] INC2k ,/ctr STR2 ( get next loop idx ) - DUP2 /print-label ( "@lXXXX" ) + DUP2 /print-label [ LIT2 &ptr =/stack ] INC2k INC2 ,/ptr STR2 ( increment stack pointer ) STA2 ( store idx ) JMP2r &close ( -- ) - ,/ptr LDR2 #0002 SUB2 + ,/ptr LDR2 #0002 SUB2 ( decrement stack pointer ) LDA2k INC2k ORA ?{ ;errs/underflow errs/die } /print-jmi ,/ptr STR2