{ Subroutine to compute the square root of x using the 1/sqrt(x) approximation. X = sqrt(Y) = Y/sqrt(Y) Calling Registers F0 = Y Input Value F8 = 3.0 F1 = 0.5 Result Registers F0 = sqrt(Y) Altered Registers F0, F4, F12 Computation Time 14 Cycles Version 0.02 7/6/90 Gordon A. Sterling } #include "asm_glob.h" .SEGMENT/PM Assembly_Library_Code_Space; .PRECISION=MACHINE_PRECISION; .GLOBAL sqrt; sqrt: F4=RSQRTS F0; {Fetch seed} F12=F4*F4; {F12=X0^2} F12=F12*F0; {F12=C*X0^2} F4=F1*F4, F12=F8-F12; {F4=.5*X0, F10=3-C*X0^2} F4=F4*F12; {F4=X1=.5*X0(3-C*X0^2)} F12=F4*F4; {F12=X1^2} F12=F12*F0; {F12=C*X1^2} F4=F1*F4, F12=F8-F12; {F4=.5*X1, F10=3-C*X1^2} F4=F4*F12; {F4=X2=.5*X1(3-C*X1^2)} F12=F4*F4; {F12=X2^2} F12=F12*F0; {F12=C*X2^2} RTS (DB), F4=F1*F4, F12=F8-F12; {F4=.5*X2, F10=3-C*X2^2} F4=F4*F12; {F4=X3=.5*X2(3-C*X2^2)} F0=F4*F0; {X=sqrt(Y)=Y/sqrt(Y)} .ENDSEG;