0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-25 15:25:12 +00:00

(hilbert) Optimizations

This commit is contained in:
Devine Lu Linvega 2024-01-21 09:51:23 -08:00
parent 46e2374049
commit 3e1183285a

View file

@ -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