~aleteoryx/uxn

e998c9e7f9246ac53d66fb08da4eab71a50c2cfa — Aleteoryx 8 months ago 4a19b81
stopgap
1 files changed, 19 insertions(+), 14 deletions(-)

M bfc.tal
M bfc.tal => bfc.tal +19 -14
@@ 18,6 18,7 @@

	DUP [ LIT "[ ] NEQ ?{ Loops/open }
	DUP [ LIT "] ] NEQ ?{ Loops/close }
	DUP [ LIT ", ] NEQ ?{ Labels/get POP2 }

	Code/emit
	BRK


@@ 52,7 53,7 @@
&next	"OVR 20 "STZ 20 "INC 20 "LDZk 0a
&prev	"OVR 20 "STZ 20 "STHrk 20 "SUB 20 "LDZk 0a
&out	"DUP 20 "#18 20 "DEO 0a
&in	"POP 20 ";{ 20 "#10 20 "DEO2 20 "BRK 20 "} 20 "#12 20 "DEI 0a
&in	20 "POP 20 ";{ 20 "#10 20 "DEO2 20 "BRK 20 "} 20 "#12 20 "DEI 0a
&open	20 "DUP 20 "#00 20 "EQU 20 "?{ 0a
&close	20 "} 0a



@@ 78,9 79,23 @@
	POP2 JMP2r


@Loops/open ( -- )
@Labels/get ( -- label* )
	[ LIT2 &ctr $2 ] INC2k ,/ctr STR2 ( get next loop idx )
	DUP2 /print-label
	DUP2
	( >> )
&print-label ( n* -- )
	[ LIT2 "@ -Console/write ] DEO
	!/print-name
&print-jmi ( n* -- )
	[ LIT2 "! -Console/write ] DEO
	( >> )
&print-name ( n* -- )
	[ LIT2 "l -Console/write ] DEO
	putn2
	JMP2r

@Loops/open ( -- )
	Labels/get
	[ LIT2 &ptr =/stack ] INC2k INC2 ,/ptr STR2 ( increment stack pointer )
	STA2 ( store idx )
	JMP2r


@@ 88,7 103,7 @@
&close ( -- )
	,/ptr LDR2 #0002 SUB2 ( decrement stack pointer )
	LDA2k INC2k ORA ?{ ;errs/underflow errs/die }
	/print-jmi
	Labels/print-jmi
	,/ptr STR2
	JMP2r



@@ 96,16 111,6 @@
	,/ptr LDR2 ;/stack EQU2
	JMP2r

&print-label ( n* -- )
	[ LIT2 "@ -Console/write ] DEO
	!/print-name
&print-jmi ( n* -- )
	[ LIT2 "! -Console/write ] DEO
	( >> )
&print-name ( n* -- )
	[ LIT2 "l -Console/write ] DEO
	putn2
	JMP2r


@errs/die ( addr* -- )