cleaning up more

This commit is contained in:
~d6 2022-01-29 23:56:57 -05:00
parent e0898742f0
commit 971148f379
1 changed files with 12 additions and 30 deletions

View File

@ -277,29 +277,23 @@
( this unrolls until it hits #ffff #ffff, which it )
( also removes from the stack. )
@unroll-stack ( -> start* end* )
( LIT 'p emit newline )
( #fedc #9876 ;emit-short JSR2 ;emit-short JSR2 space print )
;pop4 JSR2 STH2 ( r ) ( print )
#00 STH
DUP2 #0000 NEQ2 ,&loop JCN ;alloc-empty JSR2 ( print )
&loop ( r* ) ( LIT 'L emit print )
;pop4 JSR2 POP2 ( r x ) ( print )
DUP2 #ffff EQU2 ( print ) ( r x x-is-end? ) ,&done JCN
INCr
( print ) ;alloc-or JSR2 ( r|x ) ( print ) ,&loop JMP
;pop4 JSR2 STH2 ( r )
#00 STH ( count items in stack frame )
DUP2 #0000 NEQ2 ,&loop JCN ;alloc-empty JSR2
&loop ( r* )
;pop4 JSR2 POP2 ( r x )
DUP2 #ffff EQU2 ( r x x-is-end? ) ,&done JCN
INCr ( items++ )
;alloc-or JSR2 ( r|x ) ,&loop JMP
&done
( LIT 'q emit newline )
( r ffff ) ( print )
( r ffff )
POP2
STHr ,&is-or JCN
STH2r JMP2r
&is-or
POP2r
( LIT 'b emit print )
;alloc-empty JSR2 OVR2 OVR2 SWP2 ( r empty empty r )
( LIT 'c emit print )
;set-next JSR2 ( LIT 'd emit print )
( STH2 ;pop4 JSR2 POP2 STH2r ;push4 JSR2 )
;set-next JSR2
JMP2r
( add r to the top of the stock. )
@ -310,27 +304,15 @@
;pop4 JSR2 ( r0 r1 x0 x1 )
DUP2 #0000 EQU2 ( r0 r1 x0 x1 x1=0? ) ,&is-zero JCN
STH2 ROT2 STH2r ( r1 x0 r0 x1 )
( LIT 'p emit print )
;set-next JSR2 SWP2 ( x0 r1 )
( LIT 'q emit print )
;push4 JSR2
JMP2r
&is-zero POP2 POP2 ;push4 JSR2 JMP2r
( ( for nodes (other than 'or') read their 'next' pointer )
@get-next ( r* -> r.next* )
LDAk #01 NEQ ,&!1 JCN INC2 LDA2 JMP2r
&!1 LDAk #02 NEQ ,&!2 JCN INC2 LDA2 JMP2r
&!2 LDAk #03 NEQ ,&!3 JCN #0002 ADD2 LDA2 JMP2r
&!3 LDAk #04 NEQ ,&!4 JCN INC2 LDA2 JMP2r
&!4 LDAk #05 NEQ ,&!5 JCN #0003 ADD2 LDA2 JMP2r
&!5 ( either #04 (or) or ??? ) ( LIT 'q emit ) error! )
@set-next-addr ( target* addr* -> )
( LIT 'Z emit print )
LDA2k #0000 EQU2 ( target addr addr=0? ) ,&is-zero JCN
( LIT 'N emit print ) LDA2 ;set-next JSR2 JMP2r
&is-zero ( print ) ( LIT 'z emit print ) STA2 JMP2r
LDA2 ;set-next JSR2 JMP2r
&is-zero STA2 JMP2r
( set regex.next to target )
@set-next ( target* regex* -> )