Sinecalc-062.txt

Warning: if you clip this code into your program, look out for possible html code slipping in.

REM benchmark program for execution speed comparison.
REM ss 6/1/98 - modified to compare performance of -062
REM calculate sine to within 0.5% using only integers
REM Cannot calculate any closer than 0.5% due to integer limits
REM This program will run on -062 and -074

CONSTANT CRLF AS STRING = "\010\013"

FUNCTION sinx(arg AS INTEGER)AS INTEGER
	LOCAL T1 AS INTEGER, T2 AS INTEGER, T3 AS INTEGER
	T1=(((((arg/10)*(arg/10))/100))*(arg/20))/30
	T2= (((T1/2*(arg/100))/10)*(arg/100))/100
	T3= (((T2*(arg/10)/10)*(arg/100)))/1260
	sinx = arg - T1 + T2 - T3
END

GLOBAL angle AS INTEGER,radians AS INTEGER
GLOBAL degrees_per_step AS INTEGER, counts AS INTEGER
GLOBAL sine AS INTEGER,reps AS INTEGER
GLOBAL sec AS INTEGER, fsec AS INTEGER, millisec AS INTEGER

rem PRINT CRLF
PRINT "Start"
degrees_per_step=1
DPOKE(14,-32767):POKE(40,0)
DO
	FOR angle=45 to 45 STEP degrees_per_step
		radians=(((angle*131)*2)/3)/5
		sine=sinx(radians)
rem		PRINT crlf,angle,radians,sine," ",sin(angle*3.1416/180)
	NEXT angle
	counts=counts+1
LOOP UNTIL counts=5
fsec = DPEEK(14)
sec = PEEK(40)
millisec = ((((((((32767+fsec)/16)*10)/16)*10)/16)*10)/8 + sec*1000)
reps = 91/degrees_per_step*counts

LCD_COMMAND(0x80)
rem PRINT crlf
PRINT reps,millisec

LCD_COMMAND(0x80)
PRINT sine," "