commit 3e1183285a94a0930c9b09fd4fa73ac3a5d24fda
parent 46e2374049552fcaabadb3e573c0527cc841bb3c
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Sun, 21 Jan 2024 09:51:23 -0800
(hilbert) Optimizations
Diffstat:
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/projects/examples/demos/hilbert.tal b/projects/examples/demos/hilbert.tal
@@ -55,8 +55,15 @@
[ LIT2 &t $2 ] DUP2 #02 SFT2 ,&t STR2
( ) DUP2 #01 SFT2 #0001 AND2 DUP2 ,&rx STR2
( ) EOR2 #0001 AND2 ,&ry STR2
- [ LIT2 &x $2 ] [ LIT2 &y $2 ] [ LIT2 &rx $2 ] [ LIT2 &ry $2 ]
- ( ) STH2kr rot
+ [ LIT2 &x $2 ] [ LIT2 &y $2 ] [ LIT2 &ry $2 ]
+ ( ) DUP2r [ LIT2r 0001 ] SUB2r
+ ( | rot )
+ ORA ?{
+ [ LIT2 &rx $2 ] #0001 NEQ2 ?{
+ ( rx-n-1 ) SWP2 STH2kr SWP2 SUB2
+ ( ry-n-1 ) SWP2 STH2kr SWP2 SUB2 }
+ ( swap ) SWP2 }
+ POP2r
( ) STH2kr ,&ry LDR2 MUL2 ADD2 ,&y STR2
( ) STH2r ,&rx LDR2 MUL2 ADD2 ,&x STR2
DUP ADD GTHk ?&l
@@ -64,13 +71,3 @@
( ) ,&x LDR2 #20 SFT2 #0020 ADD2
( ) ,&y LDR2 #20 SFT2 #0020 ADD2 JMP2r
-@rot ( x* y* rx* ry* n* -- x* y* )
- #0001 SUB2 STH2
- SWP2 ,&rx STR2
- ORA ?{
- [ LIT2 &rx $2 ] #0001 NEQ2 ?{
- ( rx-n-1 ) SWP2 STH2kr SWP2 SUB2
- ( ry-n-1 ) SWP2 STH2kr SWP2 SUB2 }
- ( swap ) SWP2 }
- POP2r JMP2r
-