~rabbits/uxnrea

645e1299320f86070176f6f3196df660378d8ca9 — Devine Lu Linvega 1 year, 4 months ago 6916deb master
Output to file
3 files changed, 42 insertions(+), 55 deletions(-)

M build.sh
D etc/hello-dis.tal
M src/uxnrea.tal
M build.sh => build.sh +1 -1
@@ 21,7 21,7 @@ case "$*" in *--save*) cp $dst $roms_dir ;; esac

# hello.tal -> hello.rom -> hello.tal
$asm etc/hello.tal bin/hello.rom
$emu $dst bin/hello.rom bin/hello.dis.tal # > etc/hello-dis.tal
$emu $dst bin/hello.rom bin/hello.dis.tal
# $asm etc/hello-dis.tal bin/hello.rom
# $emu $dst bin/hello.rom bin/hello.dis.tal > etc/hello-dis.tal


D etc/hello-dis.tal => etc/hello-dis.tal +0 -34
@@ 1,34 0,0 @@
;hello-word-txt print-text BRK
	
@print-text
	LDAk #00 EQU ?&skip
	&while
		LDAk #18 DEO
		INC2 LDAk ?&while
	&skip
		POP2 JMP2r
		
@hello-word-txt
	"Hello 20 "World! 00 

@somefile-bin
	[ 7364 616a 7364 6a68 6173 6400  ]

@print
	&short
		SWP print/byte 
	&byte
		DUP #04 SFT print/char 
	&char
		#0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
		JMP2r
		
@dict
	&value1-txt
		"hey 00 
	&value2-txt
		"foo 00 
	&value3-txt
		"bar



M src/uxnrea.tal => src/uxnrea.tal +41 -20
@@ 195,9 195,9 @@ JMP2r
&do-lb ( c -- )

	POP emit-lb
	#0918 DEO
	#09 emit/force
	.nested LDZ #00 EQU ?&no-pad
		#0918 DEO
		#09 emit/force
		&no-pad

JMP2r


@@ 235,7 235,7 @@ JMP2r

	POP
	LIT "# emit
	read-byte phex/b
	read-byte emit-byte
	#20 emit

JMP2r


@@ 248,7 248,7 @@ JMP2r
			LIT "; emit print-ref #20 emit JMP2r
		&no-label
	LIT "# emit
	SWP phex #20 emit
	SWP emit-short #20 emit

JMP2r



@@ 273,7 273,7 @@ JMP2r
		&no-rune
	DUP is-ascii ?&ascii
		#20 emit
		DUP phex/b #20 emit ,&last STR JMP2r
		DUP emit-byte #20 emit ,&last STR JMP2r
		&ascii

	DUP emit


@@ 288,7 288,7 @@ JMP2r
	&s
		;&b .File1/read DEO2
		.File1/success DEI2 ORA ?&ok !&end &ok
		[ LIT &b $1 ] phex/b
		[ LIT &b $1 ] emit-byte
		STHkr #01 AND #00 EQU ?&no-space
			#20 emit
			&no-space


@@ 306,13 306,13 @@ JMP2r

@print-label ( addr* -- )

	#0a emit-once #0a18 DEO
	#0a emit-once #09 emit/force
	LIT "@ emit
	INC2k INC2 pstr
	INC2k INC2 emit-str

	.addr LDZ2 find-definition DUP2 #ffff EQU2 ?&no-def
		#20 emit
		INC2k INC2 pstr
		INC2k INC2 emit-str
		&no-def POP2

	.addr LDZ2 find-sublabel #ffff NEQ2 ?&no-lb


@@ 325,9 325,9 @@ JMP2r

@print-sublabel ( addr* -- )

	#0a emit-once #0918 DEO
	#0a emit-once #09 emit/force
	LIT "& emit
	INC2k INC2 LIT "/ cndx INC2 pstr emit-lb
	INC2k INC2 LIT "/ cndx INC2 emit-str emit-lb
	#09 emit #09 emit
	handle-style



@@ 335,7 335,7 @@ JMP2r

@print-absref ( addr* -- )

	find-anylabel INC2 INC2 pstr
	find-anylabel INC2 INC2 emit-str

JMP2r



@@ 344,9 344,9 @@ JMP2r
	find-anylabel INC2 INC2
	DUP2 LIT "/ cndx #ffff EQU2 ?&no-sublabel
		DUP2 .scope LDZ2 INC2 INC2 SWP2 sseg #00 EQU ?&no-sublabel
			LIT "/ cndx INC2 LIT "& emit pstr JMP2r
			LIT "/ cndx INC2 LIT "& emit emit-str JMP2r
		&no-sublabel
	pstr
	emit-str

JMP2r



@@ 356,7 356,7 @@ JMP2r
	DUP #40 EQU ?&jmi
	DUP #60 EQU ?&jsi
	DUP #00 EQU ?&brk
	#00 OVR #1f AND #20 SFT2 ;opcodes ADD2 pstr
	#00 OVR #1f AND #20 SFT2 ;opcodes ADD2 emit-str
	DUP #20 AND #00 EQU ?&no-2 LIT "2 emit &no-2
	DUP #1f AND #00 EQU ?&no-k
	DUP #80 AND #00 EQU ?&no-k LIT "k emit &no-k


@@ 364,10 364,10 @@ JMP2r
	POP

JMP2r
	&brk POP ;opcodes/brk !pstr
	&jmi POP ;opcodes/jmi !pstr
	&jci POP ;opcodes/jci !pstr
	&jsi POP ;opcodes/jsi !pstr
	&brk POP ;opcodes/brk !emit-str
	&jmi POP ;opcodes/jmi !emit-str
	&jci POP ;opcodes/jci !emit-str
	&jsi POP ;opcodes/jsi !emit-str

@emit-lb ( -- )



@@ 386,12 386,33 @@ JMP2r

JMP2r

@emit-str ( str* -- )

	LDAk ?&w POP2 JMP2r
	&w
		LDAk emit
		INC2 LDAk ?&w
	POP2

JMP2r

@emit-short ( short* -- )
	SWP emit-byte
@emit-byte ( byte -- )
		DUP #04 SFT emit-hex
@emit-hex ( char -- )
		#0f AND DUP #09 GTH #27 MUL ADD #30 ADD emit
JMP2r

@emit ( byte -- )

	DUP .last STZ
	#18 DEO
	&force
	,&b STR
	;&b .File2/write DEO2

JMP2r
	&b $1

(
@|utils )