optimize evaluate
This commit is contained in:
parent
5f56e2f6bf
commit
989db7f039
43
julia.tal
43
julia.tal
|
@ -35,8 +35,7 @@
|
|||
height #10 SFT2 .Screen/height DEO2
|
||||
|
||||
( starting c values )
|
||||
#0630 ;evaluate/cx STA2
|
||||
#f5e0 ;evaluate/cy STA2
|
||||
#0630 ;evaluate/cx STA2 #f5e0 ;evaluate/cy STA2
|
||||
|
||||
;on-screen .Screen/vector DEO2
|
||||
BRK
|
||||
|
@ -48,15 +47,14 @@
|
|||
;evaluate/cx LDA2
|
||||
DUP2 #2000 LTH2 ?&upx
|
||||
DUP2 #e000 GTH2 ?&upx
|
||||
DUP2 #8000 LTH2 #ff MUL #80 ,&dx STR2
|
||||
#0000 ,&dx LDR2 SUB2 ,&dx STR2
|
||||
&upx [ LIT2 &dx 0080 ] ADD2 SWP2 STA2
|
||||
|
||||
;evaluate/cy LDA2k
|
||||
DUP2 #2000 LTH2 ?&upy
|
||||
DUP2 #e000 GTH2 ?&upy
|
||||
DUP2 #8000 LTH2 #ff MUL #80 ,&dy STR2
|
||||
#0000 ,&dy LDR2 SUB2 ,&dy STR2
|
||||
&upy [ LIT2 &dy 0080 ] ADD2 SWP2 STA2
|
||||
|
||||
BRK
|
||||
|
||||
( logical width )
|
||||
|
@ -114,27 +112,20 @@
|
|||
|
||||
( evaluate the julia function at one point )
|
||||
@evaluate ( x* y* -> count^ )
|
||||
LIT2r 2000 ( x* y* [20 00] )
|
||||
( DUP2 ,&cy STR2 OVR2 ,&cx STR2 )
|
||||
( #fa8b ,&cx STR2 #f5e7 ,&cy STR2 )
|
||||
,&y1 STR2 ,&x1 STR2 ( [20 00] ; x1<-x, y1<- y )
|
||||
&loop
|
||||
[ LIT2 &x1 $2 ] ( x1* [20 n^] )
|
||||
square DUP2 ,&x2 STR2 ( [20 n^] )
|
||||
[ LIT2 &y1 $2 ] ( x1* [20 n^] )
|
||||
square DUP2 ,&y2 STR2 ( [20 n^] )
|
||||
ADD2 #4000 GTH2 ?&end ( [20 n^] )
|
||||
,&x1 LDR2 ,&y1 LDR2 ( x1* y1* [20 n^] )
|
||||
smul2 DUP2 ADD2 ( 2x1y1* [20 n^] )
|
||||
[ LIT2 &cy $2 ] ADD2 ( 2x1y1+cy* [20 n^] )
|
||||
,&y1 STR2 ( [20 n^] ; y1<-2x1y1+cy* )
|
||||
[ LIT2 &x2 $2 ] ( x2* [20 n^] )
|
||||
[ LIT2 &y2 $2 ] SUB2 ( x2-y2* [20 n^] )
|
||||
[ LIT2 &cx $2 ] ADD2 ( x2-y2+cx* [20 n^] )
|
||||
,&x1 STR2 ( [20 n^] ; x1<-x2-y2+x* )
|
||||
INCr GTHkr STHr ?&loop ( [20 n+1*] )
|
||||
&end ( [20 count^] )
|
||||
NIPr STHr JMP2r ( count^ )
|
||||
LIT2r 20 00 ( x* y* [20 00] )
|
||||
&loop ( x1* y1* [20 n^] )
|
||||
OVR2 square STH2 ( x1* y1* [20 n^ xx1*] )
|
||||
DUP2 square STH2 ( x1* y1* [20 n^ xx1* yy1*] )
|
||||
ADD2kr STH2r ( x1* y1* xx1+yy1* [20 n^ xx1* yy1*] )
|
||||
#4000 GTH2 ?&end2 ( x1* y1* [20 n^ xx1* yy1*] )
|
||||
smul2 DUP2 ADD2 ( 2x1y1* [20 n^ xx1* yy1*] )
|
||||
LIT2 [ &cy $2 ] ADD2 ( y2=2x1y1+cy* [20 n^ xx1* yy1*] )
|
||||
SUB2r STH2r ( y2* xx1-yy1* [20 n^] )
|
||||
LIT2 [ &cx $2 ] ADD2 ( y2* x2=xx1-yy1+cx* [20 n^] )
|
||||
SWP2 INCr GTHkr STHr ?&loop ( x2* y2* [20 n+1^] )
|
||||
!&end1 ( x2* y2* [20 n+1^] )
|
||||
&end2 POP2r POP2r ( x* y* [20 count^] )
|
||||
&end1 POP2 POP2 NIPr STHr JMP2r ( count^ )
|
||||
|
||||
( is x a non-negative signed value? )
|
||||
@non-negative ( x* -> x* x>=0^ )
|
||||
|
|
Loading…
Reference in New Issue