(brainfuck.tal) Minor optimizations
This commit is contained in:
parent
a41f1ce3e8
commit
3bd7ea944f
|
@ -21,15 +21,11 @@
|
||||||
@<eval> ( -- )
|
@<eval> ( -- )
|
||||||
;on-console/ptr LDA2 ;program
|
;on-console/ptr LDA2 ;program
|
||||||
&while ( -- )
|
&while ( -- )
|
||||||
LDAk [ LIT "+ ] NEQ ?{
|
LDAk [ LIT "+ ] NEQ ?{ OVR2 STH2k LDA INC STH2r STA }
|
||||||
OVR2 STH2k LDA INC STH2r STA }
|
LDAk [ LIT "- ] NEQ ?{ OVR2 STH2k LDA #01 SUB STH2r STA }
|
||||||
LDAk [ LIT "- ] NEQ ?{
|
|
||||||
OVR2 STH2k LDA #01 SUB STH2r STA }
|
|
||||||
LDAk [ LIT "> ] NEQ ?{ SWP2 INC2 SWP2 }
|
LDAk [ LIT "> ] NEQ ?{ SWP2 INC2 SWP2 }
|
||||||
LDAk [ LIT "< ] NEQ ?{
|
LDAk [ LIT "< ] NEQ ?{ SWP2 #0001 SUB2 SWP2 }
|
||||||
SWP2 #0001 SUB2 SWP2 }
|
LDAk [ LIT ". ] NEQ ?{ OVR2 LDA #18 DEO }
|
||||||
LDAk [ LIT ". ] NEQ ?{
|
|
||||||
OVR2 LDA #18 DEO }
|
|
||||||
LDAk [ LIT "[ ] NEQ ?{ goto-next }
|
LDAk [ LIT "[ ] NEQ ?{ goto-next }
|
||||||
LDAk [ LIT "] ] NEQ ?{ goto-back }
|
LDAk [ LIT "] ] NEQ ?{ goto-back }
|
||||||
INC2 LDAk ?&while
|
INC2 LDAk ?&while
|
||||||
|
@ -37,27 +33,23 @@
|
||||||
|
|
||||||
@goto-next ( mem* prg* -- )
|
@goto-next ( mem* prg* -- )
|
||||||
OVR2 LDA ?{ JMP2r }
|
OVR2 LDA ?{ JMP2r }
|
||||||
( depth ) [ LITr 00 ] INC2
|
[ LITr 00 ] INC2
|
||||||
&loop ( -- )
|
&loop ( -- )
|
||||||
LDAk [ LIT "[ ] NEQ JMP
|
LDAk [ LIT "[ ] NEQ ?{ INCr }
|
||||||
INCr LDAk [ LIT "] ] NEQ ?&>no-end
|
LDAk [ LIT "] ] NEQ ?{
|
||||||
STHkr #00 EQU ?&end
|
STHkr ?{ POPr JMP2r }
|
||||||
LITr 01 SUBr &>no-end
|
[ LITr 01 ] SUBr }
|
||||||
INC2 LDAk ?&loop
|
INC2 !&loop
|
||||||
&end ( depth )
|
|
||||||
POPr JMP2r
|
|
||||||
|
|
||||||
@goto-back ( mem* prg* -- )
|
@goto-back ( mem* prg* -- )
|
||||||
OVR2 LDA ?{ JMP2r }
|
OVR2 LDA ?{ JMP2r }
|
||||||
( depth ) [ LITr 00 ] #0001 SUB2
|
[ LITr 00 ] #0001 SUB2
|
||||||
&loop ( -- )
|
&loop ( -- )
|
||||||
LDAk [ LIT "] ] NEQ JMP
|
LDAk [ LIT "] ] NEQ ?{ INCr }
|
||||||
INCr LDAk [ LIT "[ ] NEQ ?&>no-end
|
LDAk [ LIT "[ ] NEQ ?{
|
||||||
STHkr #00 EQU ?&end
|
STHkr ?{ POPr JMP2r }
|
||||||
LITr 01 SUBr &>no-end
|
[ LITr 01 ] SUBr }
|
||||||
#0001 SUB2 LDAk ?&loop
|
#0001 SUB2 !&loop
|
||||||
&end ( depth )
|
|
||||||
POPr JMP2r
|
|
||||||
|
|
||||||
@program
|
@program
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue