immediate instructions

This commit is contained in:
~d6 2025-02-02 23:46:58 -05:00
parent 4c213b2a25
commit 8832be799d
1 changed files with 12 additions and 12 deletions

View File

@ -71,7 +71,7 @@
SWP emit-byte emit-byte JMP2r
@emit-byte ( byte^ -- )
DUP #04 SFT ,&hex JSR #0f AND ,&hex JMP
DUP #04 SFT ,&hex JSR #0f AND !&hex
&hex #30 ADD DUP #39 GTH #27 MUL ADD emit
JMP2r
@ -83,32 +83,32 @@
sp LIT "n emit LIT "= emit ;stack-pos LDA2 ;stack-bot SUB2 #0004 DIV2 emit-short LIT ": emit
;stack-bot
&loop
DUP2 ;stack-pos LDA2 LTH2 ,&ok JCN
DUP2 ;stack-pos LDA2 LTH2 ?&ok
POP2 nl JMP2r
&ok
sp LDA2k emit-short
#0002 ADD2 ,&loop JMP
#0002 ADD2 !&loop
( emit n bytes from the given address )
@emit-n ( addr* count^ -> addr2* )
DUP #00 GTH ( addr count count>0? ) ,&ok JCN ( addr count ) POP nl JMP2r
DUP #00 GTH ( addr count count>0? ) ?&ok ( addr count ) POP nl JMP2r
&ok
STH ( addr [count] ) sp LDAk emit-byte INC2 ( addr+1 [count] )
STHr #01 SUB ( addr+1 count-1 )
;emit-n JMP2
!emit-n
( emit the arena, with one line per node )
( parses node type, since node size is dynamic (3-5). )
@emit-arena ( -> )
;arena-bot
&loop
DUP2 ;arena-pos LDA2 LTH2 ,&ok JCN POP2 JMP2r
DUP2 ;arena-pos LDA2 LTH2 ?&ok POP2 JMP2r
&ok
DUP2 emit-short
LIT ": emit sp
LDAk #01 NEQ ,&!1 JCN #03 emit-n ,&loop JMP
&!1 LDAk #02 NEQ ,&!2 JCN #03 emit-n ,&loop JMP
&!2 LDAk #03 NEQ ,&!3 JCN #04 emit-n ,&loop JMP
&!3 LDAk #04 NEQ ,&!4 JCN #05 emit-n ,&loop JMP
&!4 LDAk #05 NEQ ,&!5 JCN #05 emit-n ,&loop JMP
&!5 ;unknown-node-type errorm
LDAk #01 NEQ ?&c1 #03 emit-n !&loop
&c1 LDAk #02 NEQ ?&c2 #03 emit-n !&loop
&c2 LDAk #03 NEQ ?&c3 #04 emit-n !&loop
&c3 LDAk #04 NEQ ?&c4 #05 emit-n !&loop
&c4 LDAk #05 NEQ ?&c5 #05 emit-n !&loop
&c5 ;unknown-node-type errorm