~rabbits/drifblim

61307385389dde1dda17fbeab20fab7ac3741ef8 — Devine Lu Linvega a month ago 5bad100
Catch writing in zero-page
2 files changed, 8 insertions(+), 2 deletions(-)

M examples/error.tal
M src/drifblim.tal
M examples/error.tal => examples/error.tal +2 -0
@@ 1,3 1,5 @@
|0020 "zero-page-writing $1

|0100 

	( invalid paddings )

M src/drifblim.tal => src/drifblim.tal +6 -2
@@ 159,14 159,17 @@ JMP2r

@write ( byte -- )

	,&head LDR2 #0100 LTH2 ?&err

	[ LIT &skip 01 ] ?&no-write
		DUP ;rom ;write/head LDA2 ADD2 STA
		DUP #00 EQU ?&no-write
			[ LIT2 &head 0100 ] ;assemble/length STA2
		&no-write
	POP
	( move )
	#0001 !move-head

#0001 !move-head
	&err POP ;token ;err/zeropage !crash

(
@|helpers )


@@ 417,6 420,7 @@ JMP2r
	&limit "Labels-limit $1
	&invalid "Invalid $1
	&mode "Mode $1
	&zeropage "Zero-page $1

@opcodes
	"LIT "INC "POP "NIP "SWP "ROT "DUP "OVR