~aleteoryx/uxn

4a19b81bacf40581b5b06f88859cc5b1cfaf06d2 — Aleteoryx 8 months ago b75b476
bfc cleanup
1 files changed, 5 insertions(+), 13 deletions(-)

M bfc.tal
M bfc.tal => bfc.tal +5 -13
@@ 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