uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 3bd7ea944f309cb091368ecae289b87e71320293
parent a41f1ce3e8fe166b7e8b8b06c20f6071d0398289
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Thu, 15 Feb 2024 20:47:53 -0800

(brainfuck.tal) Minor optimizations

Diffstat:
Mprojects/examples/exercises/brainfuck.tal | 40++++++++++++++++------------------------
1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/projects/examples/exercises/brainfuck.tal b/projects/examples/exercises/brainfuck.tal @@ -21,15 +21,11 @@ @<eval> ( -- ) ;on-console/ptr LDA2 ;program &while ( -- ) - LDAk [ LIT "+ ] NEQ ?{ - OVR2 STH2k LDA INC STH2r STA } - LDAk [ LIT "- ] NEQ ?{ - OVR2 STH2k LDA #01 SUB STH2r STA } + LDAk [ LIT "+ ] NEQ ?{ OVR2 STH2k LDA INC STH2r STA } + LDAk [ LIT "- ] NEQ ?{ OVR2 STH2k LDA #01 SUB STH2r STA } LDAk [ LIT "> ] NEQ ?{ SWP2 INC2 SWP2 } - LDAk [ LIT "< ] NEQ ?{ - SWP2 #0001 SUB2 SWP2 } - LDAk [ LIT ". ] NEQ ?{ - OVR2 LDA #18 DEO } + LDAk [ LIT "< ] NEQ ?{ SWP2 #0001 SUB2 SWP2 } + LDAk [ LIT ". ] NEQ ?{ OVR2 LDA #18 DEO } LDAk [ LIT "[ ] NEQ ?{ goto-next } LDAk [ LIT "] ] NEQ ?{ goto-back } INC2 LDAk ?&while @@ -37,27 +33,23 @@ @goto-next ( mem* prg* -- ) OVR2 LDA ?{ JMP2r } - ( depth ) [ LITr 00 ] INC2 + [ LITr 00 ] INC2 &loop ( -- ) - LDAk [ LIT "[ ] NEQ JMP - INCr LDAk [ LIT "] ] NEQ ?&>no-end - STHkr #00 EQU ?&end - LITr 01 SUBr &>no-end - INC2 LDAk ?&loop - &end ( depth ) - POPr JMP2r + LDAk [ LIT "[ ] NEQ ?{ INCr } + LDAk [ LIT "] ] NEQ ?{ + STHkr ?{ POPr JMP2r } + [ LITr 01 ] SUBr } + INC2 !&loop @goto-back ( mem* prg* -- ) OVR2 LDA ?{ JMP2r } - ( depth ) [ LITr 00 ] #0001 SUB2 + [ LITr 00 ] #0001 SUB2 &loop ( -- ) - LDAk [ LIT "] ] NEQ JMP - INCr LDAk [ LIT "[ ] NEQ ?&>no-end - STHkr #00 EQU ?&end - LITr 01 SUBr &>no-end - #0001 SUB2 LDAk ?&loop - &end ( depth ) - POPr JMP2r + LDAk [ LIT "] ] NEQ ?{ INCr } + LDAk [ LIT "[ ] NEQ ?{ + STHkr ?{ POPr JMP2r } + [ LITr 01 ] SUBr } + #0001 SUB2 !&loop @program