Here's the loader:Mike wrote:I wrote an own implementation of SQR(X) [...] using Heron's algorithm, it is 4 times faster.
Code: Select all
1 FORT=0TO74:READA:POKE673+T,A:NEXT:POKE1,161:POKE2,2:END
2 DATA32,27,220,32,43,220,240,66,16,3,76,72,210,165,97,133,251,41,1,9,128,133,97,169,4
3 DATA133,252,162,236,160,2,32,212,219,169,188,160,217,208,18,162,241,160,2,32,212,219
4 DATA169,236,160,2,32,15,219,169,241,160,2,32,103,216,198,97,198,252,208,229,165,251
5 DATA74,105,64,133,97,96
Compare
Code: Select all
T1=TI:FORT=0TO256:A=SQR(T):NEXT:T2=TI:PRINT(T2-T1)/60:REM 11.7 sec
Code: Select all
T1=TI:FORT=0TO256:A=USR(T):NEXT:T2=TI:PRINT(T2-T1)/60:REM 2.7 sec
Code: Select all
1 FORT=0TO256
2 S=S+ABS(SQR(T)*SQR(T)-T)
3 U=U+ABS(USR(T)*USR(T)-T)
4 NEXT
5 PRINT S,U
SQR(x): ~3.6E-5
USR(x): ~1.1E-6
Greetings,
Michael
Edit: added link to commented source.