Home » Archimedes archive » Micro User » MU 1992-05.adf » PD » Fractal/!Fractal/Asm/FPELib
Fractal/!Fractal/Asm/FPELib
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Micro User » MU 1992-05.adf » PD |
Filename: | Fractal/!Fractal/Asm/FPELib |
Read OK: | ✔ |
File size: | 4F82 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10REM > FPELib v1.03 20REM Mike Curnow's Floating Point Emulator Routines 30REM These routines provide support of single precision float variables. 40REM LEN Mike Curnow, November 1991 50REM See associated document for instructions 60DEFFNfpeasm(angles) 70LOCAL Z% 80Z%=FNfp_add_asm 90Z%=FNfp_sub_asm 100Z%=FNfp_mul_asm 110Z%=FNfp_div_asm 120Z%=FNfp_sqr_asm 130Z%=FNfp_cmp_asm 140Z%=FNfp_flt_asm 150Z%=FNfp_fix_asm 160Z%=FNfp_rem_asm 170IF angles Z%=FNfp_angles_asm 180=0 190REM 200REM Higher level calling functions 210DEFFNfp_add(c,a,b) 220IF b<>1 THEN [OPT asm: MOV R1,b:] 230IF a=1 THEN ERROR 0,"FNfp_add : operand 2 must not be register 1" 240IF a<>0 THEN [OPT asm: MOV R0,a:] 250[OPT asm:BL fp_add:] 260IF c<>0 THEN [OPT asm: MOV c,R0:] 270:=0 280DEFFNfp_sub(c,a,b) 290IF b<>1 THEN [OPT asm: MOV R1,b:] 300IF a=1 THEN ERROR 0,"FNfp_sub : operand 2 must not be register 1" 310IF a<>0 THEN [OPT asm: MOV R0,a:] 320[OPT asm:BL fp_sub:] 330IF c<>0 THEN [OPT asm: MOV c,R0:] 340:=0 350DEFFNfp_mul(c,a,b) 360IF b<>1 THEN [OPT asm: MOV R1,b:] 370IF a=1 THEN ERROR 0,"FNfp_mul : operand 2 must not be register 1" 380IF a<>0 THEN [OPT asm: MOV R0,a:] 390[OPT asm:BL fp_mul:] 400IF c<>0 THEN [OPT asm: MOV c,R0:] 410:=0 420DEFFNfp_div(c,a,b) 430IF b<>1 THEN [OPT asm: MOV R1,b:] 440IF a=1 THEN ERROR 0,"FNfp_div : operand 2 must not be register 1" 450IF a<>0 THEN [OPT asm: MOV R0,a:] 460[OPT asm:BL fp_div:] 470IF c<>0 THEN [OPT asm: MOV c,R0:] 480:=0 490DEFFNfp_sqr(d,n) 500IF n<>0 THEN [OPT asm: MOV R0,n:] 510[OPT asm:BL fp_sqr:] 520IF d<>0 THEN [OPT asm: MOV d,R0:] 530:=0 540DEFFNfp_cmp(a,b) 550IF b<>1 THEN [OPT asm: MOV R1,b:] 560IF a=1 THEN ERROR 0,"FNfp_cmp : operand 1 must not be register 1" 570IF a<>0 THEN [OPT asm: MOV R0,a:] 580[OPT asm:BL fp_cmp:] 590:=0 600DEFFNfp_flt(d,n) 610IF n<>0 THEN [OPT asm: MOV R0,n:] 620[OPT asm:BL fp_flt:] 630IF d<>0 THEN [OPT asm: MOV d,R0:] 640:=0 650DEFFNfp_fix(d,n) 660IF n<>0 THEN [OPT asm: MOV R0,n:] 670[OPT asm:BL fp_fix:] 680IF d<>0 THEN [OPT asm: MOV d,R0:] 690:=0 700DEFFNfp_rem(d,n,m) 710IF m<>1 THEN [OPT asm: MOV R1,m:] 720IF n=1 THEN ERROR 0,"FNfp_rem : operand 2 must not be register 1" 730IF n<>0 THEN [OPT asm: MOV R0,n:] 740[OPT asm:BL fp_rem:] 750IF d<>0 THEN [OPT asm: MOV d,R0:] 760:=0 770DEFFNfp_sin(d,n) 780IF n<>0 THEN [OPT asm: MOV R0,n:] 790[OPT asm:BL fp_sin:] 800IF d<>0 THEN [OPT asm: MOV d,R0:] 810:=0 820DEFFNfp_cos(d,n) 830IF n<>0 THEN [OPT asm: MOV R0,n:] 840[OPT asm:BL fp_cos:] 850IF d<>0 THEN [OPT asm: MOV d,R0:] 860:=0 870DEFFNfp_tan(d,n) 880IF n<>0 THEN [OPT asm: MOV R0,n:] 890[OPT asm:BL fp_tan:] 900IF d<>0 THEN [OPT asm: MOV d,R0:] 910:=0 920REM------------------------------------------------------------------ 930DEFFNfp_add_asm 940mant1=2:exp1=3:mant2=4:exp2=5:wrk1=14 950[OPT asm 960; Add 2 single precision floats- R0=R0+R1 970.fp_add 980STMFD R13!,{R2-R5,R14} 990MOV exp1,R0,LSR #23 ; get exponent+sign 1000BIC mant1,R0,exp1,LSL #23 ; get mantissa 1010CMP R0,#0 1020ORRNE mant1,mant1,#1<<23 ; set on bit to left of point 1030AND exp1,exp1,#255 ; remove sign 1040; 1050MOV exp2,R1,LSR #23 ; get exponent+sign 1060BIC mant2,R1,exp2,LSL #23 ; get mantissa 1070CMP R1,#0 1080ORRNE mant2,mant2,#1<<23 ; set on bit to left of point 1090AND exp2,exp2,#255 ; remove sign 1100; 1110EORS wrk1,R0,R1 ; both +ve/-ve? 1120BMI fp_add_neg ; no, unequal signs 1130; 1140SUBS wrk1,exp1,exp2 ; exp. difference 1150ADDPL mant1,mant1,mant2,LSR wrk1 ; exp1>exp2, round mant2 down 1160RSBMI wrk1,wrk1,#0 ; as +ve difference 1170ADDMI mant1,mant2,mant1,LSR wrk1 ; exp1<exp2, round mant1 down 1180MOVMI exp1,exp2 ; exponent of result 1190AND R0,R0,#1<<31 ; set sign of result 1200; Normalise mantissa & exponent 1210.fp_add_rounddown 1220CMP mant1,#1<<24 1230BLT fp_add_normexit 1240ADD exp1,exp1,#1 1250MOV mant1,mant1,LSR #1 1260B fp_add_rounddown 1270; 1280; R0 or R1 is -ve 1290.fp_add_neg 1300SUBS wrk1,exp1,exp2 ; exp. difference 1310MOVPL mant2,mant2,LSR wrk1 ; exp1>exp2, round mant2 1320RSBMI wrk1,wrk1,#0 ; as +ve difference 1330MOVMI mant1,mant1,LSR wrk1 ; exp1<exp2, round mant1 1340MOVMI exp1,exp2 ; exponent of result 1350; 1360TST R0,#1<<31 ; R0 -ve? 1370SUBEQ mant1,mant1,mant2 ; no, R0=R0-R1 1380SUBNE mant1,mant2,mant1 ; yes, R0=R1-R0 1390CMP mant1,#0 1400RSBMI mant1,mant1,#0 ; +ve mantissa 1410MOVMI R0,#1<<31 ; -ve result 1420MOVPL R0,#0 ; +ve result 1430; Normalise result - adjust mantissa & exponent 1440CMP mant1,#0 ; check for 0 - special case 1450MOVEQ R0,#0 1460BEQ fp_add_exit 1470.fp_add_roundup 1480TST mant1,#1<<23 1490BNE fp_add_normexit 1500SUB exp1,exp1,#1 1510MOV mant1,mant1,LSL #1 1520B fp_add_roundup 1530; combine result 1540.fp_add_normexit 1550ORR R0,R0,exp1,LSL #23 ; set exponent 1560BIC mant1,mant1,#1<<23 ; clear hi-order 1570ORR R0,R0,mant1 ; full result 1580.fp_add_exit 1590LDMFD R13!,{R2-R5,PC}^ 1600]:=0 1610: 1620DEFFNfp_sub_asm 1630mant1=2:exp1=3:mant2=4:exp2=5:wrk1=14 1640[OPT asm 1650; Subtract 2 single precision floats- R0=R0-R1 1660.fp_sub 1670STMFD R13!,{R2-R5,R14} 1680MOV exp1,R0,LSR #23 ; get exponent+sign 1690BIC mant1,R0,exp1,LSL #23 ; get mantissa 1700CMP R0,#0 1710ORRNE mant1,mant1,#1<<23 ; set on bit to left of point 1720AND exp1,exp1,#255 ; remove sign 1730; 1740MOV exp2,R1,LSR #23 ; get exponent+sign 1750BIC mant2,R1,exp2,LSL #23 ; get mantissa 1760CMP R1,#0 1770ORRNE mant2,mant2,#1<<23 ; set on bit to left of point 1780AND exp2,exp2,#255 ; remove sign 1790; 1800EORS wrk1,R0,R1 ; both +ve/-ve? 1810BMI fp_sub_unequal ; no - special case 1820; 1830SUBS wrk1,exp1,exp2 ; exp. difference 1840SUBPL mant1,mant1,mant2,LSR wrk1 ; exp1>exp2, round mant2 & subtract 1850RSBMI wrk1,wrk1,#0 ; as +ve difference 1860RSBMI mant1,mant2,mant1,LSR wrk1 ; exp1<exp2, round mant1 & subtract 1870MOVMI exp1,exp2 ; exponent of result 1880AND R0,R0,#1<<31 ; default sign of result 1890CMP mant1,#0 ; flip sign? 1900RSBMI mant1,mant1,#0 ; yes - flip mantissa 1910EORMI R0,R0,#1<<31 ; and final sign 1920; Normalise result - adjust mantissa & exponent 1930CMP mant1,#0 ; check for 0 - special case 1940MOVEQ R0,#0 1950BEQ fp_sub_exit 1960.fp_sub_roundup 1970TST mant1,#1<<23 1980BNE fp_sub_normexit 1990SUB exp1,exp1,#1 2000MOV mant1,mant1,LSL #1 2010B fp_sub_roundup 2020; 2030; R0 & R1 have different signs - add 2040.fp_sub_unequal 2050SUBS wrk1,exp1,exp2 ; exp. difference 2060ADDPL mant1,mant1,mant2,LSR wrk1 ; exp1>exp2, round mant2 & add 2070RSBMI wrk1,wrk1,#0 ; as +ve difference 2080ADDMI mant1,mant2,mant1,LSR wrk1 ; exp1<exp2, round mant1 & add 2090MOVMI exp1,exp2 ; exponent of result 2100AND R0,R0,#1<<31 ; sign of result 2110; Normalise result - adjust mantissa & exponent 2120.fp_sub_rounddown 2130CMP mant1,#1<<24 2140BLT fp_sub_normexit 2150ADD exp1,exp1,#1 2160MOV mant1,mant1,LSR #1 2170B fp_sub_rounddown 2180; combine result 2190.fp_sub_normexit 2200ORR R0,R0,exp1,LSL #23 ; set exponent 2210BIC mant1,mant1,#1<<23 ; clear hi-order 2220ORR R0,R0,mant1 ; full result 2230.fp_sub_exit 2240LDMFD R13!,{R2-R5,PC}^ 2250]:=0 2260: 2270DEFFNfp_mul_asm 2280mant1=2:exp1=3:mant2=1:exp2=4:wrk1=14 2290ResHigh=4 2300[OPT asm 2310; Multiply 2 single precision floats- R0=R0*R1 2320.fp_mul 2330STMFD R13!,{R2-R4,R14} 2340; Check for null result 2350CMP R0,#0 2360CMPNE R1,#0 2370MOVEQ R0,#0 2380BEQ fp_mul_exit 2390; 2400MOV exp1,R0,LSR #23 ; get exponent+sign 2410BIC mant1,R0,exp1,LSL #23 ; get mantissa 2420ORR mant1,mant1,#1<<23 ; set on bit to left of point 2430AND exp1,exp1,#255 ; remove sign 2440; 2450EOR R0,R0,R1 ; sign of result 2460AND R0,R0,#1<<31 ; clear rest of result 2470; 2480MOV exp2,R1,LSR #23 ; get exponent+sign 2490BIC mant2,R1,exp2,LSL #23 ; get mantissa 2500ORR mant2,mant2,#1<<23 ; set on bit to left of point 2510AND exp2,exp2,#255 ; remove sign 2520; 2530ADD exp1,exp1,exp2 2540SUBS exp1,exp1,#127 ; exponent result 2550MOVMI R0,#0 ; underflow 2560BMI fp_mul_exit 2570; Do the multiply to 30 bits precision 2580MOV wrk1,mant1,LSR#9 ; top 15 bits 2590MOV ResHigh,mant2,LSR#9 ; top 15 bits 2600BIC mant1,mant1,wrk1,LSL#9 ; low 9 bits 2610BIC mant2,mant2,ResHigh,LSL#9 ; low 9 bits 2620MUL mant2,wrk1,mant2 ; top*low 2630MUL mant1,ResHigh,mant1 ; low*top 2640MUL ResHigh,wrk1,ResHigh ; top*top 2650ADD ResHigh,ResHigh,mant1,LSR#9 ; top + middle bit1 2660ADD ResHigh,ResHigh,mant2,LSR#9 ; top + middle bit2 2670; Adjust for carry 2680TST ResHigh,#1<<29 2690ADDNE exp1,exp1,#1 ; adjust exponent 2700MOVNE ResHigh,ResHigh,LSR#1 ; shift result right 2710; combine result 2720ORR R0,R0,exp1,LSL #23 ; set exponent 2730BIC ResHigh,ResHigh,#1<<28 ; clear hi-order 2740ORR R0,R0,ResHigh,LSR #5 ; top 23 bits 2750.fp_mul_exit 2760LDMFD R13!,{R2-R4,PC}^ 2770]:=0 2780: 2790DEFFNfp_div_asm 2800mant1=2:exp1=3:mant2=4:exp2=14 2810q=1:p=exp2 2820[OPT asm 2830; Divide 2 single precision floats- R0=R0/R1 2840.fp_div 2850STMFD R13!,{R2-R4,R14} 2860; Check for null result 2870CMP R0,#0 2880CMPNE R1,#0 2890MOVEQ R0,#0 2900BEQ fp_div_exit 2910; 2920MOV exp1,R0,LSR #23 ; get exponent+sign 2930BIC mant1,R0,exp1,LSL #23 ; get mantissa 2940ORR mant1,mant1,#1<<23 ; set on bit to left of point 2950AND exp1,exp1,#255 ; remove sign 2960; 2970MOV exp2,R1,LSR #23 ; get exponent+sign 2980BIC mant2,R1,exp2,LSL #23 ; get mantissa 2990ORR mant2,mant2,#1<<23 ; set on bit to left of point 3000AND exp2,exp2,#255 ; remove sign 3010; 3020SUB exp1,exp1,exp2 3030ADDS exp1,exp1,#127 ; exponent result 3040MOVMI R0,#0 ; underflow 3050BMI fp_div_exit 3060EOR R0,R0,R1 ; sign of result 3070AND R0,R0,#1<<31 ; clear rest of result 3080; Do the divide to full precision 3090MOV q,#0 ; quotient 3100MOV p,#1<<23 ; number binary places to do 3110.fp_divloop ; do binary places 3120CMP mant1,mant2 ; number>divisor? 3130ORRCS q,q,p ; yes - set bit in binary place 3140SUBCS mant1,mant1,mant2 ; discard accounted value 3150MOVS mant1,mant1,LSL #1 ; shift up remainder, if any 3160MOVNES p,p,LSR#1 ; next binary place, if remainder 3170BNE fp_divloop ; next place if any 3180; 3190CMP q,#1<<23 ; normalise? 3200SUBLT exp1,exp1,#1 ; yes, adjust exponent 3210MOVLT q,q,LSL #1 ; & mantissa 3220; combine result 3230ORR R0,R0,exp1,LSL #23 ; set exponent 3240BIC q,q,#1<<23 ; clear hi-order 3250ORR R0,R0,q ; result 3260.fp_div_exit 3270LDMFD R13!,{R2-R4,PC}^ 3280]:=0 3290: 3300DEFFNfp_sqr_asm 3310mant1=1:exp1=2:wrk1=14 3320ResHigh=2 3330[OPT asm 3340; Square a single precision float - R0=R0*R0 3350.fp_sqr 3360STMFD R13!,{R2,R14} 3370; Check for null result 3380CMP R0,#0 3390MOVEQ R0,#0 3400BEQ fp_sqr_exit 3410; 3420MOV exp1,R0,LSR #23 ; get exponent+sign 3430BIC mant1,R0,exp1,LSL #23 ; get mantissa 3440ORR mant1,mant1,#1<<23 ; set on bit to left of point 3450AND exp1,exp1,#255 ; remove sign 3460; 3470ADD exp1,exp1,exp1 3480SUBS exp1,exp1,#127 ; exponent result 3490MOVMI R0,#0 ; underflow 3500BMI fp_sqr_exit 3510MOV R0,exp1,LSL#23 3520; Do the multiply to 30 bits precision 3530MOV wrk1,mant1,LSR#9 ; top 15 bits 3540BIC mant1,mant1,wrk1,LSL#9 ; low 9 bits 3550MUL mant1,wrk1,mant1 ; low*top 3560MUL ResHigh,wrk1,wrk1 ; top*top 3570ADD mant1,ResHigh,mant1,LSR#8 ; high+2*mid bits 3580; Adjust for carry 3590TST ResHigh,#1<<29 3600ADDNE R0,R0,#1<<23 ; adjust exponent 3610MOVNE mant1,mant1,LSR#1 ; shift result right 3620; combine result 3630BIC mant1,mant1,#1<<28 ; clear hi-order 3640ORR R0,R0,mant1,LSR#5 ; add significant part of number 3650.fp_sqr_exit 3660LDMFD R13!,{R2,PC}^ 3670]:=0 3680: 3690DEFFNfp_cmp_asm 3700[OPT asm 3710; Compare two floats. If op1 & op2 -ve, do opposite compare 3720.fp_cmp 3730CMP R1,#0 ; R1 -ve? 3740BMI fp_cmp_R0 3750CMP R0,R1 ; no - do normal CMP 3760MOV R14,PC 3770.fp_cmp_R0 3780CMP R0,#0 ; R0 -ve? 3790BMI fp_cmp_neg ; R0 & R1 -ve 3800CMP R0,R1 3810MOV R14,PC 3820.fp_cmp_neg 3830CMP R1,R0 ; opposite compare 3840MOV R14,PC 3850]:=0 3860: 3870DEFFNfp_flt_asm 3880mant1=1 3890[OPT asm 3900; Convert an integer to float format 3910.fp_flt 3920CMP R0,#0 3930MOVEQ PC,R14 ; no change required 3940MOVGE mant1,R0 3950MOVGE R0,#150<<23 ; base sign+exponent 3960RSBLT mant1,R0,#0 3970MOVLT R0,#(150<<23)+(1<<31) ; base sign+exponent 3980CMP mant1,#1<<23 3990BGE fp_flt_up ; Round up 4000.fp_flt_down ; Round down 4010SUB R0,R0,#1<<23 4020MOV mant1,mant1,LSL #1 4030CMP mant1,#1<<23 4040BLT fp_flt_down 4050.fp_flt_make ; combine result 4060BIC mant1,mant1,#1<<23 4070ORR R0,R0,mant1 4080MOVS PC,R14 4090.fp_flt_up ; round number up 4100CMP mant1,#1<<24 4110BLT fp_flt_make 4120ADD R0,R0,#1<<23 4130MOV mant1,mant1,LSR #1 4140B fp_flt_up 4150]:=0 4160: 4170DEFFNfp_fix_asm 4180mant1=0:exp1=1 4190[OPT asm 4200; Convert a float to integer format 4210.fp_fix 4220CMP R0,#0 4230MOVEQ PC,R14 ; no change required 4240MOV exp1,R0,LSR #23 4250BIC mant1,R0,exp1,LSL #23 4260ORR mant1,mant1,#1<<23 4270TST exp1,#1<<8 ; negative number? 4280RSBNE mant1,mant1,#0 ; yes 4290BIC exp1,exp1,#1<<8 ; clear sign 4300SUBS exp1,exp1,#127 ; exponent relative to 1 4310MOVMI R0,#0 ; underflow 4320MOVMIS PC,R14 4330RSBS exp1,exp1,#23 ; shift value relative to 1 4340MOVPL mant1,mant1,ASR exp1 4350RSBMI exp1,exp1,#0 ; number > 1<<23 4360MOVMI mant1,mant1,ASL exp1 4370MOVS PC,R14 4380]:=0 4390: 4400DEFFNfp_rem_asm 4410mant1=0:mant2=1:sign=2:exp1=3:exp2=14:cnt=exp1 4420[OPT asm 4430; R0 = remainder from R0/R1 4440.fp_rem 4450STMFD R13!,{R2-R3,R14} 4460; Check for null result 4470CMP R1,#0 4480MOVEQ R0,#0 4490BEQ fp_rem_exit 4500CMP R0,#0 4510BEQ fp_rem_exit 4520MOVGT sign,#0 ; set sign of result 4530MOVLT sign,#1<<31 4540BICLT R0,R0,#1<<31 ; remove sign 4550; 4560BIC R1,R1,#1<<31 ; Remove sign if any 4570CMP R0,R1 ; If R0<R1 4580BLT fp_rem_sign ; then have remainder 4590; 4600MOV exp1,R0,LSR #23 ; get exponent+sign 4610BIC mant1,R0,exp1,LSL #23 ; get mantissa 4620ORR mant1,mant1,#1<<23 ; set on bit to left of point 4630; 4640MOV exp2,R1,LSR #23 ; get exponent+sign 4650BIC mant2,R1,exp2,LSL #23 ; get mantissa 4660ORR mant2,mant2,#1<<23 ; set on bit to left of point 4670; 4680SUB cnt,exp1,exp2 ; size of quotient 4690; Do the divide but only track value of remainder 4700.fp_remloop ; do binary places 4710CMP mant1,mant2 ; number>divisor? 4720SUBCS mant1,mant1,mant2 ; discard accounted value 4730SUBS cnt,cnt,#1 4740MOVPL mant1,mant1,LSL #1 ; shift up remainder 4750BPL fp_remloop ; 4760CMP mant1,#0 4770BEQ fp_rem_exit ; no remainder 4780B fp_rem_adjust 4790; Normalise result 4800.fp_rem_norm 4810MOV mant1,mant1,LSL #1 4820SUB exp2,exp2,#1 4830.fp_rem_adjust 4840CMP mant1,#1<<23 4850BLT fp_rem_norm 4860; combine result 4870BIC R0,mant1,#1<<23 ; clear hi-order 4880ORR R0,R0,exp2,LSL #23 ; set exponent 4890.fp_rem_sign 4900ORR R0,R0,sign 4910.fp_rem_exit 4920LDMFD R13!,{R2-R3,PC}^ 4930]:=0 4940: 4950DEFFNfp_angles_asm 4960LOCAL s,sin,sinx 4970: 4980REM R0=COS(R0) where R0 is in radians 4990[OPT asm 5000.fp_cos 5010STMFD R13!,{R2-R5,R14} ; Nb! keep in step with fp_sin 5020LDR R1,fp_pi 5030SUB R1,R1,#1<<23 ; 1/2 PI 5040BL fp_add 5050B fp_sincos ; carry on as cos 5060] 5070: 5080REM R0=SIN(R0) where R0 is in radians 5090sign=3 5100[OPT asm 5110.fp_sin 5120STMFD R13!,{R2-R5,R14} 5130.fp_sincos 5140CMP R0,#0 5150MOVGE sign,#0 5160MOVLT sign,#1<<31 5170BICLT R0,R0,#1<<31 5180; If >PI*2 then get remainder 5190LDR R2,fp_pi 5200ADD R1,R2,#1<<23 ; pi*2 5210CMP R0,R1 5220BLGT fp_rem 5230; If >PI then invert sign 5240MOV R1,R2 ; pi 5250CMP R0,R1 5260EORGT sign,sign,#1<<31 5270BLGT fp_sub ; adjust to <PI 5280; If >PI/2 then adjust as offset from pi 5290SUB R1,R2,#1<<23 ; pi/2 5300CMP R0,R1 5310MOVGT R1,R0 5320MOVGT R0,R2 ; pi 5330BLGT fp_sub ; R0=pi-radians 5340; Get index into sin table 5350ADD R0,R0,#10<<23 ; multiply by 1024 5360MOV R2,R0 ; save radians*1024 5370BL fp_fix ; As integer 5380ADR R4,fp_sintab ; Table of sines 5390ADD R4,R4,R0,LSL #3 ; address of sin table entry 5400LDMIA R4,{R4,R5} ; sin + adjustment factor 5410BL fp_flt ; radian value of base sin 5420MOV R1,R0 5430MOV R0,R2 5440BL fp_sub ; radian difference from table entry 5450MOV R1,R5 5460BL fp_mul ; calc sine difference 5470MOV R1,R4 5480BL fp_add ; combine result 5490ORR R0,R0,sign ; sign of result 5500.fp_sin_exit 5510LDMFD R13!,{R2-R5,PC}^ 5520; 5530; R0=TAN(R0) where R0 is in radians 5540; Essentially a modified version of fp_sin with added cos & sin/cos 5550.fp_tan 5560STMFD R13!,{R2-R7,R14} 5570CMP R0,#0 5580MOVGE sign,#0 5590MOVLT sign,#1<<31 5600BICLT R0,R0,#1<<31 5610; If >PI*2 then get remainder 5620LDR R2,fp_pi 5630ADD R1,R2,#1<<23 ; pi*2 5640CMP R0,R1 5650BLGT fp_rem 5660; If >PI then reduce to <PI 5670MOV R1,R2 ; pi 5680CMP R0,R1 5690BLGT fp_sub ; adjust to <PI 5700; If >PI/2 then adjust as offset from pi & set sign 5710SUB R1,R2,#1<<23 ; pi/2 5720CMP R0,R1 5730MOVGT R1,R0 5740MOVGT R0,R2 ; pi 5750BLGT fp_sub ; R0=pi-radians 5760EORGT sign,sign,#1<<31 5770; Get index into sin table 5780ADD R0,R0,#10<<23 ; multiply by 1024 5790MOV R2,R0 ; save radians*1024 5800BL fp_fix ; As integer 5810ADR R6,fp_sintab ; Table of sines 5820ADD R4,R6,R0,LSL #3 ; address of sin table entry 5830LDMIA R4,{R4,R5} ; sin + adjustment factor 5840; 5850LDR R7,fp_1608 5860SUB R7,R7,R0 ; index of cos value 5870; 5880BL fp_flt ; radian value of base sin 5890MOV R1,R0 5900MOV R0,R2 5910BL fp_sub ; radian difference from table entry 5920MOV R1,R5 5930MOV R5,R0 ; save radian fraction 5940BL fp_mul ; calc sine difference 5950MOV R1,R4 5960BL fp_add ; combine result 5970ORR R0,R0,sign ; sign of result 5980MOV R4,R0 ; save sine 5990; Do cosine. Nb. frig because of 1608.5 entries in Sine table 6000LDR R0,fp_cos1 6010CMP R5,R0 ; R5>0.5? 6020LDRGE R0,fp_cos2 6030SUBGE R7,R7,#1 ; previous table entry 6040MOV R1,R5 ; radian fraction 6050BL fp_sub ; invert for cos 6060ADD R6,R6,R7,LSL #3 ; address table entry for cos 6070LDMIA R6,{R6,R7} ; cos + adjustment factor 6080MOV R1,R7 ; cos adjustment factor 6090BL fp_mul ; calc Cos difference 6100MOV R1,R6 6110BL fp_add ; combine result 6120; Tan=Sine/Cosine 6130MOV R1,R0 6140MOV R0,R4 6150BL fp_div 6160LDMFD R13!,{R2-R7,PC}^ 6170; 6180.fp_1608 DCD 1608 ; Number of entries in sine table 6190.fp_cos1 FNfp("DFS 0.49543863") ; adjustment factor for cos 6200.fp_cos2 FNfp("DFS 1.49543963") 6210.fp_pi FNfp("DFS "+STR$(PI)) 6220.fp_sintab 6230] 6240IF asm AND 2 THEN 6250 sin=0 6260 FOR s=0 TO PI/2 STEP 1/1024 6270 sinx=SIN(s+1/1024) 6280 [OPT asm 6290 FNfp("DFS "+STR$(sin)) 6300 FNfp("DFS "+STR$(sinx-sin)) 6310 :] 6320 sin=sinx 6330 NEXT 6340ELSE P%+=1610*8:O%+=1610*8 6350ENDIF 6360=0
� > FPELib v1.03 4� Mike Curnow's Floating Point Emulator Routines I� These routines provide support of single precision float variables. ("� � Mike Curnow, November 1991 2.� See associated document for instructions <ݤfpeasm(angles) F� Z% PZ%=�fp_add_asm ZZ%=�fp_sub_asm dZ%=�fp_mul_asm nZ%=�fp_div_asm xZ%=�fp_sqr_asm �Z%=�fp_cmp_asm �Z%=�fp_flt_asm �Z%=�fp_fix_asm �Z%=�fp_rem_asm �� angles Z%=�fp_angles_asm �=0 �� �$� Higher level calling functions �ݤfp_add(c,a,b) �!� b<>1 � [OPT asm: MOV R1,b:] �=� a=1 � � 0,"FNfp_add : operand 2 must not be register 1" �!� a<>0 � [OPT asm: MOV R0,a:] �[OPT asm:BL fp_add:] !� c<>0 � [OPT asm: MOV c,R0:] :=0 ݤfp_sub(c,a,b) "!� b<>1 � [OPT asm: MOV R1,b:] ,=� a=1 � � 0,"FNfp_sub : operand 2 must not be register 1" 6!� a<>0 � [OPT asm: MOV R0,a:] @[OPT asm:BL fp_sub:] J!� c<>0 � [OPT asm: MOV c,R0:] T:=0 ^ݤfp_mul(c,a,b) h!� b<>1 � [OPT asm: MOV R1,b:] r=� a=1 � � 0,"FNfp_mul : operand 2 must not be register 1" |!� a<>0 � [OPT asm: MOV R0,a:] �[OPT asm:BL fp_mul:] �!� c<>0 � [OPT asm: MOV c,R0:] �:=0 �ݤfp_div(c,a,b) �!� b<>1 � [OPT asm: MOV R1,b:] �=� a=1 � � 0,"FNfp_div : operand 2 must not be register 1" �!� a<>0 � [OPT asm: MOV R0,a:] �[OPT asm:BL fp_div:] �!� c<>0 � [OPT asm: MOV c,R0:] �:=0 �ݤfp_sqr(d,n) �!� n<>0 � [OPT asm: MOV R0,n:] �[OPT asm:BL fp_sqr:] !� d<>0 � [OPT asm: MOV d,R0:] :=0 ݤfp_cmp(a,b) &!� b<>1 � [OPT asm: MOV R1,b:] 0=� a=1 � � 0,"FNfp_cmp : operand 1 must not be register 1" :!� a<>0 � [OPT asm: MOV R0,a:] D[OPT asm:BL fp_cmp:] N:=0 Xݤfp_flt(d,n) b!� n<>0 � [OPT asm: MOV R0,n:] l[OPT asm:BL fp_flt:] v!� d<>0 � [OPT asm: MOV d,R0:] �:=0 �ݤfp_fix(d,n) �!� n<>0 � [OPT asm: MOV R0,n:] �[OPT asm:BL fp_fix:] �!� d<>0 � [OPT asm: MOV d,R0:] �:=0 �ݤfp_rem(d,n,m) �!� m<>1 � [OPT asm: MOV R1,m:] �=� n=1 � � 0,"FNfp_rem : operand 2 must not be register 1" �!� n<>0 � [OPT asm: MOV R0,n:] �[OPT asm:BL fp_rem:] �!� d<>0 � [OPT asm: MOV d,R0:] �:=0 ݤfp_sin(d,n) !� n<>0 � [OPT asm: MOV R0,n:] [OPT asm:BL fp_sin:] !� d<>0 � [OPT asm: MOV d,R0:] *:=0 4ݤfp_cos(d,n) >!� n<>0 � [OPT asm: MOV R0,n:] H[OPT asm:BL fp_cos:] R!� d<>0 � [OPT asm: MOV d,R0:] \:=0 fݤfp_tan(d,n) p!� n<>0 � [OPT asm: MOV R0,n:] z[OPT asm:BL fp_tan:] �!� d<>0 � [OPT asm: MOV d,R0:] �:=0 �G�------------------------------------------------------------------ �ݤfp_add_asm �)mant1=2:exp1=3:mant2=4:exp2=5:wrk1=14 �[OPT asm �-; Add 2 single precision floats- R0=R0+R1 �.fp_add �STMFD R13!,{R2-R5,R14} �7MOV exp1,R0,LSR #23 ; get exponent+sign �2BIC mant1,R0,exp1,LSL #23 ; get mantissa � CMP R0,#0 �@�RNE mant1,mant1,#1<<23 ; set on bit to left of point /� exp1,exp1,#255 ; remove sign ; 7MOV exp2,R1,LSR #23 ; get exponent+sign $2BIC mant2,R1,exp2,LSL #23 ; get mantissa . CMP R1,#0 8@�RNE mant2,mant2,#1<<23 ; set on bit to left of point B/� exp2,exp2,#255 ; remove sign L; V1�S wrk1,R0,R1 ; both +ve/-ve? `7BMI fp_add_neg ; no, unequal signs j; t5SUBS wrk1,exp1,exp2 ; exp. difference ~IADDPL mant1,mant1,mant2,LSR wrk1 ; exp1>exp2, round mant2 down �7RSBMI wrk1,wrk1,#0 ; as +ve difference �IADDMI mant1,mant2,mant1,LSR wrk1 ; exp1<exp2, round mant1 down �8MOVMI exp1,exp2 ; exponent of result �6� R0,R0,#1<<31 ; set sign of result �#; Normalise mantissa & exponent �.fp_add_rounddown �CMP mant1,#1<<24 �BLT fp_add_normexit �ADD exp1,exp1,#1 �MOV mant1,mant1,LSR #1 �B fp_add_rounddown �; ; R0 or R1 is -ve .fp_add_neg 5SUBS wrk1,exp1,exp2 ; exp. difference <MOVPL mant2,mant2,LSR wrk1 ; exp1>exp2, round mant2 (7RSBMI wrk1,wrk1,#0 ; as +ve difference 2<MOVMI mant1,mant1,LSR wrk1 ; exp1<exp2, round mant1 <8MOVMI exp1,exp2 ; exponent of result F; P-TST R0,#1<<31 ; R0 -ve? Z2SUBEQ mant1,mant1,mant2 ; no, R0=R0-R1 d3SUBNE mant1,mant2,mant1 ; yes, R0=R1-R0 nCMP mant1,#0 x2RSBMI mant1,mant1,#0 ; +ve mantissa �0MOVMI R0,#1<<31 ; -ve result �0MOVPL R0,#0 ; +ve result �3; Normalise result - adjust mantissa & exponent �@CMP mant1,#0 ; check for 0 - special case ��Q R0,#0 �BEQ fp_add_exit �.fp_add_roundup �TST mant1,#1<<23 �BNE fp_add_normexit �SUB exp1,exp1,#1 �MOV mant1,mant1,LSL #1 �B fp_add_roundup �; combine result .fp_add_normexit 1�R R0,R0,exp1,LSL #23 ; set exponent 4BIC mant1,mant1,#1<<23 ; clear hi-order "0�R R0,R0,mant1 ; full result ,.fp_add_exit 6LDMFD R13!,{R2-R5,PC}^ @]:=0 J: Tݤfp_sub_asm ^)mant1=2:exp1=3:mant2=4:exp2=5:wrk1=14 h[OPT asm r2; Subtract 2 single precision floats- R0=R0-R1 |.fp_sub �STMFD R13!,{R2-R5,R14} �7MOV exp1,R0,LSR #23 ; get exponent+sign �2BIC mant1,R0,exp1,LSL #23 ; get mantissa � CMP R0,#0 �@�RNE mant1,mant1,#1<<23 ; set on bit to left of point �/� exp1,exp1,#255 ; remove sign �; �7MOV exp2,R1,LSR #23 ; get exponent+sign �2BIC mant2,R1,exp2,LSL #23 ; get mantissa � CMP R1,#0 �@�RNE mant2,mant2,#1<<23 ; set on bit to left of point �/� exp2,exp2,#255 ; remove sign �; 1�S wrk1,R0,R1 ; both +ve/-ve? 7BMI fp_sub_unequal ; no - special case ; &5SUBS wrk1,exp1,exp2 ; exp. difference 0MSUBPL mant1,mant1,mant2,LSR wrk1 ; exp1>exp2, round mant2 & subtract :7RSBMI wrk1,wrk1,#0 ; as +ve difference DMRSBMI mant1,mant2,mant1,LSR wrk1 ; exp1<exp2, round mant1 & subtract N8MOVMI exp1,exp2 ; exponent of result X:� R0,R0,#1<<31 ; default sign of result b0CMP mant1,#0 ; flip sign? l9RSBMI mant1,mant1,#0 ; yes - flip mantissa v2�MI R0,R0,#1<<31 ; and final sign �3; Normalise result - adjust mantissa & exponent �@CMP mant1,#0 ; check for 0 - special case ��Q R0,#0 �BEQ fp_sub_exit �.fp_sub_roundup �TST mant1,#1<<23 �BNE fp_sub_normexit �SUB exp1,exp1,#1 �MOV mant1,mant1,LSL #1 �B fp_sub_roundup �; �(; R0 & R1 have different signs - add �.fp_sub_unequal 5SUBS wrk1,exp1,exp2 ; exp. difference HADDPL mant1,mant1,mant2,LSR wrk1 ; exp1>exp2, round mant2 & add 7RSBMI wrk1,wrk1,#0 ; as +ve difference HADDMI mant1,mant2,mant1,LSR wrk1 ; exp1<exp2, round mant1 & add *8MOVMI exp1,exp2 ; exponent of result 42� R0,R0,#1<<31 ; sign of result >3; Normalise result - adjust mantissa & exponent H.fp_sub_rounddown RCMP mant1,#1<<24 \BLT fp_sub_normexit fADD exp1,exp1,#1 pMOV mant1,mant1,LSR #1 zB fp_sub_rounddown �; combine result �.fp_sub_normexit �1�R R0,R0,exp1,LSL #23 ; set exponent �4BIC mant1,mant1,#1<<23 ; clear hi-order �0�R R0,R0,mant1 ; full result �.fp_sub_exit �LDMFD R13!,{R2-R5,PC}^ �]:=0 �: �ݤfp_mul_asm �)mant1=2:exp1=3:mant2=1:exp2=4:wrk1=14 � ResHigh=4 �[OPT asm 2; Multiply 2 single precision floats- R0=R0*R1 .fp_mul STMFD R13!,{R2-R4,R14} $; Check for null result . CMP R0,#0 8CMPNE R1,#0 B�Q R0,#0 LBEQ fp_mul_exit V; `7MOV exp1,R0,LSR #23 ; get exponent+sign j2BIC mant1,R0,exp1,LSL #23 ; get mantissa t@�R mant1,mant1,#1<<23 ; set on bit to left of point ~/� exp1,exp1,#255 ; remove sign �; �2� R0,R0,R1 ; sign of result �8� R0,R0,#1<<31 ; clear rest of result �; �7MOV exp2,R1,LSR #23 ; get exponent+sign �2BIC mant2,R1,exp2,LSL #23 ; get mantissa �@�R mant2,mant2,#1<<23 ; set on bit to left of point �/� exp2,exp2,#255 ; remove sign �; �ADD exp1,exp1,exp2 �5SUBS exp1,exp1,#127 ; exponent result �/MOVMI R0,#0 ; underflow BMI fp_mul_exit *; Do the multiply to 30 bits precision 1MOV wrk1,mant1,LSR#9 ; top 15 bits 1MOV ResHigh,mant2,LSR#9 ; top 15 bits (1BIC mant1,mant1,wrk1,LSL#9 ; low 9 bits 21BIC mant2,mant2,ResHigh,LSL#9 ; low 9 bits <-MUL mant2,wrk1,mant2 ; top*low F-MUL mant1,ResHigh,mant1 ; low*top P-MUL ResHigh,wrk1,ResHigh ; top*top Z7ADD ResHigh,ResHigh,mant1,LSR#9 ; top + middle bit1 d7ADD ResHigh,ResHigh,mant2,LSR#9 ; top + middle bit2 n; Adjust for carry xTST ResHigh,#1<<29 �5ADDNE exp1,exp1,#1 ; adjust exponent �8MOVNE ResHigh,ResHigh,LSR#1 ; shift result right �; combine result �1�R R0,R0,exp1,LSL #23 ; set exponent �4BIC ResHigh,ResHigh,#1<<28 ; clear hi-order �0�R R0,R0,ResHigh,LSR #5 ; top 23 bits �.fp_mul_exit �LDMFD R13!,{R2-R4,PC}^ �]:=0 �: �ݤfp_div_asm �"mant1=2:exp1=3:mant2=4:exp2=14 �q=1:p=exp2 [OPT asm 0; Divide 2 single precision floats- R0=R0/R1 .fp_div "STMFD R13!,{R2-R4,R14} ,; Check for null result 6 CMP R0,#0 @CMPNE R1,#0 J�Q R0,#0 TBEQ fp_div_exit ^; h7MOV exp1,R0,LSR #23 ; get exponent+sign r2BIC mant1,R0,exp1,LSL #23 ; get mantissa |@�R mant1,mant1,#1<<23 ; set on bit to left of point �/� exp1,exp1,#255 ; remove sign �; �7MOV exp2,R1,LSR #23 ; get exponent+sign �2BIC mant2,R1,exp2,LSL #23 ; get mantissa �@�R mant2,mant2,#1<<23 ; set on bit to left of point �/� exp2,exp2,#255 ; remove sign �; �SUB exp1,exp1,exp2 �5ADDS exp1,exp1,#127 ; exponent result �/MOVMI R0,#0 ; underflow �BMI fp_div_exit �2� R0,R0,R1 ; sign of result �8� R0,R0,#1<<31 ; clear rest of result %; Do the divide to full precision .MOV q,#0 ; quotient @MOV p,#1<<23 ; number binary places to do &6.fp_divloop ; do binary places 05CMP mant1,mant2 ; number>divisor? :B�RCS q,q,p ; yes - set bit in binary place D=SUBCS mant1,mant1,mant2 ; discard accounted value N@MOVS mant1,mant1,LSL #1 ; shift up remainder, if any XEMOVNES p,p,LSR#1 ; next binary place, if remainder b7BNE fp_divloop ; next place if any l; v0CMP q,#1<<23 ; normalise? �:SUBLT exp1,exp1,#1 ; yes, adjust exponent �0MOVLT q,q,LSL #1 ; & mantissa �; combine result �1�R R0,R0,exp1,LSL #23 ; set exponent �4BIC q,q,#1<<23 ; clear hi-order �+�R R0,R0,q ; result �.fp_div_exit �LDMFD R13!,{R2-R4,PC}^ �]:=0 �: �ݤfp_sqr_asm �mant1=1:exp1=2:wrk1=14 � ResHigh=2 [OPT asm 0; Square a single precision float - R0=R0*R0 .fp_sqr STMFD R13!,{R2,R14} *; Check for null result 4 CMP R0,#0 >�Q R0,#0 HBEQ fp_sqr_exit R; \7MOV exp1,R0,LSR #23 ; get exponent+sign f2BIC mant1,R0,exp1,LSL #23 ; get mantissa p@�R mant1,mant1,#1<<23 ; set on bit to left of point z/� exp1,exp1,#255 ; remove sign �; �ADD exp1,exp1,exp1 �5SUBS exp1,exp1,#127 ; exponent result �/MOVMI R0,#0 ; underflow �BMI fp_sqr_exit �MOV R0,exp1,LSL#23 �*; Do the multiply to 30 bits precision �1MOV wrk1,mant1,LSR#9 ; top 15 bits �0BIC mant1,mant1,wrk1,LSL#9 ; low 9 bits �-MUL mant1,wrk1,mant1 ; low*top �-MUL ResHigh,wrk1,wrk1 ; top*top �5ADD mant1,ResHigh,mant1,LSR#8 ; high+2*mid bits �; Adjust for carry TST ResHigh,#1<<29 5ADDNE R0,R0,#1<<23 ; adjust exponent 8MOVNE mant1,mant1,LSR#1 ; shift result right $; combine result .4BIC mant1,mant1,#1<<28 ; clear hi-order 8C�R R0,R0,mant1,LSR#5 ; add significant part of number B.fp_sqr_exit LLDMFD R13!,{R2,PC}^ V]:=0 `: jݤfp_cmp_asm t[OPT asm ~?; Compare two floats. If op1 & op2 -ve, do opposite compare �.fp_cmp �-CMP R1,#0 ; R1 -ve? �BMI fp_cmp_R0 �8CMP R0,R1 ; no - do normal CMP �MOV R14,PC �.fp_cmp_R0 �-CMP R0,#0 ; R0 -ve? �1BMI fp_cmp_neg ; R0 & R1 -ve � CMP R0,R1 �MOV R14,PC �.fp_cmp_neg �6CMP R1,R0 ; opposite compare MOV R14,PC ]:=0 : ݤfp_flt_asm (mant1=1 2[OPT asm <(; Convert an integer to float format F.fp_flt P CMP R0,#0 Z5�Q PC,R14 ; no change required dMOVGE mant1,R0 n8MOVGE R0,#150<<23 ; base sign+exponent xRSBLT mant1,R0,#0 �8MOVLT R0,#(150<<23)+(1<<31) ; base sign+exponent �CMP mant1,#1<<23 �.BGE fp_flt_up ; Round up �0.fp_flt_down ; Round down �SUB R0,R0,#1<<23 �MOV mant1,mant1,LSL #1 �CMP mant1,#1<<23 �BLT fp_flt_down �4.fp_flt_make ; combine result �BIC mant1,mant1,#1<<23 ��R R0,R0,mant1 �MOVS PC,R14 �5.fp_flt_up ; round number up CMP mant1,#1<<24 BLT fp_flt_make ADD R0,R0,#1<<23 "MOV mant1,mant1,LSR #1 ,B fp_flt_up 6]:=0 @: Jݤfp_fix_asm Tmant1=0:exp1=1 ^[OPT asm h'; Convert a float to integer format r.fp_fix | CMP R0,#0 �5�Q PC,R14 ; no change required �MOV exp1,R0,LSR #23 �BIC mant1,R0,exp1,LSL #23 ��R mant1,mant1,#1<<23 �6TST exp1,#1<<8 ; negative number? �)RSBNE mant1,mant1,#0 ; yes �0BIC exp1,exp1,#1<<8 ; clear sign �<SUBS exp1,exp1,#127 ; exponent relative to 1 �/MOVMI R0,#0 ; underflow �MOVMIS PC,R14 �?RSBS exp1,exp1,#23 ; shift value relative to 1 �MOVPL mant1,mant1,ASR exp1 �4RSBMI exp1,exp1,#0 ; number > 1<<23 MOVMI mant1,mant1,ASL exp1 MOVS PC,R14 ]:=0 &: 0ݤfp_rem_asm :2mant1=0:mant2=1:sign=2:exp1=3:exp2=14:cnt=exp1 D[OPT asm N; R0 = remainder from R0/R1 X.fp_rem bSTMFD R13!,{R2-R3,R14} l; Check for null result v CMP R1,#0 ��Q R0,#0 �BEQ fp_rem_exit � CMP R0,#0 �BEQ fp_rem_exit �8MOVGT sign,#0 ; set sign of result �MOVLT sign,#1<<31 �1BICLT R0,R0,#1<<31 ; remove sign �; �8BIC R1,R1,#1<<31 ; Remove sign if any �.CMP R0,R1 ; If R0<R1 �9BLT fp_rem_sign ; then have remainder �; �7MOV exp1,R0,LSR #23 ; get exponent+sign 2BIC mant1,R0,exp1,LSL #23 ; get mantissa @�R mant1,mant1,#1<<23 ; set on bit to left of point ; 7MOV exp2,R1,LSR #23 ; get exponent+sign *2BIC mant2,R1,exp2,LSL #23 ; get mantissa 4@�R mant2,mant2,#1<<23 ; set on bit to left of point >; H6SUB cnt,exp1,exp2 ; size of quotient R5; Do the divide but only track value of remainder \6.fp_remloop ; do binary places f5CMP mant1,mant2 ; number>divisor? p=SUBCS mant1,mant1,mant2 ; discard accounted value zSUBS cnt,cnt,#1 �8MOVPL mant1,mant1,LSL #1 ; shift up remainder �%BPL fp_remloop ; �CMP mant1,#0 �2BEQ fp_rem_exit ; no remainder �B fp_rem_adjust �; Normalise result �.fp_rem_norm �MOV mant1,mant1,LSL #1 �SUB exp2,exp2,#1 �.fp_rem_adjust �CMP mant1,#1<<23 �BLT fp_rem_norm �; combine result 4BIC R0,mant1,#1<<23 ; clear hi-order 1�R R0,R0,exp2,LSL #23 ; set exponent .fp_rem_sign $�R R0,R0,sign ..fp_rem_exit 8LDMFD R13!,{R2-R3,PC}^ B]:=0 L: Vݤfp_angles_asm `� s,sin,sinx j: t'� R0=COS(R0) where R0 is in radians ~[OPT asm �.fp_cos �BSTMFD R13!,{R2-R5,R14} ; Nb! keep in step with fp_sin �LDR R1,fp_pi �+SUB R1,R1,#1<<23 ; 1/2 � � BL fp_add �5B fp_sincos ; carry on as cos �] �: �'� R0=SIN(R0) where R0 is in radians � sign=3 �[OPT asm �.fp_sin STMFD R13!,{R2-R5,R14} .fp_sincos CMP R0,#0 MOVGE sign,#0 (MOVLT sign,#1<<31 2BICLT R0,R0,#1<<31 < ; If >�*2 then get remainder FLDR R2,fp_pi P*ADD R1,R2,#1<<23 ; pi*2 Z CMP R0,R1 dBLGT fp_rem n; If >� then invert sign x(MOV R1,R2 ; pi � CMP R0,R1 ��GT sign,sign,#1<<31 �2BLGT fp_sub ; adjust to <� �+; If >�/2 then adjust as offset from pi �*SUB R1,R2,#1<<23 ; pi/2 � CMP R0,R1 �MOVGT R1,R0 �(MOVGT R0,R2 ; pi �3BLGT fp_sub ; R0=pi-radians �; Get index into sin table �6ADD R0,R0,#10<<23 ; multiply by 1024 �7MOV R2,R0 ; save radians*1024 �0BL fp_fix ; As integer 4ADR R4,fp_sintab ; Table of sines @ADD R4,R4,R0,LSL #3 ; address of sin table entry =LDMIA R4,{R4,R5} ; sin + adjustment factor ">BL fp_flt ; radian value of base sin , MOV R1,R0 6 MOV R0,R2 @HBL fp_sub ; radian difference from table entry J MOV R1,R5 T:BL fp_mul ; calc sine difference ^ MOV R1,R4 h4BL fp_add ; combine result r3�R R0,R0,sign ; sign of result |.fp_sin_exit �LDMFD R13!,{R2-R5,PC}^ �; �%; R0=�(R0) where R0 is in radians �G; Essentially a modified version of fp_sin with added cos & sin/cos �.fp_tan �STMFD R13!,{R2-R7,R14} � CMP R0,#0 �MOVGE sign,#0 �MOVLT sign,#1<<31 �BICLT R0,R0,#1<<31 � ; If >�*2 then get remainder �LDR R2,fp_pi �*ADD R1,R2,#1<<23 ; pi*2 CMP R0,R1 BLGT fp_rem ; If >� then reduce to <� &(MOV R1,R2 ; pi 0 CMP R0,R1 :2BLGT fp_sub ; adjust to <� D6; If >�/2 then adjust as offset from pi & set sign N*SUB R1,R2,#1<<23 ; pi/2 X CMP R0,R1 bMOVGT R1,R0 l(MOVGT R0,R2 ; pi v3BLGT fp_sub ; R0=pi-radians ��GT sign,sign,#1<<31 �; Get index into sin table �6ADD R0,R0,#10<<23 ; multiply by 1024 �7MOV R2,R0 ; save radians*1024 �0BL fp_fix ; As integer �4ADR R6,fp_sintab ; Table of sines �@ADD R4,R6,R0,LSL #3 ; address of sin table entry �=LDMIA R4,{R4,R5} ; sin + adjustment factor �; �LDR R7,fp_1608 �8SUB R7,R7,R0 ; index of cos value �; �>BL fp_flt ; radian value of base sin MOV R1,R0 MOV R0,R2 HBL fp_sub ; radian difference from table entry MOV R1,R5 *:MOV R5,R0 ; save radian fraction 4:BL fp_mul ; calc sine difference > MOV R1,R4 H4BL fp_add ; combine result R3�R R0,R0,sign ; sign of result \/MOV R4,R0 ; save sine fA; Do cosine. Nb. frig because of 1608.5 entries in Sine table pLDR R0,fp_cos1 z-CMP R5,R0 ; R5>0.5? �LDRGE R0,fp_cos2 �:SUBGE R7,R7,#1 ; previous table entry �5MOV R1,R5 ; radian fraction �4BL fp_sub ; invert for cos �AADD R6,R6,R7,LSL #3 ; address table entry for cos �=LDMIA R6,{R6,R7} ; cos + adjustment factor �;MOV R1,R7 ; cos adjustment factor �9BL fp_mul ; calc Cos difference � MOV R1,R6 �4BL fp_add ; combine result �; Tan=Sine/Cosine � MOV R1,R0 � MOV R0,R4 BL fp_div LDMFD R13!,{R2-R7,PC}^ ; $E.fp_1608 DCD 1608 ; Number of entries in sine table .>.fp_cos1 �fp("DFS 0.49543863") ; adjustment factor for cos 8".fp_cos2 �fp("DFS 1.49543963") B.fp_pi �fp("DFS "+�(�)) L.fp_sintab V] `� asm � 2 � j sin=0 t � s=0 � �/2 � 1/1024 ~ sinx=�(s+1/1024) � [OPT asm � �fp("DFS "+�(sin)) � �fp("DFS "+�(sinx-sin)) � :] � sin=sinx � � �� P%+=1610*8:O%+=1610*8 �� �=0 �
00000000 0d 00 0a 14 f4 20 3e 20 46 50 45 4c 69 62 20 76 |..... > FPELib v| 00000010 31 2e 30 33 0d 00 14 34 f4 20 4d 69 6b 65 20 43 |1.03...4. Mike C| 00000020 75 72 6e 6f 77 27 73 20 46 6c 6f 61 74 69 6e 67 |urnow's Floating| 00000030 20 50 6f 69 6e 74 20 45 6d 75 6c 61 74 6f 72 20 | Point Emulator | 00000040 52 6f 75 74 69 6e 65 73 0d 00 1e 49 f4 20 54 68 |Routines...I. Th| 00000050 65 73 65 20 72 6f 75 74 69 6e 65 73 20 70 72 6f |ese routines pro| 00000060 76 69 64 65 20 73 75 70 70 6f 72 74 20 6f 66 20 |vide support of | 00000070 73 69 6e 67 6c 65 20 70 72 65 63 69 73 69 6f 6e |single precision| 00000080 20 66 6c 6f 61 74 20 76 61 72 69 61 62 6c 65 73 | float variables| 00000090 2e 0d 00 28 22 f4 20 a9 20 4d 69 6b 65 20 43 75 |...(". . Mike Cu| 000000a0 72 6e 6f 77 2c 20 4e 6f 76 65 6d 62 65 72 20 31 |rnow, November 1| 000000b0 39 39 31 0d 00 32 2e f4 20 53 65 65 20 61 73 73 |991..2.. See ass| 000000c0 6f 63 69 61 74 65 64 20 64 6f 63 75 6d 65 6e 74 |ociated document| 000000d0 20 66 6f 72 20 69 6e 73 74 72 75 63 74 69 6f 6e | for instruction| 000000e0 73 0d 00 3c 14 dd a4 66 70 65 61 73 6d 28 61 6e |s..<...fpeasm(an| 000000f0 67 6c 65 73 29 0d 00 46 08 ea 20 5a 25 0d 00 50 |gles)..F.. Z%..P| 00000100 12 5a 25 3d a4 66 70 5f 61 64 64 5f 61 73 6d 0d |.Z%=.fp_add_asm.| 00000110 00 5a 12 5a 25 3d a4 66 70 5f 73 75 62 5f 61 73 |.Z.Z%=.fp_sub_as| 00000120 6d 0d 00 64 12 5a 25 3d a4 66 70 5f 6d 75 6c 5f |m..d.Z%=.fp_mul_| 00000130 61 73 6d 0d 00 6e 12 5a 25 3d a4 66 70 5f 64 69 |asm..n.Z%=.fp_di| 00000140 76 5f 61 73 6d 0d 00 78 12 5a 25 3d a4 66 70 5f |v_asm..x.Z%=.fp_| 00000150 73 71 72 5f 61 73 6d 0d 00 82 12 5a 25 3d a4 66 |sqr_asm....Z%=.f| 00000160 70 5f 63 6d 70 5f 61 73 6d 0d 00 8c 12 5a 25 3d |p_cmp_asm....Z%=| 00000170 a4 66 70 5f 66 6c 74 5f 61 73 6d 0d 00 96 12 5a |.fp_flt_asm....Z| 00000180 25 3d a4 66 70 5f 66 69 78 5f 61 73 6d 0d 00 a0 |%=.fp_fix_asm...| 00000190 12 5a 25 3d a4 66 70 5f 72 65 6d 5f 61 73 6d 0d |.Z%=.fp_rem_asm.| 000001a0 00 aa 1e e7 20 61 6e 67 6c 65 73 20 5a 25 3d a4 |.... angles Z%=.| 000001b0 66 70 5f 61 6e 67 6c 65 73 5f 61 73 6d 0d 00 b4 |fp_angles_asm...| 000001c0 06 3d 30 0d 00 be 05 f4 0d 00 c8 24 f4 20 48 69 |.=0........$. Hi| 000001d0 67 68 65 72 20 6c 65 76 65 6c 20 63 61 6c 6c 69 |gher level calli| 000001e0 6e 67 20 66 75 6e 63 74 69 6f 6e 73 0d 00 d2 13 |ng functions....| 000001f0 dd a4 66 70 5f 61 64 64 28 63 2c 61 2c 62 29 0d |..fp_add(c,a,b).| 00000200 00 dc 21 e7 20 62 3c 3e 31 20 8c 20 5b 4f 50 54 |..!. b<>1 . [OPT| 00000210 20 61 73 6d 3a 20 4d 4f 56 20 52 31 2c 62 3a 5d | asm: MOV R1,b:]| 00000220 0d 00 e6 3d e7 20 61 3d 31 20 8c 20 85 20 30 2c |...=. a=1 . . 0,| 00000230 22 46 4e 66 70 5f 61 64 64 20 3a 20 6f 70 65 72 |"FNfp_add : oper| 00000240 61 6e 64 20 32 20 6d 75 73 74 20 6e 6f 74 20 62 |and 2 must not b| 00000250 65 20 72 65 67 69 73 74 65 72 20 31 22 0d 00 f0 |e register 1"...| 00000260 21 e7 20 61 3c 3e 30 20 8c 20 5b 4f 50 54 20 61 |!. a<>0 . [OPT a| 00000270 73 6d 3a 20 4d 4f 56 20 52 30 2c 61 3a 5d 0d 00 |sm: MOV R0,a:]..| 00000280 fa 18 5b 4f 50 54 20 61 73 6d 3a 42 4c 20 66 70 |..[OPT asm:BL fp| 00000290 5f 61 64 64 3a 5d 0d 01 04 21 e7 20 63 3c 3e 30 |_add:]...!. c<>0| 000002a0 20 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 | . [OPT asm: MOV| 000002b0 20 63 2c 52 30 3a 5d 0d 01 0e 07 3a 3d 30 0d 01 | c,R0:]....:=0..| 000002c0 18 13 dd a4 66 70 5f 73 75 62 28 63 2c 61 2c 62 |....fp_sub(c,a,b| 000002d0 29 0d 01 22 21 e7 20 62 3c 3e 31 20 8c 20 5b 4f |).."!. b<>1 . [O| 000002e0 50 54 20 61 73 6d 3a 20 4d 4f 56 20 52 31 2c 62 |PT asm: MOV R1,b| 000002f0 3a 5d 0d 01 2c 3d e7 20 61 3d 31 20 8c 20 85 20 |:]..,=. a=1 . . | 00000300 30 2c 22 46 4e 66 70 5f 73 75 62 20 3a 20 6f 70 |0,"FNfp_sub : op| 00000310 65 72 61 6e 64 20 32 20 6d 75 73 74 20 6e 6f 74 |erand 2 must not| 00000320 20 62 65 20 72 65 67 69 73 74 65 72 20 31 22 0d | be register 1".| 00000330 01 36 21 e7 20 61 3c 3e 30 20 8c 20 5b 4f 50 54 |.6!. a<>0 . [OPT| 00000340 20 61 73 6d 3a 20 4d 4f 56 20 52 30 2c 61 3a 5d | asm: MOV R0,a:]| 00000350 0d 01 40 18 5b 4f 50 54 20 61 73 6d 3a 42 4c 20 |..@.[OPT asm:BL | 00000360 66 70 5f 73 75 62 3a 5d 0d 01 4a 21 e7 20 63 3c |fp_sub:]..J!. c<| 00000370 3e 30 20 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d |>0 . [OPT asm: M| 00000380 4f 56 20 63 2c 52 30 3a 5d 0d 01 54 07 3a 3d 30 |OV c,R0:]..T.:=0| 00000390 0d 01 5e 13 dd a4 66 70 5f 6d 75 6c 28 63 2c 61 |..^...fp_mul(c,a| 000003a0 2c 62 29 0d 01 68 21 e7 20 62 3c 3e 31 20 8c 20 |,b)..h!. b<>1 . | 000003b0 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 20 52 31 |[OPT asm: MOV R1| 000003c0 2c 62 3a 5d 0d 01 72 3d e7 20 61 3d 31 20 8c 20 |,b:]..r=. a=1 . | 000003d0 85 20 30 2c 22 46 4e 66 70 5f 6d 75 6c 20 3a 20 |. 0,"FNfp_mul : | 000003e0 6f 70 65 72 61 6e 64 20 32 20 6d 75 73 74 20 6e |operand 2 must n| 000003f0 6f 74 20 62 65 20 72 65 67 69 73 74 65 72 20 31 |ot be register 1| 00000400 22 0d 01 7c 21 e7 20 61 3c 3e 30 20 8c 20 5b 4f |"..|!. a<>0 . [O| 00000410 50 54 20 61 73 6d 3a 20 4d 4f 56 20 52 30 2c 61 |PT asm: MOV R0,a| 00000420 3a 5d 0d 01 86 18 5b 4f 50 54 20 61 73 6d 3a 42 |:]....[OPT asm:B| 00000430 4c 20 66 70 5f 6d 75 6c 3a 5d 0d 01 90 21 e7 20 |L fp_mul:]...!. | 00000440 63 3c 3e 30 20 8c 20 5b 4f 50 54 20 61 73 6d 3a |c<>0 . [OPT asm:| 00000450 20 4d 4f 56 20 63 2c 52 30 3a 5d 0d 01 9a 07 3a | MOV c,R0:]....:| 00000460 3d 30 0d 01 a4 13 dd a4 66 70 5f 64 69 76 28 63 |=0......fp_div(c| 00000470 2c 61 2c 62 29 0d 01 ae 21 e7 20 62 3c 3e 31 20 |,a,b)...!. b<>1 | 00000480 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 20 |. [OPT asm: MOV | 00000490 52 31 2c 62 3a 5d 0d 01 b8 3d e7 20 61 3d 31 20 |R1,b:]...=. a=1 | 000004a0 8c 20 85 20 30 2c 22 46 4e 66 70 5f 64 69 76 20 |. . 0,"FNfp_div | 000004b0 3a 20 6f 70 65 72 61 6e 64 20 32 20 6d 75 73 74 |: operand 2 must| 000004c0 20 6e 6f 74 20 62 65 20 72 65 67 69 73 74 65 72 | not be register| 000004d0 20 31 22 0d 01 c2 21 e7 20 61 3c 3e 30 20 8c 20 | 1"...!. a<>0 . | 000004e0 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 20 52 30 |[OPT asm: MOV R0| 000004f0 2c 61 3a 5d 0d 01 cc 18 5b 4f 50 54 20 61 73 6d |,a:]....[OPT asm| 00000500 3a 42 4c 20 66 70 5f 64 69 76 3a 5d 0d 01 d6 21 |:BL fp_div:]...!| 00000510 e7 20 63 3c 3e 30 20 8c 20 5b 4f 50 54 20 61 73 |. c<>0 . [OPT as| 00000520 6d 3a 20 4d 4f 56 20 63 2c 52 30 3a 5d 0d 01 e0 |m: MOV c,R0:]...| 00000530 07 3a 3d 30 0d 01 ea 11 dd a4 66 70 5f 73 71 72 |.:=0......fp_sqr| 00000540 28 64 2c 6e 29 0d 01 f4 21 e7 20 6e 3c 3e 30 20 |(d,n)...!. n<>0 | 00000550 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 20 |. [OPT asm: MOV | 00000560 52 30 2c 6e 3a 5d 0d 01 fe 18 5b 4f 50 54 20 61 |R0,n:]....[OPT a| 00000570 73 6d 3a 42 4c 20 66 70 5f 73 71 72 3a 5d 0d 02 |sm:BL fp_sqr:]..| 00000580 08 21 e7 20 64 3c 3e 30 20 8c 20 5b 4f 50 54 20 |.!. d<>0 . [OPT | 00000590 61 73 6d 3a 20 4d 4f 56 20 64 2c 52 30 3a 5d 0d |asm: MOV d,R0:].| 000005a0 02 12 07 3a 3d 30 0d 02 1c 11 dd a4 66 70 5f 63 |...:=0......fp_c| 000005b0 6d 70 28 61 2c 62 29 0d 02 26 21 e7 20 62 3c 3e |mp(a,b)..&!. b<>| 000005c0 31 20 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f |1 . [OPT asm: MO| 000005d0 56 20 52 31 2c 62 3a 5d 0d 02 30 3d e7 20 61 3d |V R1,b:]..0=. a=| 000005e0 31 20 8c 20 85 20 30 2c 22 46 4e 66 70 5f 63 6d |1 . . 0,"FNfp_cm| 000005f0 70 20 3a 20 6f 70 65 72 61 6e 64 20 31 20 6d 75 |p : operand 1 mu| 00000600 73 74 20 6e 6f 74 20 62 65 20 72 65 67 69 73 74 |st not be regist| 00000610 65 72 20 31 22 0d 02 3a 21 e7 20 61 3c 3e 30 20 |er 1"..:!. a<>0 | 00000620 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 20 |. [OPT asm: MOV | 00000630 52 30 2c 61 3a 5d 0d 02 44 18 5b 4f 50 54 20 61 |R0,a:]..D.[OPT a| 00000640 73 6d 3a 42 4c 20 66 70 5f 63 6d 70 3a 5d 0d 02 |sm:BL fp_cmp:]..| 00000650 4e 07 3a 3d 30 0d 02 58 11 dd a4 66 70 5f 66 6c |N.:=0..X...fp_fl| 00000660 74 28 64 2c 6e 29 0d 02 62 21 e7 20 6e 3c 3e 30 |t(d,n)..b!. n<>0| 00000670 20 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 | . [OPT asm: MOV| 00000680 20 52 30 2c 6e 3a 5d 0d 02 6c 18 5b 4f 50 54 20 | R0,n:]..l.[OPT | 00000690 61 73 6d 3a 42 4c 20 66 70 5f 66 6c 74 3a 5d 0d |asm:BL fp_flt:].| 000006a0 02 76 21 e7 20 64 3c 3e 30 20 8c 20 5b 4f 50 54 |.v!. d<>0 . [OPT| 000006b0 20 61 73 6d 3a 20 4d 4f 56 20 64 2c 52 30 3a 5d | asm: MOV d,R0:]| 000006c0 0d 02 80 07 3a 3d 30 0d 02 8a 11 dd a4 66 70 5f |....:=0......fp_| 000006d0 66 69 78 28 64 2c 6e 29 0d 02 94 21 e7 20 6e 3c |fix(d,n)...!. n<| 000006e0 3e 30 20 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d |>0 . [OPT asm: M| 000006f0 4f 56 20 52 30 2c 6e 3a 5d 0d 02 9e 18 5b 4f 50 |OV R0,n:]....[OP| 00000700 54 20 61 73 6d 3a 42 4c 20 66 70 5f 66 69 78 3a |T asm:BL fp_fix:| 00000710 5d 0d 02 a8 21 e7 20 64 3c 3e 30 20 8c 20 5b 4f |]...!. d<>0 . [O| 00000720 50 54 20 61 73 6d 3a 20 4d 4f 56 20 64 2c 52 30 |PT asm: MOV d,R0| 00000730 3a 5d 0d 02 b2 07 3a 3d 30 0d 02 bc 13 dd a4 66 |:]....:=0......f| 00000740 70 5f 72 65 6d 28 64 2c 6e 2c 6d 29 0d 02 c6 21 |p_rem(d,n,m)...!| 00000750 e7 20 6d 3c 3e 31 20 8c 20 5b 4f 50 54 20 61 73 |. m<>1 . [OPT as| 00000760 6d 3a 20 4d 4f 56 20 52 31 2c 6d 3a 5d 0d 02 d0 |m: MOV R1,m:]...| 00000770 3d e7 20 6e 3d 31 20 8c 20 85 20 30 2c 22 46 4e |=. n=1 . . 0,"FN| 00000780 66 70 5f 72 65 6d 20 3a 20 6f 70 65 72 61 6e 64 |fp_rem : operand| 00000790 20 32 20 6d 75 73 74 20 6e 6f 74 20 62 65 20 72 | 2 must not be r| 000007a0 65 67 69 73 74 65 72 20 31 22 0d 02 da 21 e7 20 |egister 1"...!. | 000007b0 6e 3c 3e 30 20 8c 20 5b 4f 50 54 20 61 73 6d 3a |n<>0 . [OPT asm:| 000007c0 20 4d 4f 56 20 52 30 2c 6e 3a 5d 0d 02 e4 18 5b | MOV R0,n:]....[| 000007d0 4f 50 54 20 61 73 6d 3a 42 4c 20 66 70 5f 72 65 |OPT asm:BL fp_re| 000007e0 6d 3a 5d 0d 02 ee 21 e7 20 64 3c 3e 30 20 8c 20 |m:]...!. d<>0 . | 000007f0 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 20 64 2c |[OPT asm: MOV d,| 00000800 52 30 3a 5d 0d 02 f8 07 3a 3d 30 0d 03 02 11 dd |R0:]....:=0.....| 00000810 a4 66 70 5f 73 69 6e 28 64 2c 6e 29 0d 03 0c 21 |.fp_sin(d,n)...!| 00000820 e7 20 6e 3c 3e 30 20 8c 20 5b 4f 50 54 20 61 73 |. n<>0 . [OPT as| 00000830 6d 3a 20 4d 4f 56 20 52 30 2c 6e 3a 5d 0d 03 16 |m: MOV R0,n:]...| 00000840 18 5b 4f 50 54 20 61 73 6d 3a 42 4c 20 66 70 5f |.[OPT asm:BL fp_| 00000850 73 69 6e 3a 5d 0d 03 20 21 e7 20 64 3c 3e 30 20 |sin:].. !. d<>0 | 00000860 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f 56 20 |. [OPT asm: MOV | 00000870 64 2c 52 30 3a 5d 0d 03 2a 07 3a 3d 30 0d 03 34 |d,R0:]..*.:=0..4| 00000880 11 dd a4 66 70 5f 63 6f 73 28 64 2c 6e 29 0d 03 |...fp_cos(d,n)..| 00000890 3e 21 e7 20 6e 3c 3e 30 20 8c 20 5b 4f 50 54 20 |>!. n<>0 . [OPT | 000008a0 61 73 6d 3a 20 4d 4f 56 20 52 30 2c 6e 3a 5d 0d |asm: MOV R0,n:].| 000008b0 03 48 18 5b 4f 50 54 20 61 73 6d 3a 42 4c 20 66 |.H.[OPT asm:BL f| 000008c0 70 5f 63 6f 73 3a 5d 0d 03 52 21 e7 20 64 3c 3e |p_cos:]..R!. d<>| 000008d0 30 20 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 4d 4f |0 . [OPT asm: MO| 000008e0 56 20 64 2c 52 30 3a 5d 0d 03 5c 07 3a 3d 30 0d |V d,R0:]..\.:=0.| 000008f0 03 66 11 dd a4 66 70 5f 74 61 6e 28 64 2c 6e 29 |.f...fp_tan(d,n)| 00000900 0d 03 70 21 e7 20 6e 3c 3e 30 20 8c 20 5b 4f 50 |..p!. n<>0 . [OP| 00000910 54 20 61 73 6d 3a 20 4d 4f 56 20 52 30 2c 6e 3a |T asm: MOV R0,n:| 00000920 5d 0d 03 7a 18 5b 4f 50 54 20 61 73 6d 3a 42 4c |]..z.[OPT asm:BL| 00000930 20 66 70 5f 74 61 6e 3a 5d 0d 03 84 21 e7 20 64 | fp_tan:]...!. d| 00000940 3c 3e 30 20 8c 20 5b 4f 50 54 20 61 73 6d 3a 20 |<>0 . [OPT asm: | 00000950 4d 4f 56 20 64 2c 52 30 3a 5d 0d 03 8e 07 3a 3d |MOV d,R0:]....:=| 00000960 30 0d 03 98 47 f4 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |0...G.----------| 00000970 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000009a0 2d 2d 2d 2d 2d 2d 2d 2d 0d 03 a2 10 dd a4 66 70 |--------......fp| 000009b0 5f 61 64 64 5f 61 73 6d 0d 03 ac 29 6d 61 6e 74 |_add_asm...)mant| 000009c0 31 3d 32 3a 65 78 70 31 3d 33 3a 6d 61 6e 74 32 |1=2:exp1=3:mant2| 000009d0 3d 34 3a 65 78 70 32 3d 35 3a 77 72 6b 31 3d 31 |=4:exp2=5:wrk1=1| 000009e0 34 0d 03 b6 0c 5b 4f 50 54 20 61 73 6d 0d 03 c0 |4....[OPT asm...| 000009f0 2d 3b 20 41 64 64 20 32 20 73 69 6e 67 6c 65 20 |-; Add 2 single | 00000a00 70 72 65 63 69 73 69 6f 6e 20 66 6c 6f 61 74 73 |precision floats| 00000a10 2d 20 52 30 3d 52 30 2b 52 31 0d 03 ca 0b 2e 66 |- R0=R0+R1.....f| 00000a20 70 5f 61 64 64 0d 03 d4 1a 53 54 4d 46 44 20 52 |p_add....STMFD R| 00000a30 31 33 21 2c 7b 52 32 2d 52 35 2c 52 31 34 7d 0d |13!,{R2-R5,R14}.| 00000a40 03 de 37 4d 4f 56 20 65 78 70 31 2c 52 30 2c 4c |..7MOV exp1,R0,L| 00000a50 53 52 20 23 32 33 20 20 20 20 20 20 20 20 20 20 |SR #23 | 00000a60 20 20 20 3b 20 67 65 74 20 65 78 70 6f 6e 65 6e | ; get exponen| 00000a70 74 2b 73 69 67 6e 0d 03 e8 32 42 49 43 20 6d 61 |t+sign...2BIC ma| 00000a80 6e 74 31 2c 52 30 2c 65 78 70 31 2c 4c 53 4c 20 |nt1,R0,exp1,LSL | 00000a90 23 32 33 20 20 20 20 20 20 20 3b 20 67 65 74 20 |#23 ; get | 00000aa0 6d 61 6e 74 69 73 73 61 0d 03 f2 0d 43 4d 50 20 |mantissa....CMP | 00000ab0 52 30 2c 23 30 0d 03 fc 40 84 52 4e 45 20 6d 61 |R0,#0...@.RNE ma| 00000ac0 6e 74 31 2c 6d 61 6e 74 31 2c 23 31 3c 3c 32 33 |nt1,mant1,#1<<23| 00000ad0 20 20 20 20 20 20 20 20 3b 20 73 65 74 20 6f 6e | ; set on| 00000ae0 20 62 69 74 20 74 6f 20 6c 65 66 74 20 6f 66 20 | bit to left of | 00000af0 70 6f 69 6e 74 0d 04 06 2f 80 20 65 78 70 31 2c |point.../. exp1,| 00000b00 65 78 70 31 2c 23 32 35 35 20 20 20 20 20 20 20 |exp1,#255 | 00000b10 20 20 20 20 20 20 20 3b 20 72 65 6d 6f 76 65 20 | ; remove | 00000b20 73 69 67 6e 0d 04 10 05 3b 0d 04 1a 37 4d 4f 56 |sign....;...7MOV| 00000b30 20 65 78 70 32 2c 52 31 2c 4c 53 52 20 23 32 33 | exp2,R1,LSR #23| 00000b40 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 67 | ; g| 00000b50 65 74 20 65 78 70 6f 6e 65 6e 74 2b 73 69 67 6e |et exponent+sign| 00000b60 0d 04 24 32 42 49 43 20 6d 61 6e 74 32 2c 52 31 |..$2BIC mant2,R1| 00000b70 2c 65 78 70 32 2c 4c 53 4c 20 23 32 33 20 20 20 |,exp2,LSL #23 | 00000b80 20 20 20 20 3b 20 67 65 74 20 6d 61 6e 74 69 73 | ; get mantis| 00000b90 73 61 0d 04 2e 0d 43 4d 50 20 52 31 2c 23 30 0d |sa....CMP R1,#0.| 00000ba0 04 38 40 84 52 4e 45 20 6d 61 6e 74 32 2c 6d 61 |.8@.RNE mant2,ma| 00000bb0 6e 74 32 2c 23 31 3c 3c 32 33 20 20 20 20 20 20 |nt2,#1<<23 | 00000bc0 20 20 3b 20 73 65 74 20 6f 6e 20 62 69 74 20 74 | ; set on bit t| 00000bd0 6f 20 6c 65 66 74 20 6f 66 20 70 6f 69 6e 74 0d |o left of point.| 00000be0 04 42 2f 80 20 65 78 70 32 2c 65 78 70 32 2c 23 |.B/. exp2,exp2,#| 00000bf0 32 35 35 20 20 20 20 20 20 20 20 20 20 20 20 20 |255 | 00000c00 20 3b 20 72 65 6d 6f 76 65 20 73 69 67 6e 0d 04 | ; remove sign..| 00000c10 4c 05 3b 0d 04 56 31 82 53 20 77 72 6b 31 2c 52 |L.;..V1.S wrk1,R| 00000c20 30 2c 52 31 20 20 20 20 20 20 20 20 20 20 20 20 |0,R1 | 00000c30 20 20 20 20 20 3b 20 62 6f 74 68 20 2b 76 65 2f | ; both +ve/| 00000c40 2d 76 65 3f 0d 04 60 37 42 4d 49 20 66 70 5f 61 |-ve?..`7BMI fp_a| 00000c50 64 64 5f 6e 65 67 20 20 20 20 20 20 20 20 20 20 |dd_neg | 00000c60 20 20 20 20 20 20 20 20 3b 20 6e 6f 2c 20 75 6e | ; no, un| 00000c70 65 71 75 61 6c 20 73 69 67 6e 73 0d 04 6a 05 3b |equal signs..j.;| 00000c80 0d 04 74 35 53 55 42 53 20 77 72 6b 31 2c 65 78 |..t5SUBS wrk1,ex| 00000c90 70 31 2c 65 78 70 32 20 20 20 20 20 20 20 20 20 |p1,exp2 | 00000ca0 20 20 20 20 3b 20 65 78 70 2e 20 64 69 66 66 65 | ; exp. diffe| 00000cb0 72 65 6e 63 65 0d 04 7e 49 41 44 44 50 4c 20 6d |rence..~IADDPL m| 00000cc0 61 6e 74 31 2c 6d 61 6e 74 31 2c 6d 61 6e 74 32 |ant1,mant1,mant2| 00000cd0 2c 4c 53 52 20 77 72 6b 31 20 20 20 20 20 20 20 |,LSR wrk1 | 00000ce0 20 3b 20 65 78 70 31 3e 65 78 70 32 2c 20 72 6f | ; exp1>exp2, ro| 00000cf0 75 6e 64 20 6d 61 6e 74 32 20 64 6f 77 6e 0d 04 |und mant2 down..| 00000d00 88 37 52 53 42 4d 49 20 77 72 6b 31 2c 77 72 6b |.7RSBMI wrk1,wrk| 00000d10 31 2c 23 30 20 20 20 20 20 20 20 20 20 20 20 20 |1,#0 | 00000d20 20 20 3b 20 61 73 20 2b 76 65 20 64 69 66 66 65 | ; as +ve diffe| 00000d30 72 65 6e 63 65 0d 04 92 49 41 44 44 4d 49 20 6d |rence...IADDMI m| 00000d40 61 6e 74 31 2c 6d 61 6e 74 32 2c 6d 61 6e 74 31 |ant1,mant2,mant1| 00000d50 2c 4c 53 52 20 77 72 6b 31 20 20 20 20 20 20 20 |,LSR wrk1 | 00000d60 20 3b 20 65 78 70 31 3c 65 78 70 32 2c 20 72 6f | ; exp1<exp2, ro| 00000d70 75 6e 64 20 6d 61 6e 74 31 20 64 6f 77 6e 0d 04 |und mant1 down..| 00000d80 9c 38 4d 4f 56 4d 49 20 65 78 70 31 2c 65 78 70 |.8MOVMI exp1,exp| 00000d90 32 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |2 | 00000da0 20 20 3b 20 65 78 70 6f 6e 65 6e 74 20 6f 66 20 | ; exponent of | 00000db0 72 65 73 75 6c 74 0d 04 a6 36 80 20 20 20 52 30 |result...6. R0| 00000dc0 2c 52 30 2c 23 31 3c 3c 33 31 20 20 20 20 20 20 |,R0,#1<<31 | 00000dd0 20 20 20 20 20 20 20 20 3b 20 73 65 74 20 73 69 | ; set si| 00000de0 67 6e 20 6f 66 20 72 65 73 75 6c 74 0d 04 b0 23 |gn of result...#| 00000df0 3b 20 4e 6f 72 6d 61 6c 69 73 65 20 6d 61 6e 74 |; Normalise mant| 00000e00 69 73 73 61 20 26 20 65 78 70 6f 6e 65 6e 74 0d |issa & exponent.| 00000e10 04 ba 15 2e 66 70 5f 61 64 64 5f 72 6f 75 6e 64 |....fp_add_round| 00000e20 64 6f 77 6e 0d 04 c4 14 43 4d 50 20 6d 61 6e 74 |down....CMP mant| 00000e30 31 2c 23 31 3c 3c 32 34 0d 04 ce 17 42 4c 54 20 |1,#1<<24....BLT | 00000e40 66 70 5f 61 64 64 5f 6e 6f 72 6d 65 78 69 74 0d |fp_add_normexit.| 00000e50 04 d8 14 41 44 44 20 65 78 70 31 2c 65 78 70 31 |...ADD exp1,exp1| 00000e60 2c 23 31 0d 04 e2 1a 4d 4f 56 20 6d 61 6e 74 31 |,#1....MOV mant1| 00000e70 2c 6d 61 6e 74 31 2c 4c 53 52 20 23 31 0d 04 ec |,mant1,LSR #1...| 00000e80 16 42 20 66 70 5f 61 64 64 5f 72 6f 75 6e 64 64 |.B fp_add_roundd| 00000e90 6f 77 6e 0d 04 f6 05 3b 0d 05 00 15 3b 20 52 30 |own....;....; R0| 00000ea0 20 6f 72 20 52 31 20 69 73 20 2d 76 65 0d 05 0a | or R1 is -ve...| 00000eb0 0f 2e 66 70 5f 61 64 64 5f 6e 65 67 0d 05 14 35 |..fp_add_neg...5| 00000ec0 53 55 42 53 20 77 72 6b 31 2c 65 78 70 31 2c 65 |SUBS wrk1,exp1,e| 00000ed0 78 70 32 20 20 20 20 20 20 20 20 20 20 20 20 20 |xp2 | 00000ee0 3b 20 65 78 70 2e 20 64 69 66 66 65 72 65 6e 63 |; exp. differenc| 00000ef0 65 0d 05 1e 3c 4d 4f 56 50 4c 20 6d 61 6e 74 32 |e...<MOVPL mant2| 00000f00 2c 6d 61 6e 74 32 2c 4c 53 52 20 77 72 6b 31 20 |,mant2,LSR wrk1 | 00000f10 20 20 20 20 20 3b 20 65 78 70 31 3e 65 78 70 32 | ; exp1>exp2| 00000f20 2c 20 72 6f 75 6e 64 20 6d 61 6e 74 32 0d 05 28 |, round mant2..(| 00000f30 37 52 53 42 4d 49 20 77 72 6b 31 2c 77 72 6b 31 |7RSBMI wrk1,wrk1| 00000f40 2c 23 30 20 20 20 20 20 20 20 20 20 20 20 20 20 |,#0 | 00000f50 20 3b 20 61 73 20 2b 76 65 20 64 69 66 66 65 72 | ; as +ve differ| 00000f60 65 6e 63 65 0d 05 32 3c 4d 4f 56 4d 49 20 6d 61 |ence..2<MOVMI ma| 00000f70 6e 74 31 2c 6d 61 6e 74 31 2c 4c 53 52 20 77 72 |nt1,mant1,LSR wr| 00000f80 6b 31 20 20 20 20 20 20 3b 20 65 78 70 31 3c 65 |k1 ; exp1<e| 00000f90 78 70 32 2c 20 72 6f 75 6e 64 20 6d 61 6e 74 31 |xp2, round mant1| 00000fa0 0d 05 3c 38 4d 4f 56 4d 49 20 65 78 70 31 2c 65 |..<8MOVMI exp1,e| 00000fb0 78 70 32 20 20 20 20 20 20 20 20 20 20 20 20 20 |xp2 | 00000fc0 20 20 20 20 3b 20 65 78 70 6f 6e 65 6e 74 20 6f | ; exponent o| 00000fd0 66 20 72 65 73 75 6c 74 0d 05 46 05 3b 0d 05 50 |f result..F.;..P| 00000fe0 2d 54 53 54 20 52 30 2c 23 31 3c 3c 33 31 20 20 |-TST R0,#1<<31 | 00000ff0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001000 20 3b 20 52 30 20 2d 76 65 3f 0d 05 5a 32 53 55 | ; R0 -ve?..Z2SU| 00001010 42 45 51 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c |BEQ mant1,mant1,| 00001020 6d 61 6e 74 32 20 20 20 20 20 20 20 20 20 3b 20 |mant2 ; | 00001030 6e 6f 2c 20 52 30 3d 52 30 2d 52 31 0d 05 64 33 |no, R0=R0-R1..d3| 00001040 53 55 42 4e 45 20 6d 61 6e 74 31 2c 6d 61 6e 74 |SUBNE mant1,mant| 00001050 32 2c 6d 61 6e 74 31 20 20 20 20 20 20 20 20 20 |2,mant1 | 00001060 3b 20 79 65 73 2c 20 52 30 3d 52 31 2d 52 30 0d |; yes, R0=R1-R0.| 00001070 05 6e 10 43 4d 50 20 6d 61 6e 74 31 2c 23 30 0d |.n.CMP mant1,#0.| 00001080 05 78 32 52 53 42 4d 49 20 6d 61 6e 74 31 2c 6d |.x2RSBMI mant1,m| 00001090 61 6e 74 31 2c 23 30 20 20 20 20 20 20 20 20 20 |ant1,#0 | 000010a0 20 20 20 3b 20 2b 76 65 20 6d 61 6e 74 69 73 73 | ; +ve mantiss| 000010b0 61 0d 05 82 30 4d 4f 56 4d 49 20 52 30 2c 23 31 |a...0MOVMI R0,#1| 000010c0 3c 3c 33 31 20 20 20 20 20 20 20 20 20 20 20 20 |<<31 | 000010d0 20 20 20 20 20 3b 20 2d 76 65 20 72 65 73 75 6c | ; -ve resul| 000010e0 74 0d 05 8c 30 4d 4f 56 50 4c 20 52 30 2c 23 30 |t...0MOVPL R0,#0| 000010f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001100 20 20 20 20 20 3b 20 2b 76 65 20 72 65 73 75 6c | ; +ve resul| 00001110 74 0d 05 96 33 3b 20 4e 6f 72 6d 61 6c 69 73 65 |t...3; Normalise| 00001120 20 72 65 73 75 6c 74 20 2d 20 61 64 6a 75 73 74 | result - adjust| 00001130 20 6d 61 6e 74 69 73 73 61 20 26 20 65 78 70 6f | mantissa & expo| 00001140 6e 65 6e 74 0d 05 a0 40 43 4d 50 20 6d 61 6e 74 |nent...@CMP mant| 00001150 31 2c 23 30 20 20 20 20 20 20 20 20 20 20 20 20 |1,#0 | 00001160 20 20 20 20 20 20 20 20 3b 20 63 68 65 63 6b 20 | ; check | 00001170 66 6f 72 20 30 20 2d 20 73 70 65 63 69 61 6c 20 |for 0 - special | 00001180 63 61 73 65 0d 05 aa 0c ec 51 20 52 30 2c 23 30 |case.....Q R0,#0| 00001190 0d 05 b4 13 42 45 51 20 66 70 5f 61 64 64 5f 65 |....BEQ fp_add_e| 000011a0 78 69 74 0d 05 be 13 2e 66 70 5f 61 64 64 5f 72 |xit.....fp_add_r| 000011b0 6f 75 6e 64 75 70 0d 05 c8 14 54 53 54 20 6d 61 |oundup....TST ma| 000011c0 6e 74 31 2c 23 31 3c 3c 32 33 0d 05 d2 17 42 4e |nt1,#1<<23....BN| 000011d0 45 20 66 70 5f 61 64 64 5f 6e 6f 72 6d 65 78 69 |E fp_add_normexi| 000011e0 74 0d 05 dc 14 53 55 42 20 65 78 70 31 2c 65 78 |t....SUB exp1,ex| 000011f0 70 31 2c 23 31 0d 05 e6 1a 4d 4f 56 20 6d 61 6e |p1,#1....MOV man| 00001200 74 31 2c 6d 61 6e 74 31 2c 4c 53 4c 20 23 31 0d |t1,mant1,LSL #1.| 00001210 05 f0 14 42 20 66 70 5f 61 64 64 5f 72 6f 75 6e |...B fp_add_roun| 00001220 64 75 70 0d 05 fa 14 3b 20 63 6f 6d 62 69 6e 65 |dup....; combine| 00001230 20 72 65 73 75 6c 74 0d 06 04 14 2e 66 70 5f 61 | result.....fp_a| 00001240 64 64 5f 6e 6f 72 6d 65 78 69 74 0d 06 0e 31 84 |dd_normexit...1.| 00001250 52 20 52 30 2c 52 30 2c 65 78 70 31 2c 4c 53 4c |R R0,R0,exp1,LSL| 00001260 20 23 32 33 20 20 20 20 20 20 20 20 20 20 3b 20 | #23 ; | 00001270 73 65 74 20 65 78 70 6f 6e 65 6e 74 0d 06 18 34 |set exponent...4| 00001280 42 49 43 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c |BIC mant1,mant1,| 00001290 23 31 3c 3c 32 33 20 20 20 20 20 20 20 20 20 20 |#1<<23 | 000012a0 3b 20 63 6c 65 61 72 20 68 69 2d 6f 72 64 65 72 |; clear hi-order| 000012b0 0d 06 22 30 84 52 20 52 30 2c 52 30 2c 6d 61 6e |.."0.R R0,R0,man| 000012c0 74 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |t1 | 000012d0 20 20 20 3b 20 66 75 6c 6c 20 72 65 73 75 6c 74 | ; full result| 000012e0 0d 06 2c 10 2e 66 70 5f 61 64 64 5f 65 78 69 74 |..,..fp_add_exit| 000012f0 0d 06 36 1a 4c 44 4d 46 44 20 52 31 33 21 2c 7b |..6.LDMFD R13!,{| 00001300 52 32 2d 52 35 2c 50 43 7d 5e 0d 06 40 08 5d 3a |R2-R5,PC}^..@.]:| 00001310 3d 30 0d 06 4a 05 3a 0d 06 54 10 dd a4 66 70 5f |=0..J.:..T...fp_| 00001320 73 75 62 5f 61 73 6d 0d 06 5e 29 6d 61 6e 74 31 |sub_asm..^)mant1| 00001330 3d 32 3a 65 78 70 31 3d 33 3a 6d 61 6e 74 32 3d |=2:exp1=3:mant2=| 00001340 34 3a 65 78 70 32 3d 35 3a 77 72 6b 31 3d 31 34 |4:exp2=5:wrk1=14| 00001350 0d 06 68 0c 5b 4f 50 54 20 61 73 6d 0d 06 72 32 |..h.[OPT asm..r2| 00001360 3b 20 53 75 62 74 72 61 63 74 20 32 20 73 69 6e |; Subtract 2 sin| 00001370 67 6c 65 20 70 72 65 63 69 73 69 6f 6e 20 66 6c |gle precision fl| 00001380 6f 61 74 73 2d 20 52 30 3d 52 30 2d 52 31 0d 06 |oats- R0=R0-R1..| 00001390 7c 0b 2e 66 70 5f 73 75 62 0d 06 86 1a 53 54 4d ||..fp_sub....STM| 000013a0 46 44 20 52 31 33 21 2c 7b 52 32 2d 52 35 2c 52 |FD R13!,{R2-R5,R| 000013b0 31 34 7d 0d 06 90 37 4d 4f 56 20 65 78 70 31 2c |14}...7MOV exp1,| 000013c0 52 30 2c 4c 53 52 20 23 32 33 20 20 20 20 20 20 |R0,LSR #23 | 000013d0 20 20 20 20 20 20 20 3b 20 67 65 74 20 65 78 70 | ; get exp| 000013e0 6f 6e 65 6e 74 2b 73 69 67 6e 0d 06 9a 32 42 49 |onent+sign...2BI| 000013f0 43 20 6d 61 6e 74 31 2c 52 30 2c 65 78 70 31 2c |C mant1,R0,exp1,| 00001400 4c 53 4c 20 23 32 33 20 20 20 20 20 20 20 3b 20 |LSL #23 ; | 00001410 67 65 74 20 6d 61 6e 74 69 73 73 61 0d 06 a4 0d |get mantissa....| 00001420 43 4d 50 20 52 30 2c 23 30 0d 06 ae 40 84 52 4e |CMP R0,#0...@.RN| 00001430 45 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c 23 31 |E mant1,mant1,#1| 00001440 3c 3c 32 33 20 20 20 20 20 20 20 20 3b 20 73 65 |<<23 ; se| 00001450 74 20 6f 6e 20 62 69 74 20 74 6f 20 6c 65 66 74 |t on bit to left| 00001460 20 6f 66 20 70 6f 69 6e 74 0d 06 b8 2f 80 20 65 | of point.../. e| 00001470 78 70 31 2c 65 78 70 31 2c 23 32 35 35 20 20 20 |xp1,exp1,#255 | 00001480 20 20 20 20 20 20 20 20 20 20 20 3b 20 72 65 6d | ; rem| 00001490 6f 76 65 20 73 69 67 6e 0d 06 c2 05 3b 0d 06 cc |ove sign....;...| 000014a0 37 4d 4f 56 20 65 78 70 32 2c 52 31 2c 4c 53 52 |7MOV exp2,R1,LSR| 000014b0 20 23 32 33 20 20 20 20 20 20 20 20 20 20 20 20 | #23 | 000014c0 20 3b 20 67 65 74 20 65 78 70 6f 6e 65 6e 74 2b | ; get exponent+| 000014d0 73 69 67 6e 0d 06 d6 32 42 49 43 20 6d 61 6e 74 |sign...2BIC mant| 000014e0 32 2c 52 31 2c 65 78 70 32 2c 4c 53 4c 20 23 32 |2,R1,exp2,LSL #2| 000014f0 33 20 20 20 20 20 20 20 3b 20 67 65 74 20 6d 61 |3 ; get ma| 00001500 6e 74 69 73 73 61 0d 06 e0 0d 43 4d 50 20 52 31 |ntissa....CMP R1| 00001510 2c 23 30 0d 06 ea 40 84 52 4e 45 20 6d 61 6e 74 |,#0...@.RNE mant| 00001520 32 2c 6d 61 6e 74 32 2c 23 31 3c 3c 32 33 20 20 |2,mant2,#1<<23 | 00001530 20 20 20 20 20 20 3b 20 73 65 74 20 6f 6e 20 62 | ; set on b| 00001540 69 74 20 74 6f 20 6c 65 66 74 20 6f 66 20 70 6f |it to left of po| 00001550 69 6e 74 0d 06 f4 2f 80 20 65 78 70 32 2c 65 78 |int.../. exp2,ex| 00001560 70 32 2c 23 32 35 35 20 20 20 20 20 20 20 20 20 |p2,#255 | 00001570 20 20 20 20 20 3b 20 72 65 6d 6f 76 65 20 73 69 | ; remove si| 00001580 67 6e 0d 06 fe 05 3b 0d 07 08 31 82 53 20 77 72 |gn....;...1.S wr| 00001590 6b 31 2c 52 30 2c 52 31 20 20 20 20 20 20 20 20 |k1,R0,R1 | 000015a0 20 20 20 20 20 20 20 20 20 3b 20 62 6f 74 68 20 | ; both | 000015b0 2b 76 65 2f 2d 76 65 3f 0d 07 12 37 42 4d 49 20 |+ve/-ve?...7BMI | 000015c0 66 70 5f 73 75 62 5f 75 6e 65 71 75 61 6c 20 20 |fp_sub_unequal | 000015d0 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 6e 6f | ; no| 000015e0 20 2d 20 73 70 65 63 69 61 6c 20 63 61 73 65 0d | - special case.| 000015f0 07 1c 05 3b 0d 07 26 35 53 55 42 53 20 77 72 6b |...;..&5SUBS wrk| 00001600 31 2c 65 78 70 31 2c 65 78 70 32 20 20 20 20 20 |1,exp1,exp2 | 00001610 20 20 20 20 20 20 20 20 3b 20 65 78 70 2e 20 64 | ; exp. d| 00001620 69 66 66 65 72 65 6e 63 65 0d 07 30 4d 53 55 42 |ifference..0MSUB| 00001630 50 4c 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c 6d |PL mant1,mant1,m| 00001640 61 6e 74 32 2c 4c 53 52 20 77 72 6b 31 20 20 20 |ant2,LSR wrk1 | 00001650 20 20 20 3b 20 65 78 70 31 3e 65 78 70 32 2c 20 | ; exp1>exp2, | 00001660 72 6f 75 6e 64 20 6d 61 6e 74 32 20 26 20 73 75 |round mant2 & su| 00001670 62 74 72 61 63 74 0d 07 3a 37 52 53 42 4d 49 20 |btract..:7RSBMI | 00001680 77 72 6b 31 2c 77 72 6b 31 2c 23 30 20 20 20 20 |wrk1,wrk1,#0 | 00001690 20 20 20 20 20 20 20 20 20 20 3b 20 61 73 20 2b | ; as +| 000016a0 76 65 20 64 69 66 66 65 72 65 6e 63 65 0d 07 44 |ve difference..D| 000016b0 4d 52 53 42 4d 49 20 6d 61 6e 74 31 2c 6d 61 6e |MRSBMI mant1,man| 000016c0 74 32 2c 6d 61 6e 74 31 2c 4c 53 52 20 77 72 6b |t2,mant1,LSR wrk| 000016d0 31 20 20 20 20 20 20 3b 20 65 78 70 31 3c 65 78 |1 ; exp1<ex| 000016e0 70 32 2c 20 72 6f 75 6e 64 20 6d 61 6e 74 31 20 |p2, round mant1 | 000016f0 26 20 73 75 62 74 72 61 63 74 0d 07 4e 38 4d 4f |& subtract..N8MO| 00001700 56 4d 49 20 65 78 70 31 2c 65 78 70 32 20 20 20 |VMI exp1,exp2 | 00001710 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00001720 65 78 70 6f 6e 65 6e 74 20 6f 66 20 72 65 73 75 |exponent of resu| 00001730 6c 74 0d 07 58 3a 80 20 52 30 2c 52 30 2c 23 31 |lt..X:. R0,R0,#1| 00001740 3c 3c 33 31 20 20 20 20 20 20 20 20 20 20 20 20 |<<31 | 00001750 20 20 20 20 3b 20 64 65 66 61 75 6c 74 20 73 69 | ; default si| 00001760 67 6e 20 6f 66 20 72 65 73 75 6c 74 0d 07 62 30 |gn of result..b0| 00001770 43 4d 50 20 6d 61 6e 74 31 2c 23 30 20 20 20 20 |CMP mant1,#0 | 00001780 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001790 3b 20 66 6c 69 70 20 73 69 67 6e 3f 0d 07 6c 39 |; flip sign?..l9| 000017a0 52 53 42 4d 49 20 6d 61 6e 74 31 2c 6d 61 6e 74 |RSBMI mant1,mant| 000017b0 31 2c 23 30 20 20 20 20 20 20 20 20 20 20 20 20 |1,#0 | 000017c0 3b 20 79 65 73 20 2d 20 66 6c 69 70 20 6d 61 6e |; yes - flip man| 000017d0 74 69 73 73 61 0d 07 76 32 82 4d 49 20 52 30 2c |tissa..v2.MI R0,| 000017e0 52 30 2c 23 31 3c 3c 33 31 20 20 20 20 20 20 20 |R0,#1<<31 | 000017f0 20 20 20 20 20 20 20 3b 20 61 6e 64 20 66 69 6e | ; and fin| 00001800 61 6c 20 73 69 67 6e 0d 07 80 33 3b 20 4e 6f 72 |al sign...3; Nor| 00001810 6d 61 6c 69 73 65 20 72 65 73 75 6c 74 20 2d 20 |malise result - | 00001820 61 64 6a 75 73 74 20 6d 61 6e 74 69 73 73 61 20 |adjust mantissa | 00001830 26 20 65 78 70 6f 6e 65 6e 74 0d 07 8a 40 43 4d |& exponent...@CM| 00001840 50 20 6d 61 6e 74 31 2c 23 30 20 20 20 20 20 20 |P mant1,#0 | 00001850 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00001860 63 68 65 63 6b 20 66 6f 72 20 30 20 2d 20 73 70 |check for 0 - sp| 00001870 65 63 69 61 6c 20 63 61 73 65 0d 07 94 0c ec 51 |ecial case.....Q| 00001880 20 52 30 2c 23 30 0d 07 9e 13 42 45 51 20 66 70 | R0,#0....BEQ fp| 00001890 5f 73 75 62 5f 65 78 69 74 0d 07 a8 13 2e 66 70 |_sub_exit.....fp| 000018a0 5f 73 75 62 5f 72 6f 75 6e 64 75 70 0d 07 b2 14 |_sub_roundup....| 000018b0 54 53 54 20 6d 61 6e 74 31 2c 23 31 3c 3c 32 33 |TST mant1,#1<<23| 000018c0 0d 07 bc 17 42 4e 45 20 66 70 5f 73 75 62 5f 6e |....BNE fp_sub_n| 000018d0 6f 72 6d 65 78 69 74 0d 07 c6 14 53 55 42 20 65 |ormexit....SUB e| 000018e0 78 70 31 2c 65 78 70 31 2c 23 31 0d 07 d0 1a 4d |xp1,exp1,#1....M| 000018f0 4f 56 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c 4c |OV mant1,mant1,L| 00001900 53 4c 20 23 31 0d 07 da 14 42 20 66 70 5f 73 75 |SL #1....B fp_su| 00001910 62 5f 72 6f 75 6e 64 75 70 0d 07 e4 05 3b 0d 07 |b_roundup....;..| 00001920 ee 28 3b 20 52 30 20 26 20 52 31 20 68 61 76 65 |.(; R0 & R1 have| 00001930 20 64 69 66 66 65 72 65 6e 74 20 73 69 67 6e 73 | different signs| 00001940 20 2d 20 61 64 64 0d 07 f8 13 2e 66 70 5f 73 75 | - add.....fp_su| 00001950 62 5f 75 6e 65 71 75 61 6c 0d 08 02 35 53 55 42 |b_unequal...5SUB| 00001960 53 20 77 72 6b 31 2c 65 78 70 31 2c 65 78 70 32 |S wrk1,exp1,exp2| 00001970 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 65 | ; e| 00001980 78 70 2e 20 64 69 66 66 65 72 65 6e 63 65 0d 08 |xp. difference..| 00001990 0c 48 41 44 44 50 4c 20 6d 61 6e 74 31 2c 6d 61 |.HADDPL mant1,ma| 000019a0 6e 74 31 2c 6d 61 6e 74 32 2c 4c 53 52 20 77 72 |nt1,mant2,LSR wr| 000019b0 6b 31 20 20 20 20 20 20 3b 20 65 78 70 31 3e 65 |k1 ; exp1>e| 000019c0 78 70 32 2c 20 72 6f 75 6e 64 20 6d 61 6e 74 32 |xp2, round mant2| 000019d0 20 26 20 61 64 64 0d 08 16 37 52 53 42 4d 49 20 | & add...7RSBMI | 000019e0 77 72 6b 31 2c 77 72 6b 31 2c 23 30 20 20 20 20 |wrk1,wrk1,#0 | 000019f0 20 20 20 20 20 20 20 20 20 20 3b 20 61 73 20 2b | ; as +| 00001a00 76 65 20 64 69 66 66 65 72 65 6e 63 65 0d 08 20 |ve difference.. | 00001a10 48 41 44 44 4d 49 20 6d 61 6e 74 31 2c 6d 61 6e |HADDMI mant1,man| 00001a20 74 32 2c 6d 61 6e 74 31 2c 4c 53 52 20 77 72 6b |t2,mant1,LSR wrk| 00001a30 31 20 20 20 20 20 20 3b 20 65 78 70 31 3c 65 78 |1 ; exp1<ex| 00001a40 70 32 2c 20 72 6f 75 6e 64 20 6d 61 6e 74 31 20 |p2, round mant1 | 00001a50 26 20 61 64 64 0d 08 2a 38 4d 4f 56 4d 49 20 65 |& add..*8MOVMI e| 00001a60 78 70 31 2c 65 78 70 32 20 20 20 20 20 20 20 20 |xp1,exp2 | 00001a70 20 20 20 20 20 20 20 20 20 3b 20 65 78 70 6f 6e | ; expon| 00001a80 65 6e 74 20 6f 66 20 72 65 73 75 6c 74 0d 08 34 |ent of result..4| 00001a90 32 80 20 52 30 2c 52 30 2c 23 31 3c 3c 33 31 20 |2. R0,R0,#1<<31 | 00001aa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b | ;| 00001ab0 20 73 69 67 6e 20 6f 66 20 72 65 73 75 6c 74 0d | sign of result.| 00001ac0 08 3e 33 3b 20 4e 6f 72 6d 61 6c 69 73 65 20 72 |.>3; Normalise r| 00001ad0 65 73 75 6c 74 20 2d 20 61 64 6a 75 73 74 20 6d |esult - adjust m| 00001ae0 61 6e 74 69 73 73 61 20 26 20 65 78 70 6f 6e 65 |antissa & expone| 00001af0 6e 74 0d 08 48 15 2e 66 70 5f 73 75 62 5f 72 6f |nt..H..fp_sub_ro| 00001b00 75 6e 64 64 6f 77 6e 0d 08 52 14 43 4d 50 20 6d |unddown..R.CMP m| 00001b10 61 6e 74 31 2c 23 31 3c 3c 32 34 0d 08 5c 17 42 |ant1,#1<<24..\.B| 00001b20 4c 54 20 66 70 5f 73 75 62 5f 6e 6f 72 6d 65 78 |LT fp_sub_normex| 00001b30 69 74 0d 08 66 14 41 44 44 20 65 78 70 31 2c 65 |it..f.ADD exp1,e| 00001b40 78 70 31 2c 23 31 0d 08 70 1a 4d 4f 56 20 6d 61 |xp1,#1..p.MOV ma| 00001b50 6e 74 31 2c 6d 61 6e 74 31 2c 4c 53 52 20 23 31 |nt1,mant1,LSR #1| 00001b60 0d 08 7a 16 42 20 66 70 5f 73 75 62 5f 72 6f 75 |..z.B fp_sub_rou| 00001b70 6e 64 64 6f 77 6e 0d 08 84 14 3b 20 63 6f 6d 62 |nddown....; comb| 00001b80 69 6e 65 20 72 65 73 75 6c 74 0d 08 8e 14 2e 66 |ine result.....f| 00001b90 70 5f 73 75 62 5f 6e 6f 72 6d 65 78 69 74 0d 08 |p_sub_normexit..| 00001ba0 98 31 84 52 20 52 30 2c 52 30 2c 65 78 70 31 2c |.1.R R0,R0,exp1,| 00001bb0 4c 53 4c 20 23 32 33 20 20 20 20 20 20 20 20 20 |LSL #23 | 00001bc0 20 3b 20 73 65 74 20 65 78 70 6f 6e 65 6e 74 0d | ; set exponent.| 00001bd0 08 a2 34 42 49 43 20 6d 61 6e 74 31 2c 6d 61 6e |..4BIC mant1,man| 00001be0 74 31 2c 23 31 3c 3c 32 33 20 20 20 20 20 20 20 |t1,#1<<23 | 00001bf0 20 20 20 3b 20 63 6c 65 61 72 20 68 69 2d 6f 72 | ; clear hi-or| 00001c00 64 65 72 0d 08 ac 30 84 52 20 52 30 2c 52 30 2c |der...0.R R0,R0,| 00001c10 6d 61 6e 74 31 20 20 20 20 20 20 20 20 20 20 20 |mant1 | 00001c20 20 20 20 20 20 20 3b 20 66 75 6c 6c 20 72 65 73 | ; full res| 00001c30 75 6c 74 0d 08 b6 10 2e 66 70 5f 73 75 62 5f 65 |ult.....fp_sub_e| 00001c40 78 69 74 0d 08 c0 1a 4c 44 4d 46 44 20 52 31 33 |xit....LDMFD R13| 00001c50 21 2c 7b 52 32 2d 52 35 2c 50 43 7d 5e 0d 08 ca |!,{R2-R5,PC}^...| 00001c60 08 5d 3a 3d 30 0d 08 d4 05 3a 0d 08 de 10 dd a4 |.]:=0....:......| 00001c70 66 70 5f 6d 75 6c 5f 61 73 6d 0d 08 e8 29 6d 61 |fp_mul_asm...)ma| 00001c80 6e 74 31 3d 32 3a 65 78 70 31 3d 33 3a 6d 61 6e |nt1=2:exp1=3:man| 00001c90 74 32 3d 31 3a 65 78 70 32 3d 34 3a 77 72 6b 31 |t2=1:exp2=4:wrk1| 00001ca0 3d 31 34 0d 08 f2 0d 52 65 73 48 69 67 68 3d 34 |=14....ResHigh=4| 00001cb0 0d 08 fc 0c 5b 4f 50 54 20 61 73 6d 0d 09 06 32 |....[OPT asm...2| 00001cc0 3b 20 4d 75 6c 74 69 70 6c 79 20 32 20 73 69 6e |; Multiply 2 sin| 00001cd0 67 6c 65 20 70 72 65 63 69 73 69 6f 6e 20 66 6c |gle precision fl| 00001ce0 6f 61 74 73 2d 20 52 30 3d 52 30 2a 52 31 0d 09 |oats- R0=R0*R1..| 00001cf0 10 0b 2e 66 70 5f 6d 75 6c 0d 09 1a 1a 53 54 4d |...fp_mul....STM| 00001d00 46 44 20 52 31 33 21 2c 7b 52 32 2d 52 34 2c 52 |FD R13!,{R2-R4,R| 00001d10 31 34 7d 0d 09 24 1b 3b 20 43 68 65 63 6b 20 66 |14}..$.; Check f| 00001d20 6f 72 20 6e 75 6c 6c 20 72 65 73 75 6c 74 0d 09 |or null result..| 00001d30 2e 0d 43 4d 50 20 52 30 2c 23 30 0d 09 38 0f 43 |..CMP R0,#0..8.C| 00001d40 4d 50 4e 45 20 52 31 2c 23 30 0d 09 42 0c ec 51 |MPNE R1,#0..B..Q| 00001d50 20 52 30 2c 23 30 0d 09 4c 13 42 45 51 20 66 70 | R0,#0..L.BEQ fp| 00001d60 5f 6d 75 6c 5f 65 78 69 74 0d 09 56 05 3b 0d 09 |_mul_exit..V.;..| 00001d70 60 37 4d 4f 56 20 65 78 70 31 2c 52 30 2c 4c 53 |`7MOV exp1,R0,LS| 00001d80 52 20 23 32 33 20 20 20 20 20 20 20 20 20 20 20 |R #23 | 00001d90 20 20 3b 20 67 65 74 20 65 78 70 6f 6e 65 6e 74 | ; get exponent| 00001da0 2b 73 69 67 6e 0d 09 6a 32 42 49 43 20 6d 61 6e |+sign..j2BIC man| 00001db0 74 31 2c 52 30 2c 65 78 70 31 2c 4c 53 4c 20 23 |t1,R0,exp1,LSL #| 00001dc0 32 33 20 20 20 20 20 20 20 3b 20 67 65 74 20 6d |23 ; get m| 00001dd0 61 6e 74 69 73 73 61 0d 09 74 40 84 52 20 6d 61 |antissa..t@.R ma| 00001de0 6e 74 31 2c 6d 61 6e 74 31 2c 23 31 3c 3c 32 33 |nt1,mant1,#1<<23| 00001df0 20 20 20 20 20 20 20 20 20 20 3b 20 73 65 74 20 | ; set | 00001e00 6f 6e 20 62 69 74 20 74 6f 20 6c 65 66 74 20 6f |on bit to left o| 00001e10 66 20 70 6f 69 6e 74 0d 09 7e 2f 80 20 65 78 70 |f point..~/. exp| 00001e20 31 2c 65 78 70 31 2c 23 32 35 35 20 20 20 20 20 |1,exp1,#255 | 00001e30 20 20 20 20 20 20 20 20 20 3b 20 72 65 6d 6f 76 | ; remov| 00001e40 65 20 73 69 67 6e 0d 09 88 05 3b 0d 09 92 32 82 |e sign....;...2.| 00001e50 20 52 30 2c 52 30 2c 52 31 20 20 20 20 20 20 20 | R0,R0,R1 | 00001e60 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 73 | ; s| 00001e70 69 67 6e 20 6f 66 20 72 65 73 75 6c 74 0d 09 9c |ign of result...| 00001e80 38 80 20 52 30 2c 52 30 2c 23 31 3c 3c 33 31 20 |8. R0,R0,#1<<31 | 00001e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b | ;| 00001ea0 20 63 6c 65 61 72 20 72 65 73 74 20 6f 66 20 72 | clear rest of r| 00001eb0 65 73 75 6c 74 0d 09 a6 05 3b 0d 09 b0 37 4d 4f |esult....;...7MO| 00001ec0 56 20 65 78 70 32 2c 52 31 2c 4c 53 52 20 23 32 |V exp2,R1,LSR #2| 00001ed0 33 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 |3 ; | 00001ee0 67 65 74 20 65 78 70 6f 6e 65 6e 74 2b 73 69 67 |get exponent+sig| 00001ef0 6e 0d 09 ba 32 42 49 43 20 6d 61 6e 74 32 2c 52 |n...2BIC mant2,R| 00001f00 31 2c 65 78 70 32 2c 4c 53 4c 20 23 32 33 20 20 |1,exp2,LSL #23 | 00001f10 20 20 20 20 20 3b 20 67 65 74 20 6d 61 6e 74 69 | ; get manti| 00001f20 73 73 61 0d 09 c4 40 84 52 20 6d 61 6e 74 32 2c |ssa...@.R mant2,| 00001f30 6d 61 6e 74 32 2c 23 31 3c 3c 32 33 20 20 20 20 |mant2,#1<<23 | 00001f40 20 20 20 20 20 20 3b 20 73 65 74 20 6f 6e 20 62 | ; set on b| 00001f50 69 74 20 74 6f 20 6c 65 66 74 20 6f 66 20 70 6f |it to left of po| 00001f60 69 6e 74 0d 09 ce 2f 80 20 65 78 70 32 2c 65 78 |int.../. exp2,ex| 00001f70 70 32 2c 23 32 35 35 20 20 20 20 20 20 20 20 20 |p2,#255 | 00001f80 20 20 20 20 20 3b 20 72 65 6d 6f 76 65 20 73 69 | ; remove si| 00001f90 67 6e 0d 09 d8 05 3b 0d 09 e2 16 41 44 44 20 65 |gn....;....ADD e| 00001fa0 78 70 31 2c 65 78 70 31 2c 65 78 70 32 0d 09 ec |xp1,exp1,exp2...| 00001fb0 35 53 55 42 53 20 65 78 70 31 2c 65 78 70 31 2c |5SUBS exp1,exp1,| 00001fc0 23 31 32 37 20 20 20 20 20 20 20 20 20 20 20 20 |#127 | 00001fd0 20 3b 20 65 78 70 6f 6e 65 6e 74 20 72 65 73 75 | ; exponent resu| 00001fe0 6c 74 0d 09 f6 2f 4d 4f 56 4d 49 20 52 30 2c 23 |lt.../MOVMI R0,#| 00001ff0 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |0 | 00002000 20 20 20 20 20 20 3b 20 75 6e 64 65 72 66 6c 6f | ; underflo| 00002010 77 0d 0a 00 13 42 4d 49 20 66 70 5f 6d 75 6c 5f |w....BMI fp_mul_| 00002020 65 78 69 74 0d 0a 0a 2a 3b 20 44 6f 20 74 68 65 |exit...*; Do the| 00002030 20 6d 75 6c 74 69 70 6c 79 20 74 6f 20 33 30 20 | multiply to 30 | 00002040 62 69 74 73 20 70 72 65 63 69 73 69 6f 6e 0d 0a |bits precision..| 00002050 14 31 4d 4f 56 20 77 72 6b 31 2c 6d 61 6e 74 31 |.1MOV wrk1,mant1| 00002060 2c 4c 53 52 23 39 20 20 20 20 20 20 20 20 20 20 |,LSR#9 | 00002070 20 20 3b 20 74 6f 70 20 31 35 20 62 69 74 73 0d | ; top 15 bits.| 00002080 0a 1e 31 4d 4f 56 20 52 65 73 48 69 67 68 2c 6d |..1MOV ResHigh,m| 00002090 61 6e 74 32 2c 4c 53 52 23 39 20 20 20 20 20 20 |ant2,LSR#9 | 000020a0 20 20 20 3b 20 74 6f 70 20 31 35 20 62 69 74 73 | ; top 15 bits| 000020b0 0d 0a 28 31 42 49 43 20 6d 61 6e 74 31 2c 6d 61 |..(1BIC mant1,ma| 000020c0 6e 74 31 2c 77 72 6b 31 2c 4c 53 4c 23 39 20 20 |nt1,wrk1,LSL#9 | 000020d0 20 20 20 20 3b 20 6c 6f 77 20 20 39 20 62 69 74 | ; low 9 bit| 000020e0 73 0d 0a 32 31 42 49 43 20 6d 61 6e 74 32 2c 6d |s..21BIC mant2,m| 000020f0 61 6e 74 32 2c 52 65 73 48 69 67 68 2c 4c 53 4c |ant2,ResHigh,LSL| 00002100 23 39 20 20 20 3b 20 6c 6f 77 20 20 39 20 62 69 |#9 ; low 9 bi| 00002110 74 73 0d 0a 3c 2d 4d 55 4c 20 6d 61 6e 74 32 2c |ts..<-MUL mant2,| 00002120 77 72 6b 31 2c 6d 61 6e 74 32 20 20 20 20 20 20 |wrk1,mant2 | 00002130 20 20 20 20 20 20 3b 20 74 6f 70 2a 6c 6f 77 0d | ; top*low.| 00002140 0a 46 2d 4d 55 4c 20 6d 61 6e 74 31 2c 52 65 73 |.F-MUL mant1,Res| 00002150 48 69 67 68 2c 6d 61 6e 74 31 20 20 20 20 20 20 |High,mant1 | 00002160 20 20 20 3b 20 6c 6f 77 2a 74 6f 70 0d 0a 50 2d | ; low*top..P-| 00002170 4d 55 4c 20 52 65 73 48 69 67 68 2c 77 72 6b 31 |MUL ResHigh,wrk1| 00002180 2c 52 65 73 48 69 67 68 20 20 20 20 20 20 20 20 |,ResHigh | 00002190 3b 20 74 6f 70 2a 74 6f 70 0d 0a 5a 37 41 44 44 |; top*top..Z7ADD| 000021a0 20 52 65 73 48 69 67 68 2c 52 65 73 48 69 67 68 | ResHigh,ResHigh| 000021b0 2c 6d 61 6e 74 31 2c 4c 53 52 23 39 20 3b 20 74 |,mant1,LSR#9 ; t| 000021c0 6f 70 20 2b 20 6d 69 64 64 6c 65 20 62 69 74 31 |op + middle bit1| 000021d0 0d 0a 64 37 41 44 44 20 52 65 73 48 69 67 68 2c |..d7ADD ResHigh,| 000021e0 52 65 73 48 69 67 68 2c 6d 61 6e 74 32 2c 4c 53 |ResHigh,mant2,LS| 000021f0 52 23 39 20 3b 20 74 6f 70 20 2b 20 6d 69 64 64 |R#9 ; top + midd| 00002200 6c 65 20 62 69 74 32 0d 0a 6e 16 3b 20 41 64 6a |le bit2..n.; Adj| 00002210 75 73 74 20 66 6f 72 20 63 61 72 72 79 0d 0a 78 |ust for carry..x| 00002220 16 54 53 54 20 52 65 73 48 69 67 68 2c 23 31 3c |.TST ResHigh,#1<| 00002230 3c 32 39 0d 0a 82 35 41 44 44 4e 45 20 65 78 70 |<29...5ADDNE exp| 00002240 31 2c 65 78 70 31 2c 23 31 20 20 20 20 20 20 20 |1,exp1,#1 | 00002250 20 20 20 20 20 20 20 3b 20 61 64 6a 75 73 74 20 | ; adjust | 00002260 65 78 70 6f 6e 65 6e 74 0d 0a 8c 38 4d 4f 56 4e |exponent...8MOVN| 00002270 45 20 52 65 73 48 69 67 68 2c 52 65 73 48 69 67 |E ResHigh,ResHig| 00002280 68 2c 4c 53 52 23 31 20 20 20 20 20 3b 20 73 68 |h,LSR#1 ; sh| 00002290 69 66 74 20 72 65 73 75 6c 74 20 72 69 67 68 74 |ift result right| 000022a0 0d 0a 96 14 3b 20 63 6f 6d 62 69 6e 65 20 72 65 |....; combine re| 000022b0 73 75 6c 74 0d 0a a0 31 84 52 20 52 30 2c 52 30 |sult...1.R R0,R0| 000022c0 2c 65 78 70 31 2c 4c 53 4c 20 23 32 33 20 20 20 |,exp1,LSL #23 | 000022d0 20 20 20 20 20 20 20 3b 20 73 65 74 20 65 78 70 | ; set exp| 000022e0 6f 6e 65 6e 74 0d 0a aa 34 42 49 43 20 52 65 73 |onent...4BIC Res| 000022f0 48 69 67 68 2c 52 65 73 48 69 67 68 2c 23 31 3c |High,ResHigh,#1<| 00002300 3c 32 38 20 20 20 20 20 20 3b 20 63 6c 65 61 72 |<28 ; clear| 00002310 20 68 69 2d 6f 72 64 65 72 0d 0a b4 30 84 52 20 | hi-order...0.R | 00002320 52 30 2c 52 30 2c 52 65 73 48 69 67 68 2c 4c 53 |R0,R0,ResHigh,LS| 00002330 52 20 23 35 20 20 20 20 20 20 20 20 3b 20 74 6f |R #5 ; to| 00002340 70 20 32 33 20 62 69 74 73 0d 0a be 10 2e 66 70 |p 23 bits.....fp| 00002350 5f 6d 75 6c 5f 65 78 69 74 0d 0a c8 1a 4c 44 4d |_mul_exit....LDM| 00002360 46 44 20 52 31 33 21 2c 7b 52 32 2d 52 34 2c 50 |FD R13!,{R2-R4,P| 00002370 43 7d 5e 0d 0a d2 08 5d 3a 3d 30 0d 0a dc 05 3a |C}^....]:=0....:| 00002380 0d 0a e6 10 dd a4 66 70 5f 64 69 76 5f 61 73 6d |......fp_div_asm| 00002390 0d 0a f0 22 6d 61 6e 74 31 3d 32 3a 65 78 70 31 |..."mant1=2:exp1| 000023a0 3d 33 3a 6d 61 6e 74 32 3d 34 3a 65 78 70 32 3d |=3:mant2=4:exp2=| 000023b0 31 34 0d 0a fa 0e 71 3d 31 3a 70 3d 65 78 70 32 |14....q=1:p=exp2| 000023c0 0d 0b 04 0c 5b 4f 50 54 20 61 73 6d 0d 0b 0e 30 |....[OPT asm...0| 000023d0 3b 20 44 69 76 69 64 65 20 32 20 73 69 6e 67 6c |; Divide 2 singl| 000023e0 65 20 70 72 65 63 69 73 69 6f 6e 20 66 6c 6f 61 |e precision floa| 000023f0 74 73 2d 20 52 30 3d 52 30 2f 52 31 0d 0b 18 0b |ts- R0=R0/R1....| 00002400 2e 66 70 5f 64 69 76 0d 0b 22 1a 53 54 4d 46 44 |.fp_div..".STMFD| 00002410 20 52 31 33 21 2c 7b 52 32 2d 52 34 2c 52 31 34 | R13!,{R2-R4,R14| 00002420 7d 0d 0b 2c 1b 3b 20 43 68 65 63 6b 20 66 6f 72 |}..,.; Check for| 00002430 20 6e 75 6c 6c 20 72 65 73 75 6c 74 0d 0b 36 0d | null result..6.| 00002440 43 4d 50 20 52 30 2c 23 30 0d 0b 40 0f 43 4d 50 |CMP R0,#0..@.CMP| 00002450 4e 45 20 52 31 2c 23 30 0d 0b 4a 0c ec 51 20 52 |NE R1,#0..J..Q R| 00002460 30 2c 23 30 0d 0b 54 13 42 45 51 20 66 70 5f 64 |0,#0..T.BEQ fp_d| 00002470 69 76 5f 65 78 69 74 0d 0b 5e 05 3b 0d 0b 68 37 |iv_exit..^.;..h7| 00002480 4d 4f 56 20 65 78 70 31 2c 52 30 2c 4c 53 52 20 |MOV exp1,R0,LSR | 00002490 23 32 33 20 20 20 20 20 20 20 20 20 20 20 20 20 |#23 | 000024a0 3b 20 67 65 74 20 65 78 70 6f 6e 65 6e 74 2b 73 |; get exponent+s| 000024b0 69 67 6e 0d 0b 72 32 42 49 43 20 6d 61 6e 74 31 |ign..r2BIC mant1| 000024c0 2c 52 30 2c 65 78 70 31 2c 4c 53 4c 20 23 32 33 |,R0,exp1,LSL #23| 000024d0 20 20 20 20 20 20 20 3b 20 67 65 74 20 6d 61 6e | ; get man| 000024e0 74 69 73 73 61 0d 0b 7c 40 84 52 20 6d 61 6e 74 |tissa..|@.R mant| 000024f0 31 2c 6d 61 6e 74 31 2c 23 31 3c 3c 32 33 20 20 |1,mant1,#1<<23 | 00002500 20 20 20 20 20 20 20 20 3b 20 73 65 74 20 6f 6e | ; set on| 00002510 20 62 69 74 20 74 6f 20 6c 65 66 74 20 6f 66 20 | bit to left of | 00002520 70 6f 69 6e 74 0d 0b 86 2f 80 20 65 78 70 31 2c |point.../. exp1,| 00002530 65 78 70 31 2c 23 32 35 35 20 20 20 20 20 20 20 |exp1,#255 | 00002540 20 20 20 20 20 20 20 3b 20 72 65 6d 6f 76 65 20 | ; remove | 00002550 73 69 67 6e 0d 0b 90 05 3b 0d 0b 9a 37 4d 4f 56 |sign....;...7MOV| 00002560 20 65 78 70 32 2c 52 31 2c 4c 53 52 20 23 32 33 | exp2,R1,LSR #23| 00002570 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 67 | ; g| 00002580 65 74 20 65 78 70 6f 6e 65 6e 74 2b 73 69 67 6e |et exponent+sign| 00002590 0d 0b a4 32 42 49 43 20 6d 61 6e 74 32 2c 52 31 |...2BIC mant2,R1| 000025a0 2c 65 78 70 32 2c 4c 53 4c 20 23 32 33 20 20 20 |,exp2,LSL #23 | 000025b0 20 20 20 20 3b 20 67 65 74 20 6d 61 6e 74 69 73 | ; get mantis| 000025c0 73 61 0d 0b ae 40 84 52 20 6d 61 6e 74 32 2c 6d |sa...@.R mant2,m| 000025d0 61 6e 74 32 2c 23 31 3c 3c 32 33 20 20 20 20 20 |ant2,#1<<23 | 000025e0 20 20 20 20 20 3b 20 73 65 74 20 6f 6e 20 62 69 | ; set on bi| 000025f0 74 20 74 6f 20 6c 65 66 74 20 6f 66 20 70 6f 69 |t to left of poi| 00002600 6e 74 0d 0b b8 2f 80 20 65 78 70 32 2c 65 78 70 |nt.../. exp2,exp| 00002610 32 2c 23 32 35 35 20 20 20 20 20 20 20 20 20 20 |2,#255 | 00002620 20 20 20 20 3b 20 72 65 6d 6f 76 65 20 73 69 67 | ; remove sig| 00002630 6e 0d 0b c2 05 3b 0d 0b cc 16 53 55 42 20 65 78 |n....;....SUB ex| 00002640 70 31 2c 65 78 70 31 2c 65 78 70 32 0d 0b d6 35 |p1,exp1,exp2...5| 00002650 41 44 44 53 20 65 78 70 31 2c 65 78 70 31 2c 23 |ADDS exp1,exp1,#| 00002660 31 32 37 20 20 20 20 20 20 20 20 20 20 20 20 20 |127 | 00002670 3b 20 65 78 70 6f 6e 65 6e 74 20 72 65 73 75 6c |; exponent resul| 00002680 74 0d 0b e0 2f 4d 4f 56 4d 49 20 52 30 2c 23 30 |t.../MOVMI R0,#0| 00002690 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000026a0 20 20 20 20 20 3b 20 75 6e 64 65 72 66 6c 6f 77 | ; underflow| 000026b0 0d 0b ea 13 42 4d 49 20 66 70 5f 64 69 76 5f 65 |....BMI fp_div_e| 000026c0 78 69 74 0d 0b f4 32 82 20 52 30 2c 52 30 2c 52 |xit...2. R0,R0,R| 000026d0 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |1 | 000026e0 20 20 20 20 20 3b 20 73 69 67 6e 20 6f 66 20 72 | ; sign of r| 000026f0 65 73 75 6c 74 0d 0b fe 38 80 20 52 30 2c 52 30 |esult...8. R0,R0| 00002700 2c 23 31 3c 3c 33 31 20 20 20 20 20 20 20 20 20 |,#1<<31 | 00002710 20 20 20 20 20 20 20 3b 20 63 6c 65 61 72 20 72 | ; clear r| 00002720 65 73 74 20 6f 66 20 72 65 73 75 6c 74 0d 0c 08 |est of result...| 00002730 25 3b 20 44 6f 20 74 68 65 20 64 69 76 69 64 65 |%; Do the divide| 00002740 20 74 6f 20 66 75 6c 6c 20 70 72 65 63 69 73 69 | to full precisi| 00002750 6f 6e 0d 0c 12 2e 4d 4f 56 20 71 2c 23 30 20 20 |on....MOV q,#0 | 00002760 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002770 20 20 20 20 20 20 3b 20 71 75 6f 74 69 65 6e 74 | ; quotient| 00002780 0d 0c 1c 40 4d 4f 56 20 70 2c 23 31 3c 3c 32 33 |...@MOV p,#1<<23| 00002790 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000027a0 20 20 20 20 3b 20 6e 75 6d 62 65 72 20 62 69 6e | ; number bin| 000027b0 61 72 79 20 70 6c 61 63 65 73 20 74 6f 20 64 6f |ary places to do| 000027c0 0d 0c 26 36 2e 66 70 5f 64 69 76 6c 6f 6f 70 20 |..&6.fp_divloop | 000027d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000027e0 20 20 20 20 3b 20 64 6f 20 62 69 6e 61 72 79 20 | ; do binary | 000027f0 70 6c 61 63 65 73 0d 0c 30 35 43 4d 50 20 6d 61 |places..05CMP ma| 00002800 6e 74 31 2c 6d 61 6e 74 32 20 20 20 20 20 20 20 |nt1,mant2 | 00002810 20 20 20 20 20 20 20 20 20 20 3b 20 6e 75 6d 62 | ; numb| 00002820 65 72 3e 64 69 76 69 73 6f 72 3f 0d 0c 3a 42 84 |er>divisor?..:B.| 00002830 52 43 53 20 71 2c 71 2c 70 20 20 20 20 20 20 20 |RCS q,q,p | 00002840 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00002850 79 65 73 20 2d 20 73 65 74 20 62 69 74 20 69 6e |yes - set bit in| 00002860 20 62 69 6e 61 72 79 20 70 6c 61 63 65 0d 0c 44 | binary place..D| 00002870 3d 53 55 42 43 53 20 6d 61 6e 74 31 2c 6d 61 6e |=SUBCS mant1,man| 00002880 74 31 2c 6d 61 6e 74 32 20 20 20 20 20 20 20 20 |t1,mant2 | 00002890 20 3b 20 64 69 73 63 61 72 64 20 61 63 63 6f 75 | ; discard accou| 000028a0 6e 74 65 64 20 76 61 6c 75 65 0d 0c 4e 40 4d 4f |nted value..N@MO| 000028b0 56 53 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c 4c |VS mant1,mant1,L| 000028c0 53 4c 20 23 31 20 20 20 20 20 20 20 20 20 3b 20 |SL #1 ; | 000028d0 73 68 69 66 74 20 75 70 20 72 65 6d 61 69 6e 64 |shift up remaind| 000028e0 65 72 2c 20 69 66 20 61 6e 79 0d 0c 58 45 4d 4f |er, if any..XEMO| 000028f0 56 4e 45 53 20 70 2c 70 2c 4c 53 52 23 31 20 20 |VNES p,p,LSR#1 | 00002900 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00002910 6e 65 78 74 20 62 69 6e 61 72 79 20 70 6c 61 63 |next binary plac| 00002920 65 2c 20 69 66 20 72 65 6d 61 69 6e 64 65 72 0d |e, if remainder.| 00002930 0c 62 37 42 4e 45 20 66 70 5f 64 69 76 6c 6f 6f |.b7BNE fp_divloo| 00002940 70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |p | 00002950 20 20 20 3b 20 6e 65 78 74 20 70 6c 61 63 65 20 | ; next place | 00002960 69 66 20 61 6e 79 0d 0c 6c 05 3b 0d 0c 76 30 43 |if any..l.;..v0C| 00002970 4d 50 20 71 2c 23 31 3c 3c 32 33 20 20 20 20 20 |MP q,#1<<23 | 00002980 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b | ;| 00002990 20 6e 6f 72 6d 61 6c 69 73 65 3f 0d 0c 80 3a 53 | normalise?...:S| 000029a0 55 42 4c 54 20 65 78 70 31 2c 65 78 70 31 2c 23 |UBLT exp1,exp1,#| 000029b0 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b |1 ;| 000029c0 20 79 65 73 2c 20 61 64 6a 75 73 74 20 65 78 70 | yes, adjust exp| 000029d0 6f 6e 65 6e 74 0d 0c 8a 30 4d 4f 56 4c 54 20 71 |onent...0MOVLT q| 000029e0 2c 71 2c 4c 53 4c 20 23 31 20 20 20 20 20 20 20 |,q,LSL #1 | 000029f0 20 20 20 20 20 20 20 20 20 3b 20 26 20 6d 61 6e | ; & man| 00002a00 74 69 73 73 61 0d 0c 94 14 3b 20 63 6f 6d 62 69 |tissa....; combi| 00002a10 6e 65 20 72 65 73 75 6c 74 0d 0c 9e 31 84 52 20 |ne result...1.R | 00002a20 52 30 2c 52 30 2c 65 78 70 31 2c 4c 53 4c 20 23 |R0,R0,exp1,LSL #| 00002a30 32 33 20 20 20 20 20 20 20 20 20 20 3b 20 73 65 |23 ; se| 00002a40 74 20 65 78 70 6f 6e 65 6e 74 0d 0c a8 34 42 49 |t exponent...4BI| 00002a50 43 20 71 2c 71 2c 23 31 3c 3c 32 33 20 20 20 20 |C q,q,#1<<23 | 00002a60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00002a70 63 6c 65 61 72 20 68 69 2d 6f 72 64 65 72 0d 0c |clear hi-order..| 00002a80 b2 2b 84 52 20 52 30 2c 52 30 2c 71 20 20 20 20 |.+.R R0,R0,q | 00002a90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002aa0 20 3b 20 72 65 73 75 6c 74 0d 0c bc 10 2e 66 70 | ; result.....fp| 00002ab0 5f 64 69 76 5f 65 78 69 74 0d 0c c6 1a 4c 44 4d |_div_exit....LDM| 00002ac0 46 44 20 52 31 33 21 2c 7b 52 32 2d 52 34 2c 50 |FD R13!,{R2-R4,P| 00002ad0 43 7d 5e 0d 0c d0 08 5d 3a 3d 30 0d 0c da 05 3a |C}^....]:=0....:| 00002ae0 0d 0c e4 10 dd a4 66 70 5f 73 71 72 5f 61 73 6d |......fp_sqr_asm| 00002af0 0d 0c ee 1a 6d 61 6e 74 31 3d 31 3a 65 78 70 31 |....mant1=1:exp1| 00002b00 3d 32 3a 77 72 6b 31 3d 31 34 0d 0c f8 0d 52 65 |=2:wrk1=14....Re| 00002b10 73 48 69 67 68 3d 32 0d 0d 02 0c 5b 4f 50 54 20 |sHigh=2....[OPT | 00002b20 61 73 6d 0d 0d 0c 30 3b 20 53 71 75 61 72 65 20 |asm...0; Square | 00002b30 61 20 73 69 6e 67 6c 65 20 70 72 65 63 69 73 69 |a single precisi| 00002b40 6f 6e 20 66 6c 6f 61 74 20 2d 20 52 30 3d 52 30 |on float - R0=R0| 00002b50 2a 52 30 0d 0d 16 0b 2e 66 70 5f 73 71 72 0d 0d |*R0.....fp_sqr..| 00002b60 20 17 53 54 4d 46 44 20 52 31 33 21 2c 7b 52 32 | .STMFD R13!,{R2| 00002b70 2c 52 31 34 7d 0d 0d 2a 1b 3b 20 43 68 65 63 6b |,R14}..*.; Check| 00002b80 20 66 6f 72 20 6e 75 6c 6c 20 72 65 73 75 6c 74 | for null result| 00002b90 0d 0d 34 0d 43 4d 50 20 52 30 2c 23 30 0d 0d 3e |..4.CMP R0,#0..>| 00002ba0 0c ec 51 20 52 30 2c 23 30 0d 0d 48 13 42 45 51 |..Q R0,#0..H.BEQ| 00002bb0 20 66 70 5f 73 71 72 5f 65 78 69 74 0d 0d 52 05 | fp_sqr_exit..R.| 00002bc0 3b 0d 0d 5c 37 4d 4f 56 20 65 78 70 31 2c 52 30 |;..\7MOV exp1,R0| 00002bd0 2c 4c 53 52 20 23 32 33 20 20 20 20 20 20 20 20 |,LSR #23 | 00002be0 20 20 20 20 20 3b 20 67 65 74 20 65 78 70 6f 6e | ; get expon| 00002bf0 65 6e 74 2b 73 69 67 6e 0d 0d 66 32 42 49 43 20 |ent+sign..f2BIC | 00002c00 6d 61 6e 74 31 2c 52 30 2c 65 78 70 31 2c 4c 53 |mant1,R0,exp1,LS| 00002c10 4c 20 23 32 33 20 20 20 20 20 20 20 3b 20 67 65 |L #23 ; ge| 00002c20 74 20 6d 61 6e 74 69 73 73 61 0d 0d 70 40 84 52 |t mantissa..p@.R| 00002c30 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c 23 31 3c | mant1,mant1,#1<| 00002c40 3c 32 33 20 20 20 20 20 20 20 20 20 20 3b 20 73 |<23 ; s| 00002c50 65 74 20 6f 6e 20 62 69 74 20 74 6f 20 6c 65 66 |et on bit to lef| 00002c60 74 20 6f 66 20 70 6f 69 6e 74 0d 0d 7a 2f 80 20 |t of point..z/. | 00002c70 65 78 70 31 2c 65 78 70 31 2c 23 32 35 35 20 20 |exp1,exp1,#255 | 00002c80 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 72 65 | ; re| 00002c90 6d 6f 76 65 20 73 69 67 6e 0d 0d 84 05 3b 0d 0d |move sign....;..| 00002ca0 8e 16 41 44 44 20 65 78 70 31 2c 65 78 70 31 2c |..ADD exp1,exp1,| 00002cb0 65 78 70 31 0d 0d 98 35 53 55 42 53 20 65 78 70 |exp1...5SUBS exp| 00002cc0 31 2c 65 78 70 31 2c 23 31 32 37 20 20 20 20 20 |1,exp1,#127 | 00002cd0 20 20 20 20 20 20 20 20 3b 20 65 78 70 6f 6e 65 | ; expone| 00002ce0 6e 74 20 72 65 73 75 6c 74 0d 0d a2 2f 4d 4f 56 |nt result.../MOV| 00002cf0 4d 49 20 52 30 2c 23 30 20 20 20 20 20 20 20 20 |MI R0,#0 | 00002d00 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 75 | ; u| 00002d10 6e 64 65 72 66 6c 6f 77 0d 0d ac 13 42 4d 49 20 |nderflow....BMI | 00002d20 66 70 5f 73 71 72 5f 65 78 69 74 0d 0d b6 16 4d |fp_sqr_exit....M| 00002d30 4f 56 20 52 30 2c 65 78 70 31 2c 4c 53 4c 23 32 |OV R0,exp1,LSL#2| 00002d40 33 0d 0d c0 2a 3b 20 44 6f 20 74 68 65 20 6d 75 |3...*; Do the mu| 00002d50 6c 74 69 70 6c 79 20 74 6f 20 33 30 20 62 69 74 |ltiply to 30 bit| 00002d60 73 20 70 72 65 63 69 73 69 6f 6e 0d 0d ca 31 4d |s precision...1M| 00002d70 4f 56 20 77 72 6b 31 2c 6d 61 6e 74 31 2c 4c 53 |OV wrk1,mant1,LS| 00002d80 52 23 39 20 20 20 20 20 20 20 20 20 20 20 20 3b |R#9 ;| 00002d90 20 74 6f 70 20 31 35 20 62 69 74 73 0d 0d d4 30 | top 15 bits...0| 00002da0 42 49 43 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c |BIC mant1,mant1,| 00002db0 77 72 6b 31 2c 4c 53 4c 23 39 20 20 20 20 20 20 |wrk1,LSL#9 | 00002dc0 3b 20 6c 6f 77 20 39 20 62 69 74 73 0d 0d de 2d |; low 9 bits...-| 00002dd0 4d 55 4c 20 6d 61 6e 74 31 2c 77 72 6b 31 2c 6d |MUL mant1,wrk1,m| 00002de0 61 6e 74 31 20 20 20 20 20 20 20 20 20 20 20 20 |ant1 | 00002df0 3b 20 6c 6f 77 2a 74 6f 70 0d 0d e8 2d 4d 55 4c |; low*top...-MUL| 00002e00 20 52 65 73 48 69 67 68 2c 77 72 6b 31 2c 77 72 | ResHigh,wrk1,wr| 00002e10 6b 31 20 20 20 20 20 20 20 20 20 20 20 3b 20 74 |k1 ; t| 00002e20 6f 70 2a 74 6f 70 0d 0d f2 35 41 44 44 20 6d 61 |op*top...5ADD ma| 00002e30 6e 74 31 2c 52 65 73 48 69 67 68 2c 6d 61 6e 74 |nt1,ResHigh,mant| 00002e40 31 2c 4c 53 52 23 38 20 20 20 3b 20 68 69 67 68 |1,LSR#8 ; high| 00002e50 2b 32 2a 6d 69 64 20 62 69 74 73 0d 0d fc 16 3b |+2*mid bits....;| 00002e60 20 41 64 6a 75 73 74 20 66 6f 72 20 63 61 72 72 | Adjust for carr| 00002e70 79 0d 0e 06 16 54 53 54 20 52 65 73 48 69 67 68 |y....TST ResHigh| 00002e80 2c 23 31 3c 3c 32 39 0d 0e 10 35 41 44 44 4e 45 |,#1<<29...5ADDNE| 00002e90 20 52 30 2c 52 30 2c 23 31 3c 3c 32 33 20 20 20 | R0,R0,#1<<23 | 00002ea0 20 20 20 20 20 20 20 20 20 20 20 3b 20 61 64 6a | ; adj| 00002eb0 75 73 74 20 65 78 70 6f 6e 65 6e 74 0d 0e 1a 38 |ust exponent...8| 00002ec0 4d 4f 56 4e 45 20 6d 61 6e 74 31 2c 6d 61 6e 74 |MOVNE mant1,mant| 00002ed0 31 2c 4c 53 52 23 31 20 20 20 20 20 20 20 20 20 |1,LSR#1 | 00002ee0 3b 20 73 68 69 66 74 20 72 65 73 75 6c 74 20 72 |; shift result r| 00002ef0 69 67 68 74 0d 0e 24 14 3b 20 63 6f 6d 62 69 6e |ight..$.; combin| 00002f00 65 20 72 65 73 75 6c 74 0d 0e 2e 34 42 49 43 20 |e result...4BIC | 00002f10 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c 23 31 3c 3c |mant1,mant1,#1<<| 00002f20 32 38 20 20 20 20 20 20 20 20 20 20 3b 20 63 6c |28 ; cl| 00002f30 65 61 72 20 68 69 2d 6f 72 64 65 72 0d 0e 38 43 |ear hi-order..8C| 00002f40 84 52 20 52 30 2c 52 30 2c 6d 61 6e 74 31 2c 4c |.R R0,R0,mant1,L| 00002f50 53 52 23 35 20 20 20 20 20 20 20 20 20 20 20 3b |SR#5 ;| 00002f60 20 61 64 64 20 73 69 67 6e 69 66 69 63 61 6e 74 | add significant| 00002f70 20 70 61 72 74 20 6f 66 20 6e 75 6d 62 65 72 0d | part of number.| 00002f80 0e 42 10 2e 66 70 5f 73 71 72 5f 65 78 69 74 0d |.B..fp_sqr_exit.| 00002f90 0e 4c 17 4c 44 4d 46 44 20 52 31 33 21 2c 7b 52 |.L.LDMFD R13!,{R| 00002fa0 32 2c 50 43 7d 5e 0d 0e 56 08 5d 3a 3d 30 0d 0e |2,PC}^..V.]:=0..| 00002fb0 60 05 3a 0d 0e 6a 10 dd a4 66 70 5f 63 6d 70 5f |`.:..j...fp_cmp_| 00002fc0 61 73 6d 0d 0e 74 0c 5b 4f 50 54 20 61 73 6d 0d |asm..t.[OPT asm.| 00002fd0 0e 7e 3f 3b 20 43 6f 6d 70 61 72 65 20 74 77 6f |.~?; Compare two| 00002fe0 20 66 6c 6f 61 74 73 2e 20 49 66 20 6f 70 31 20 | floats. If op1 | 00002ff0 26 20 6f 70 32 20 2d 76 65 2c 20 64 6f 20 6f 70 |& op2 -ve, do op| 00003000 70 6f 73 69 74 65 20 63 6f 6d 70 61 72 65 0d 0e |posite compare..| 00003010 88 0b 2e 66 70 5f 63 6d 70 0d 0e 92 2d 43 4d 50 |...fp_cmp...-CMP| 00003020 20 52 31 2c 23 30 20 20 20 20 20 20 20 20 20 20 | R1,#0 | 00003030 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 52 | ; R| 00003040 31 20 2d 76 65 3f 0d 0e 9c 11 42 4d 49 20 66 70 |1 -ve?....BMI fp| 00003050 5f 63 6d 70 5f 52 30 0d 0e a6 38 43 4d 50 20 52 |_cmp_R0...8CMP R| 00003060 30 2c 52 31 20 20 20 20 20 20 20 20 20 20 20 20 |0,R1 | 00003070 20 20 20 20 20 20 20 20 20 20 20 3b 20 6e 6f 20 | ; no | 00003080 2d 20 64 6f 20 6e 6f 72 6d 61 6c 20 43 4d 50 0d |- do normal CMP.| 00003090 0e b0 0e 4d 4f 56 20 52 31 34 2c 50 43 0d 0e ba |...MOV R14,PC...| 000030a0 0e 2e 66 70 5f 63 6d 70 5f 52 30 0d 0e c4 2d 43 |..fp_cmp_R0...-C| 000030b0 4d 50 20 52 30 2c 23 30 20 20 20 20 20 20 20 20 |MP R0,#0 | 000030c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b | ;| 000030d0 20 52 30 20 2d 76 65 3f 0d 0e ce 31 42 4d 49 20 | R0 -ve?...1BMI | 000030e0 66 70 5f 63 6d 70 5f 6e 65 67 20 20 20 20 20 20 |fp_cmp_neg | 000030f0 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 52 30 | ; R0| 00003100 20 26 20 52 31 20 2d 76 65 0d 0e d8 0d 43 4d 50 | & R1 -ve....CMP| 00003110 20 52 30 2c 52 31 0d 0e e2 0e 4d 4f 56 20 52 31 | R0,R1....MOV R1| 00003120 34 2c 50 43 0d 0e ec 0f 2e 66 70 5f 63 6d 70 5f |4,PC.....fp_cmp_| 00003130 6e 65 67 0d 0e f6 36 43 4d 50 20 52 31 2c 52 30 |neg...6CMP R1,R0| 00003140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003150 20 20 20 20 20 20 20 3b 20 6f 70 70 6f 73 69 74 | ; opposit| 00003160 65 20 63 6f 6d 70 61 72 65 0d 0f 00 0e 4d 4f 56 |e compare....MOV| 00003170 20 52 31 34 2c 50 43 0d 0f 0a 08 5d 3a 3d 30 0d | R14,PC....]:=0.| 00003180 0f 14 05 3a 0d 0f 1e 10 dd a4 66 70 5f 66 6c 74 |...:......fp_flt| 00003190 5f 61 73 6d 0d 0f 28 0b 6d 61 6e 74 31 3d 31 0d |_asm..(.mant1=1.| 000031a0 0f 32 0c 5b 4f 50 54 20 61 73 6d 0d 0f 3c 28 3b |.2.[OPT asm..<(;| 000031b0 20 43 6f 6e 76 65 72 74 20 61 6e 20 69 6e 74 65 | Convert an inte| 000031c0 67 65 72 20 74 6f 20 66 6c 6f 61 74 20 66 6f 72 |ger to float for| 000031d0 6d 61 74 0d 0f 46 0b 2e 66 70 5f 66 6c 74 0d 0f |mat..F..fp_flt..| 000031e0 50 0d 43 4d 50 20 52 30 2c 23 30 0d 0f 5a 35 ec |P.CMP R0,#0..Z5.| 000031f0 51 20 50 43 2c 52 31 34 20 20 20 20 20 20 20 20 |Q PC,R14 | 00003200 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 6e 6f | ; no| 00003210 20 63 68 61 6e 67 65 20 72 65 71 75 69 72 65 64 | change required| 00003220 0d 0f 64 12 4d 4f 56 47 45 20 6d 61 6e 74 31 2c |..d.MOVGE mant1,| 00003230 52 30 0d 0f 6e 38 4d 4f 56 47 45 20 52 30 2c 23 |R0..n8MOVGE R0,#| 00003240 31 35 30 3c 3c 32 33 20 20 20 20 20 20 20 20 20 |150<<23 | 00003250 20 20 20 20 20 20 3b 20 62 61 73 65 20 73 69 67 | ; base sig| 00003260 6e 2b 65 78 70 6f 6e 65 6e 74 0d 0f 78 15 52 53 |n+exponent..x.RS| 00003270 42 4c 54 20 6d 61 6e 74 31 2c 52 30 2c 23 30 0d |BLT mant1,R0,#0.| 00003280 0f 82 38 4d 4f 56 4c 54 20 52 30 2c 23 28 31 35 |..8MOVLT R0,#(15| 00003290 30 3c 3c 32 33 29 2b 28 31 3c 3c 33 31 29 20 20 |0<<23)+(1<<31) | 000032a0 20 20 20 3b 20 62 61 73 65 20 73 69 67 6e 2b 65 | ; base sign+e| 000032b0 78 70 6f 6e 65 6e 74 0d 0f 8c 14 43 4d 50 20 6d |xponent....CMP m| 000032c0 61 6e 74 31 2c 23 31 3c 3c 32 33 0d 0f 96 2e 42 |ant1,#1<<23....B| 000032d0 47 45 20 66 70 5f 66 6c 74 5f 75 70 20 20 20 20 |GE fp_flt_up | 000032e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b | ;| 000032f0 20 52 6f 75 6e 64 20 75 70 0d 0f a0 30 2e 66 70 | Round up...0.fp| 00003300 5f 66 6c 74 5f 64 6f 77 6e 20 20 20 20 20 20 20 |_flt_down | 00003310 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 52 | ; R| 00003320 6f 75 6e 64 20 64 6f 77 6e 0d 0f aa 14 53 55 42 |ound down....SUB| 00003330 20 52 30 2c 52 30 2c 23 31 3c 3c 32 33 0d 0f b4 | R0,R0,#1<<23...| 00003340 1a 4d 4f 56 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 |.MOV mant1,mant1| 00003350 2c 4c 53 4c 20 23 31 0d 0f be 14 43 4d 50 20 6d |,LSL #1....CMP m| 00003360 61 6e 74 31 2c 23 31 3c 3c 32 33 0d 0f c8 13 42 |ant1,#1<<23....B| 00003370 4c 54 20 66 70 5f 66 6c 74 5f 64 6f 77 6e 0d 0f |LT fp_flt_down..| 00003380 d2 34 2e 66 70 5f 66 6c 74 5f 6d 61 6b 65 20 20 |.4.fp_flt_make | 00003390 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000033a0 20 20 3b 20 63 6f 6d 62 69 6e 65 20 72 65 73 75 | ; combine resu| 000033b0 6c 74 0d 0f dc 1a 42 49 43 20 6d 61 6e 74 31 2c |lt....BIC mant1,| 000033c0 6d 61 6e 74 31 2c 23 31 3c 3c 32 33 0d 0f e6 12 |mant1,#1<<23....| 000033d0 84 52 20 52 30 2c 52 30 2c 6d 61 6e 74 31 0d 0f |.R R0,R0,mant1..| 000033e0 f0 0f 4d 4f 56 53 20 50 43 2c 52 31 34 0d 0f fa |..MOVS PC,R14...| 000033f0 35 2e 66 70 5f 66 6c 74 5f 75 70 20 20 20 20 20 |5.fp_flt_up | 00003400 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003410 20 3b 20 72 6f 75 6e 64 20 6e 75 6d 62 65 72 20 | ; round number | 00003420 75 70 0d 10 04 14 43 4d 50 20 6d 61 6e 74 31 2c |up....CMP mant1,| 00003430 23 31 3c 3c 32 34 0d 10 0e 13 42 4c 54 20 66 70 |#1<<24....BLT fp| 00003440 5f 66 6c 74 5f 6d 61 6b 65 0d 10 18 14 41 44 44 |_flt_make....ADD| 00003450 20 52 30 2c 52 30 2c 23 31 3c 3c 32 33 0d 10 22 | R0,R0,#1<<23.."| 00003460 1a 4d 4f 56 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 |.MOV mant1,mant1| 00003470 2c 4c 53 52 20 23 31 0d 10 2c 0f 42 20 66 70 5f |,LSR #1..,.B fp_| 00003480 66 6c 74 5f 75 70 0d 10 36 08 5d 3a 3d 30 0d 10 |flt_up..6.]:=0..| 00003490 40 05 3a 0d 10 4a 10 dd a4 66 70 5f 66 69 78 5f |@.:..J...fp_fix_| 000034a0 61 73 6d 0d 10 54 12 6d 61 6e 74 31 3d 30 3a 65 |asm..T.mant1=0:e| 000034b0 78 70 31 3d 31 0d 10 5e 0c 5b 4f 50 54 20 61 73 |xp1=1..^.[OPT as| 000034c0 6d 0d 10 68 27 3b 20 43 6f 6e 76 65 72 74 20 61 |m..h'; Convert a| 000034d0 20 66 6c 6f 61 74 20 74 6f 20 69 6e 74 65 67 65 | float to intege| 000034e0 72 20 66 6f 72 6d 61 74 0d 10 72 0b 2e 66 70 5f |r format..r..fp_| 000034f0 66 69 78 0d 10 7c 0d 43 4d 50 20 52 30 2c 23 30 |fix..|.CMP R0,#0| 00003500 0d 10 86 35 ec 51 20 50 43 2c 52 31 34 20 20 20 |...5.Q PC,R14 | 00003510 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003520 20 3b 20 6e 6f 20 63 68 61 6e 67 65 20 72 65 71 | ; no change req| 00003530 75 69 72 65 64 0d 10 90 17 4d 4f 56 20 65 78 70 |uired....MOV exp| 00003540 31 2c 52 30 2c 4c 53 52 20 23 32 33 0d 10 9a 1d |1,R0,LSR #23....| 00003550 42 49 43 20 6d 61 6e 74 31 2c 52 30 2c 65 78 70 |BIC mant1,R0,exp| 00003560 31 2c 4c 53 4c 20 23 32 33 0d 10 a4 19 84 52 20 |1,LSL #23.....R | 00003570 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c 23 31 3c 3c |mant1,mant1,#1<<| 00003580 32 33 0d 10 ae 36 54 53 54 20 65 78 70 31 2c 23 |23...6TST exp1,#| 00003590 31 3c 3c 38 20 20 20 20 20 20 20 20 20 20 20 20 |1<<8 | 000035a0 20 20 20 20 20 20 3b 20 6e 65 67 61 74 69 76 65 | ; negative| 000035b0 20 6e 75 6d 62 65 72 3f 0d 10 b8 29 52 53 42 4e | number?...)RSBN| 000035c0 45 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c 23 30 |E mant1,mant1,#0| 000035d0 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 79 65 | ; ye| 000035e0 73 0d 10 c2 30 42 49 43 20 65 78 70 31 2c 65 78 |s...0BIC exp1,ex| 000035f0 70 31 2c 23 31 3c 3c 38 20 20 20 20 20 20 20 20 |p1,#1<<8 | 00003600 20 20 20 20 20 3b 20 63 6c 65 61 72 20 73 69 67 | ; clear sig| 00003610 6e 0d 10 cc 3c 53 55 42 53 20 65 78 70 31 2c 65 |n...<SUBS exp1,e| 00003620 78 70 31 2c 23 31 32 37 20 20 20 20 20 20 20 20 |xp1,#127 | 00003630 20 20 20 20 20 3b 20 65 78 70 6f 6e 65 6e 74 20 | ; exponent | 00003640 72 65 6c 61 74 69 76 65 20 74 6f 20 31 0d 10 d6 |relative to 1...| 00003650 2f 4d 4f 56 4d 49 20 52 30 2c 23 30 20 20 20 20 |/MOVMI R0,#0 | 00003660 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003670 20 3b 20 75 6e 64 65 72 66 6c 6f 77 0d 10 e0 11 | ; underflow....| 00003680 4d 4f 56 4d 49 53 20 50 43 2c 52 31 34 0d 10 ea |MOVMIS PC,R14...| 00003690 3f 52 53 42 53 20 65 78 70 31 2c 65 78 70 31 2c |?RSBS exp1,exp1,| 000036a0 23 32 33 20 20 20 20 20 20 20 20 20 20 20 20 20 |#23 | 000036b0 20 3b 20 73 68 69 66 74 20 76 61 6c 75 65 20 72 | ; shift value r| 000036c0 65 6c 61 74 69 76 65 20 74 6f 20 31 0d 10 f4 1e |elative to 1....| 000036d0 4d 4f 56 50 4c 20 6d 61 6e 74 31 2c 6d 61 6e 74 |MOVPL mant1,mant| 000036e0 31 2c 41 53 52 20 65 78 70 31 0d 10 fe 34 52 53 |1,ASR exp1...4RS| 000036f0 42 4d 49 20 65 78 70 31 2c 65 78 70 31 2c 23 30 |BMI exp1,exp1,#0| 00003700 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00003710 6e 75 6d 62 65 72 20 3e 20 31 3c 3c 32 33 0d 11 |number > 1<<23..| 00003720 08 1e 4d 4f 56 4d 49 20 6d 61 6e 74 31 2c 6d 61 |..MOVMI mant1,ma| 00003730 6e 74 31 2c 41 53 4c 20 65 78 70 31 0d 11 12 0f |nt1,ASL exp1....| 00003740 4d 4f 56 53 20 50 43 2c 52 31 34 0d 11 1c 08 5d |MOVS PC,R14....]| 00003750 3a 3d 30 0d 11 26 05 3a 0d 11 30 10 dd a4 66 70 |:=0..&.:..0...fp| 00003760 5f 72 65 6d 5f 61 73 6d 0d 11 3a 32 6d 61 6e 74 |_rem_asm..:2mant| 00003770 31 3d 30 3a 6d 61 6e 74 32 3d 31 3a 73 69 67 6e |1=0:mant2=1:sign| 00003780 3d 32 3a 65 78 70 31 3d 33 3a 65 78 70 32 3d 31 |=2:exp1=3:exp2=1| 00003790 34 3a 63 6e 74 3d 65 78 70 31 0d 11 44 0c 5b 4f |4:cnt=exp1..D.[O| 000037a0 50 54 20 61 73 6d 0d 11 4e 1f 3b 20 52 30 20 3d |PT asm..N.; R0 =| 000037b0 20 72 65 6d 61 69 6e 64 65 72 20 66 72 6f 6d 20 | remainder from | 000037c0 52 30 2f 52 31 0d 11 58 0b 2e 66 70 5f 72 65 6d |R0/R1..X..fp_rem| 000037d0 0d 11 62 1a 53 54 4d 46 44 20 52 31 33 21 2c 7b |..b.STMFD R13!,{| 000037e0 52 32 2d 52 33 2c 52 31 34 7d 0d 11 6c 1b 3b 20 |R2-R3,R14}..l.; | 000037f0 43 68 65 63 6b 20 66 6f 72 20 6e 75 6c 6c 20 72 |Check for null r| 00003800 65 73 75 6c 74 0d 11 76 0d 43 4d 50 20 52 31 2c |esult..v.CMP R1,| 00003810 23 30 0d 11 80 0c ec 51 20 52 30 2c 23 30 0d 11 |#0.....Q R0,#0..| 00003820 8a 13 42 45 51 20 66 70 5f 72 65 6d 5f 65 78 69 |..BEQ fp_rem_exi| 00003830 74 0d 11 94 0d 43 4d 50 20 52 30 2c 23 30 0d 11 |t....CMP R0,#0..| 00003840 9e 13 42 45 51 20 66 70 5f 72 65 6d 5f 65 78 69 |..BEQ fp_rem_exi| 00003850 74 0d 11 a8 38 4d 4f 56 47 54 20 73 69 67 6e 2c |t...8MOVGT sign,| 00003860 23 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |#0 | 00003870 20 20 20 20 20 3b 20 73 65 74 20 73 69 67 6e 20 | ; set sign | 00003880 6f 66 20 72 65 73 75 6c 74 0d 11 b2 15 4d 4f 56 |of result....MOV| 00003890 4c 54 20 73 69 67 6e 2c 23 31 3c 3c 33 31 0d 11 |LT sign,#1<<31..| 000038a0 bc 31 42 49 43 4c 54 20 52 30 2c 52 30 2c 23 31 |.1BICLT R0,R0,#1| 000038b0 3c 3c 33 31 20 20 20 20 20 20 20 20 20 20 20 20 |<<31 | 000038c0 20 20 3b 20 72 65 6d 6f 76 65 20 73 69 67 6e 0d | ; remove sign.| 000038d0 11 c6 05 3b 0d 11 d0 38 42 49 43 20 52 31 2c 52 |...;...8BIC R1,R| 000038e0 31 2c 23 31 3c 3c 33 31 20 20 20 20 20 20 20 20 |1,#1<<31 | 000038f0 20 20 20 20 20 20 20 20 3b 20 52 65 6d 6f 76 65 | ; Remove| 00003900 20 73 69 67 6e 20 69 66 20 61 6e 79 0d 11 da 2e | sign if any....| 00003910 43 4d 50 20 52 30 2c 52 31 20 20 20 20 20 20 20 |CMP R0,R1 | 00003920 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003930 3b 20 49 66 20 52 30 3c 52 31 0d 11 e4 39 42 4c |; If R0<R1...9BL| 00003940 54 20 66 70 5f 72 65 6d 5f 73 69 67 6e 20 20 20 |T fp_rem_sign | 00003950 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00003960 74 68 65 6e 20 68 61 76 65 20 72 65 6d 61 69 6e |then have remain| 00003970 64 65 72 0d 11 ee 05 3b 0d 11 f8 37 4d 4f 56 20 |der....;...7MOV | 00003980 65 78 70 31 2c 52 30 2c 4c 53 52 20 23 32 33 20 |exp1,R0,LSR #23 | 00003990 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 67 65 | ; ge| 000039a0 74 20 65 78 70 6f 6e 65 6e 74 2b 73 69 67 6e 0d |t exponent+sign.| 000039b0 12 02 32 42 49 43 20 6d 61 6e 74 31 2c 52 30 2c |..2BIC mant1,R0,| 000039c0 65 78 70 31 2c 4c 53 4c 20 23 32 33 20 20 20 20 |exp1,LSL #23 | 000039d0 20 20 20 3b 20 67 65 74 20 6d 61 6e 74 69 73 73 | ; get mantiss| 000039e0 61 0d 12 0c 40 84 52 20 6d 61 6e 74 31 2c 6d 61 |a...@.R mant1,ma| 000039f0 6e 74 31 2c 23 31 3c 3c 32 33 20 20 20 20 20 20 |nt1,#1<<23 | 00003a00 20 20 20 20 3b 20 73 65 74 20 6f 6e 20 62 69 74 | ; set on bit| 00003a10 20 74 6f 20 6c 65 66 74 20 6f 66 20 70 6f 69 6e | to left of poin| 00003a20 74 0d 12 16 05 3b 0d 12 20 37 4d 4f 56 20 65 78 |t....;.. 7MOV ex| 00003a30 70 32 2c 52 31 2c 4c 53 52 20 23 32 33 20 20 20 |p2,R1,LSR #23 | 00003a40 20 20 20 20 20 20 20 20 20 20 3b 20 67 65 74 20 | ; get | 00003a50 65 78 70 6f 6e 65 6e 74 2b 73 69 67 6e 0d 12 2a |exponent+sign..*| 00003a60 32 42 49 43 20 6d 61 6e 74 32 2c 52 31 2c 65 78 |2BIC mant2,R1,ex| 00003a70 70 32 2c 4c 53 4c 20 23 32 33 20 20 20 20 20 20 |p2,LSL #23 | 00003a80 20 3b 20 67 65 74 20 6d 61 6e 74 69 73 73 61 0d | ; get mantissa.| 00003a90 12 34 40 84 52 20 6d 61 6e 74 32 2c 6d 61 6e 74 |.4@.R mant2,mant| 00003aa0 32 2c 23 31 3c 3c 32 33 20 20 20 20 20 20 20 20 |2,#1<<23 | 00003ab0 20 20 3b 20 73 65 74 20 6f 6e 20 62 69 74 20 74 | ; set on bit t| 00003ac0 6f 20 6c 65 66 74 20 6f 66 20 70 6f 69 6e 74 0d |o left of point.| 00003ad0 12 3e 05 3b 0d 12 48 36 53 55 42 20 63 6e 74 2c |.>.;..H6SUB cnt,| 00003ae0 65 78 70 31 2c 65 78 70 32 20 20 20 20 20 20 20 |exp1,exp2 | 00003af0 20 20 20 20 20 20 20 20 3b 20 73 69 7a 65 20 6f | ; size o| 00003b00 66 20 71 75 6f 74 69 65 6e 74 0d 12 52 35 3b 20 |f quotient..R5; | 00003b10 44 6f 20 74 68 65 20 64 69 76 69 64 65 20 62 75 |Do the divide bu| 00003b20 74 20 6f 6e 6c 79 20 74 72 61 63 6b 20 76 61 6c |t only track val| 00003b30 75 65 20 6f 66 20 72 65 6d 61 69 6e 64 65 72 0d |ue of remainder.| 00003b40 12 5c 36 2e 66 70 5f 72 65 6d 6c 6f 6f 70 20 20 |.\6.fp_remloop | 00003b50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003b60 20 20 20 3b 20 64 6f 20 62 69 6e 61 72 79 20 70 | ; do binary p| 00003b70 6c 61 63 65 73 0d 12 66 35 43 4d 50 20 6d 61 6e |laces..f5CMP man| 00003b80 74 31 2c 6d 61 6e 74 32 20 20 20 20 20 20 20 20 |t1,mant2 | 00003b90 20 20 20 20 20 20 20 20 20 3b 20 6e 75 6d 62 65 | ; numbe| 00003ba0 72 3e 64 69 76 69 73 6f 72 3f 0d 12 70 3d 53 55 |r>divisor?..p=SU| 00003bb0 42 43 53 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c |BCS mant1,mant1,| 00003bc0 6d 61 6e 74 32 20 20 20 20 20 20 20 20 20 3b 20 |mant2 ; | 00003bd0 64 69 73 63 61 72 64 20 61 63 63 6f 75 6e 74 65 |discard accounte| 00003be0 64 20 76 61 6c 75 65 0d 12 7a 13 53 55 42 53 20 |d value..z.SUBS | 00003bf0 63 6e 74 2c 63 6e 74 2c 23 31 0d 12 84 38 4d 4f |cnt,cnt,#1...8MO| 00003c00 56 50 4c 20 6d 61 6e 74 31 2c 6d 61 6e 74 31 2c |VPL mant1,mant1,| 00003c10 4c 53 4c 20 23 31 20 20 20 20 20 20 20 20 3b 20 |LSL #1 ; | 00003c20 73 68 69 66 74 20 75 70 20 72 65 6d 61 69 6e 64 |shift up remaind| 00003c30 65 72 0d 12 8e 25 42 50 4c 20 66 70 5f 72 65 6d |er...%BPL fp_rem| 00003c40 6c 6f 6f 70 20 20 20 20 20 20 20 20 20 20 20 20 |loop | 00003c50 20 20 20 20 20 20 3b 0d 12 98 10 43 4d 50 20 6d | ;....CMP m| 00003c60 61 6e 74 31 2c 23 30 0d 12 a2 32 42 45 51 20 66 |ant1,#0...2BEQ f| 00003c70 70 5f 72 65 6d 5f 65 78 69 74 20 20 20 20 20 20 |p_rem_exit | 00003c80 20 20 20 20 20 20 20 20 20 20 20 3b 20 6e 6f 20 | ; no | 00003c90 72 65 6d 61 69 6e 64 65 72 0d 12 ac 13 42 20 66 |remainder....B f| 00003ca0 70 5f 72 65 6d 5f 61 64 6a 75 73 74 0d 12 b6 16 |p_rem_adjust....| 00003cb0 3b 20 4e 6f 72 6d 61 6c 69 73 65 20 72 65 73 75 |; Normalise resu| 00003cc0 6c 74 0d 12 c0 10 2e 66 70 5f 72 65 6d 5f 6e 6f |lt.....fp_rem_no| 00003cd0 72 6d 0d 12 ca 1a 4d 4f 56 20 6d 61 6e 74 31 2c |rm....MOV mant1,| 00003ce0 6d 61 6e 74 31 2c 4c 53 4c 20 23 31 0d 12 d4 14 |mant1,LSL #1....| 00003cf0 53 55 42 20 65 78 70 32 2c 65 78 70 32 2c 23 31 |SUB exp2,exp2,#1| 00003d00 0d 12 de 12 2e 66 70 5f 72 65 6d 5f 61 64 6a 75 |.....fp_rem_adju| 00003d10 73 74 0d 12 e8 14 43 4d 50 20 6d 61 6e 74 31 2c |st....CMP mant1,| 00003d20 23 31 3c 3c 32 33 0d 12 f2 13 42 4c 54 20 66 70 |#1<<23....BLT fp| 00003d30 5f 72 65 6d 5f 6e 6f 72 6d 0d 12 fc 14 3b 20 63 |_rem_norm....; c| 00003d40 6f 6d 62 69 6e 65 20 72 65 73 75 6c 74 0d 13 06 |ombine result...| 00003d50 34 42 49 43 20 52 30 2c 6d 61 6e 74 31 2c 23 31 |4BIC R0,mant1,#1| 00003d60 3c 3c 32 33 20 20 20 20 20 20 20 20 20 20 20 20 |<<23 | 00003d70 20 3b 20 63 6c 65 61 72 20 68 69 2d 6f 72 64 65 | ; clear hi-orde| 00003d80 72 0d 13 10 31 84 52 20 52 30 2c 52 30 2c 65 78 |r...1.R R0,R0,ex| 00003d90 70 32 2c 4c 53 4c 20 23 32 33 20 20 20 20 20 20 |p2,LSL #23 | 00003da0 20 20 20 20 3b 20 73 65 74 20 65 78 70 6f 6e 65 | ; set expone| 00003db0 6e 74 0d 13 1a 10 2e 66 70 5f 72 65 6d 5f 73 69 |nt.....fp_rem_si| 00003dc0 67 6e 0d 13 24 11 84 52 20 52 30 2c 52 30 2c 73 |gn..$..R R0,R0,s| 00003dd0 69 67 6e 0d 13 2e 10 2e 66 70 5f 72 65 6d 5f 65 |ign.....fp_rem_e| 00003de0 78 69 74 0d 13 38 1a 4c 44 4d 46 44 20 52 31 33 |xit..8.LDMFD R13| 00003df0 21 2c 7b 52 32 2d 52 33 2c 50 43 7d 5e 0d 13 42 |!,{R2-R3,PC}^..B| 00003e00 08 5d 3a 3d 30 0d 13 4c 05 3a 0d 13 56 13 dd a4 |.]:=0..L.:..V...| 00003e10 66 70 5f 61 6e 67 6c 65 73 5f 61 73 6d 0d 13 60 |fp_angles_asm..`| 00003e20 10 ea 20 73 2c 73 69 6e 2c 73 69 6e 78 0d 13 6a |.. s,sin,sinx..j| 00003e30 05 3a 0d 13 74 27 f4 20 52 30 3d 43 4f 53 28 52 |.:..t'. R0=COS(R| 00003e40 30 29 20 77 68 65 72 65 20 52 30 20 69 73 20 69 |0) where R0 is i| 00003e50 6e 20 72 61 64 69 61 6e 73 0d 13 7e 0c 5b 4f 50 |n radians..~.[OP| 00003e60 54 20 61 73 6d 0d 13 88 0b 2e 66 70 5f 63 6f 73 |T asm.....fp_cos| 00003e70 0d 13 92 42 53 54 4d 46 44 20 52 31 33 21 2c 7b |...BSTMFD R13!,{| 00003e80 52 32 2d 52 35 2c 52 31 34 7d 20 20 20 20 20 20 |R2-R5,R14} | 00003e90 20 20 20 20 3b 20 4e 62 21 20 6b 65 65 70 20 69 | ; Nb! keep i| 00003ea0 6e 20 73 74 65 70 20 77 69 74 68 20 66 70 5f 73 |n step with fp_s| 00003eb0 69 6e 0d 13 9c 10 4c 44 52 20 52 31 2c 66 70 5f |in....LDR R1,fp_| 00003ec0 70 69 0d 13 a6 2b 53 55 42 20 52 31 2c 52 31 2c |pi...+SUB R1,R1,| 00003ed0 23 31 3c 3c 32 33 20 20 20 20 20 20 20 20 20 20 |#1<<23 | 00003ee0 20 20 20 20 20 20 3b 20 31 2f 32 20 af 0d 13 b0 | ; 1/2 ....| 00003ef0 0d 42 4c 20 66 70 5f 61 64 64 0d 13 ba 35 42 20 |.BL fp_add...5B | 00003f00 66 70 5f 73 69 6e 63 6f 73 20 20 20 20 20 20 20 |fp_sincos | 00003f10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00003f20 63 61 72 72 79 20 6f 6e 20 61 73 20 63 6f 73 0d |carry on as cos.| 00003f30 13 c4 05 5d 0d 13 ce 05 3a 0d 13 d8 27 f4 20 52 |...]....:...'. R| 00003f40 30 3d 53 49 4e 28 52 30 29 20 77 68 65 72 65 20 |0=SIN(R0) where | 00003f50 52 30 20 69 73 20 69 6e 20 72 61 64 69 61 6e 73 |R0 is in radians| 00003f60 0d 13 e2 0a 73 69 67 6e 3d 33 0d 13 ec 0c 5b 4f |....sign=3....[O| 00003f70 50 54 20 61 73 6d 0d 13 f6 0b 2e 66 70 5f 73 69 |PT asm.....fp_si| 00003f80 6e 0d 14 00 1a 53 54 4d 46 44 20 52 31 33 21 2c |n....STMFD R13!,| 00003f90 7b 52 32 2d 52 35 2c 52 31 34 7d 0d 14 0a 0e 2e |{R2-R5,R14}.....| 00003fa0 66 70 5f 73 69 6e 63 6f 73 0d 14 14 0d 43 4d 50 |fp_sincos....CMP| 00003fb0 20 52 30 2c 23 30 0d 14 1e 11 4d 4f 56 47 45 20 | R0,#0....MOVGE | 00003fc0 73 69 67 6e 2c 23 30 0d 14 28 15 4d 4f 56 4c 54 |sign,#0..(.MOVLT| 00003fd0 20 73 69 67 6e 2c 23 31 3c 3c 33 31 0d 14 32 16 | sign,#1<<31..2.| 00003fe0 42 49 43 4c 54 20 52 30 2c 52 30 2c 23 31 3c 3c |BICLT R0,R0,#1<<| 00003ff0 33 31 0d 14 3c 20 3b 20 49 66 20 3e af 2a 32 20 |31..< ; If >.*2 | 00004000 74 68 65 6e 20 67 65 74 20 72 65 6d 61 69 6e 64 |then get remaind| 00004010 65 72 0d 14 46 10 4c 44 52 20 52 32 2c 66 70 5f |er..F.LDR R2,fp_| 00004020 70 69 0d 14 50 2a 41 44 44 20 52 31 2c 52 32 2c |pi..P*ADD R1,R2,| 00004030 23 31 3c 3c 32 33 20 20 20 20 20 20 20 20 20 20 |#1<<23 | 00004040 20 20 20 20 20 20 3b 20 70 69 2a 32 0d 14 5a 0d | ; pi*2..Z.| 00004050 43 4d 50 20 52 30 2c 52 31 0d 14 64 0f 42 4c 47 |CMP R0,R1..d.BLG| 00004060 54 20 66 70 5f 72 65 6d 0d 14 6e 1c 3b 20 49 66 |T fp_rem..n.; If| 00004070 20 3e af 20 74 68 65 6e 20 69 6e 76 65 72 74 20 | >. then invert | 00004080 73 69 67 6e 0d 14 78 28 4d 4f 56 20 52 31 2c 52 |sign..x(MOV R1,R| 00004090 32 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |2 | 000040a0 20 20 20 20 20 20 20 20 3b 20 70 69 0d 14 82 0d | ; pi....| 000040b0 43 4d 50 20 52 30 2c 52 31 0d 14 8c 18 82 47 54 |CMP R0,R1.....GT| 000040c0 20 73 69 67 6e 2c 73 69 67 6e 2c 23 31 3c 3c 33 | sign,sign,#1<<3| 000040d0 31 0d 14 96 32 42 4c 47 54 20 66 70 5f 73 75 62 |1...2BLGT fp_sub| 000040e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000040f0 20 20 20 20 20 3b 20 61 64 6a 75 73 74 20 74 6f | ; adjust to| 00004100 20 3c af 0d 14 a0 2b 3b 20 49 66 20 3e af 2f 32 | <....+; If >./2| 00004110 20 74 68 65 6e 20 61 64 6a 75 73 74 20 61 73 20 | then adjust as | 00004120 6f 66 66 73 65 74 20 66 72 6f 6d 20 70 69 0d 14 |offset from pi..| 00004130 aa 2a 53 55 42 20 52 31 2c 52 32 2c 23 31 3c 3c |.*SUB R1,R2,#1<<| 00004140 32 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |23 | 00004150 20 20 3b 20 70 69 2f 32 0d 14 b4 0d 43 4d 50 20 | ; pi/2....CMP | 00004160 52 30 2c 52 31 0d 14 be 0f 4d 4f 56 47 54 20 52 |R0,R1....MOVGT R| 00004170 31 2c 52 30 0d 14 c8 28 4d 4f 56 47 54 20 52 30 |1,R0...(MOVGT R0| 00004180 2c 52 32 20 20 20 20 20 20 20 20 20 20 20 20 20 |,R2 | 00004190 20 20 20 20 20 20 20 20 3b 20 70 69 0d 14 d2 33 | ; pi...3| 000041a0 42 4c 47 54 20 66 70 5f 73 75 62 20 20 20 20 20 |BLGT fp_sub | 000041b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000041c0 3b 20 52 30 3d 70 69 2d 72 61 64 69 61 6e 73 0d |; R0=pi-radians.| 000041d0 14 dc 1e 3b 20 47 65 74 20 69 6e 64 65 78 20 69 |...; Get index i| 000041e0 6e 74 6f 20 73 69 6e 20 74 61 62 6c 65 0d 14 e6 |nto sin table...| 000041f0 36 41 44 44 20 52 30 2c 52 30 2c 23 31 30 3c 3c |6ADD R0,R0,#10<<| 00004200 32 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |23 | 00004210 20 3b 20 6d 75 6c 74 69 70 6c 79 20 62 79 20 31 | ; multiply by 1| 00004220 30 32 34 0d 14 f0 37 4d 4f 56 20 52 32 2c 52 30 |024...7MOV R2,R0| 00004230 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004240 20 20 20 20 20 20 20 3b 20 73 61 76 65 20 72 61 | ; save ra| 00004250 64 69 61 6e 73 2a 31 30 32 34 0d 14 fa 30 42 4c |dians*1024...0BL| 00004260 20 66 70 5f 66 69 78 20 20 20 20 20 20 20 20 20 | fp_fix | 00004270 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00004280 41 73 20 69 6e 74 65 67 65 72 0d 15 04 34 41 44 |As integer...4AD| 00004290 52 20 52 34 2c 66 70 5f 73 69 6e 74 61 62 20 20 |R R4,fp_sintab | 000042a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 000042b0 54 61 62 6c 65 20 6f 66 20 73 69 6e 65 73 0d 15 |Table of sines..| 000042c0 0e 40 41 44 44 20 52 34 2c 52 34 2c 52 30 2c 4c |.@ADD R4,R4,R0,L| 000042d0 53 4c 20 23 33 20 20 20 20 20 20 20 20 20 20 20 |SL #3 | 000042e0 20 20 3b 20 61 64 64 72 65 73 73 20 6f 66 20 73 | ; address of s| 000042f0 69 6e 20 74 61 62 6c 65 20 65 6e 74 72 79 0d 15 |in table entry..| 00004300 18 3d 4c 44 4d 49 41 20 52 34 2c 7b 52 34 2c 52 |.=LDMIA R4,{R4,R| 00004310 35 7d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |5} | 00004320 20 20 3b 20 73 69 6e 20 2b 20 61 64 6a 75 73 74 | ; sin + adjust| 00004330 6d 65 6e 74 20 66 61 63 74 6f 72 0d 15 22 3e 42 |ment factor..">B| 00004340 4c 20 66 70 5f 66 6c 74 20 20 20 20 20 20 20 20 |L fp_flt | 00004350 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b | ;| 00004360 20 72 61 64 69 61 6e 20 76 61 6c 75 65 20 6f 66 | radian value of| 00004370 20 62 61 73 65 20 73 69 6e 0d 15 2c 0d 4d 4f 56 | base sin..,.MOV| 00004380 20 52 31 2c 52 30 0d 15 36 0d 4d 4f 56 20 52 30 | R1,R0..6.MOV R0| 00004390 2c 52 32 0d 15 40 48 42 4c 20 66 70 5f 73 75 62 |,R2..@HBL fp_sub| 000043a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000043b0 20 20 20 20 20 20 20 3b 20 72 61 64 69 61 6e 20 | ; radian | 000043c0 64 69 66 66 65 72 65 6e 63 65 20 66 72 6f 6d 20 |difference from | 000043d0 74 61 62 6c 65 20 65 6e 74 72 79 0d 15 4a 0d 4d |table entry..J.M| 000043e0 4f 56 20 52 31 2c 52 35 0d 15 54 3a 42 4c 20 66 |OV R1,R5..T:BL f| 000043f0 70 5f 6d 75 6c 20 20 20 20 20 20 20 20 20 20 20 |p_mul | 00004400 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 63 61 | ; ca| 00004410 6c 63 20 73 69 6e 65 20 64 69 66 66 65 72 65 6e |lc sine differen| 00004420 63 65 0d 15 5e 0d 4d 4f 56 20 52 31 2c 52 34 0d |ce..^.MOV R1,R4.| 00004430 15 68 34 42 4c 20 66 70 5f 61 64 64 20 20 20 20 |.h4BL fp_add | 00004440 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004450 20 20 20 3b 20 63 6f 6d 62 69 6e 65 20 72 65 73 | ; combine res| 00004460 75 6c 74 0d 15 72 33 84 52 20 52 30 2c 52 30 2c |ult..r3.R R0,R0,| 00004470 73 69 67 6e 20 20 20 20 20 20 20 20 20 20 20 20 |sign | 00004480 20 20 20 20 20 20 3b 20 73 69 67 6e 20 6f 66 20 | ; sign of | 00004490 72 65 73 75 6c 74 0d 15 7c 10 2e 66 70 5f 73 69 |result..|..fp_si| 000044a0 6e 5f 65 78 69 74 0d 15 86 1a 4c 44 4d 46 44 20 |n_exit....LDMFD | 000044b0 52 31 33 21 2c 7b 52 32 2d 52 35 2c 50 43 7d 5e |R13!,{R2-R5,PC}^| 000044c0 0d 15 90 05 3b 0d 15 9a 25 3b 20 52 30 3d b7 28 |....;...%; R0=.(| 000044d0 52 30 29 20 77 68 65 72 65 20 52 30 20 69 73 20 |R0) where R0 is | 000044e0 69 6e 20 72 61 64 69 61 6e 73 0d 15 a4 47 3b 20 |in radians...G; | 000044f0 45 73 73 65 6e 74 69 61 6c 6c 79 20 61 20 6d 6f |Essentially a mo| 00004500 64 69 66 69 65 64 20 76 65 72 73 69 6f 6e 20 6f |dified version o| 00004510 66 20 66 70 5f 73 69 6e 20 77 69 74 68 20 61 64 |f fp_sin with ad| 00004520 64 65 64 20 63 6f 73 20 26 20 73 69 6e 2f 63 6f |ded cos & sin/co| 00004530 73 0d 15 ae 0b 2e 66 70 5f 74 61 6e 0d 15 b8 1a |s.....fp_tan....| 00004540 53 54 4d 46 44 20 52 31 33 21 2c 7b 52 32 2d 52 |STMFD R13!,{R2-R| 00004550 37 2c 52 31 34 7d 0d 15 c2 0d 43 4d 50 20 52 30 |7,R14}....CMP R0| 00004560 2c 23 30 0d 15 cc 11 4d 4f 56 47 45 20 73 69 67 |,#0....MOVGE sig| 00004570 6e 2c 23 30 0d 15 d6 15 4d 4f 56 4c 54 20 73 69 |n,#0....MOVLT si| 00004580 67 6e 2c 23 31 3c 3c 33 31 0d 15 e0 16 42 49 43 |gn,#1<<31....BIC| 00004590 4c 54 20 52 30 2c 52 30 2c 23 31 3c 3c 33 31 0d |LT R0,R0,#1<<31.| 000045a0 15 ea 20 3b 20 49 66 20 3e af 2a 32 20 74 68 65 |.. ; If >.*2 the| 000045b0 6e 20 67 65 74 20 72 65 6d 61 69 6e 64 65 72 0d |n get remainder.| 000045c0 15 f4 10 4c 44 52 20 52 32 2c 66 70 5f 70 69 0d |...LDR R2,fp_pi.| 000045d0 15 fe 2a 41 44 44 20 52 31 2c 52 32 2c 23 31 3c |..*ADD R1,R2,#1<| 000045e0 3c 32 33 20 20 20 20 20 20 20 20 20 20 20 20 20 |<23 | 000045f0 20 20 20 3b 20 70 69 2a 32 0d 16 08 0d 43 4d 50 | ; pi*2....CMP| 00004600 20 52 30 2c 52 31 0d 16 12 0f 42 4c 47 54 20 66 | R0,R1....BLGT f| 00004610 70 5f 72 65 6d 0d 16 1c 1d 3b 20 49 66 20 3e af |p_rem....; If >.| 00004620 20 74 68 65 6e 20 72 65 64 75 63 65 20 74 6f 20 | then reduce to | 00004630 3c af 0d 16 26 28 4d 4f 56 20 52 31 2c 52 32 20 |<...&(MOV R1,R2 | 00004640 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004650 20 20 20 20 20 20 3b 20 70 69 0d 16 30 0d 43 4d | ; pi..0.CM| 00004660 50 20 52 30 2c 52 31 0d 16 3a 32 42 4c 47 54 20 |P R0,R1..:2BLGT | 00004670 66 70 5f 73 75 62 20 20 20 20 20 20 20 20 20 20 |fp_sub | 00004680 20 20 20 20 20 20 20 20 20 20 20 3b 20 61 64 6a | ; adj| 00004690 75 73 74 20 74 6f 20 3c af 0d 16 44 36 3b 20 49 |ust to <...D6; I| 000046a0 66 20 3e af 2f 32 20 74 68 65 6e 20 61 64 6a 75 |f >./2 then adju| 000046b0 73 74 20 61 73 20 6f 66 66 73 65 74 20 66 72 6f |st as offset fro| 000046c0 6d 20 70 69 20 26 20 73 65 74 20 73 69 67 6e 0d |m pi & set sign.| 000046d0 16 4e 2a 53 55 42 20 52 31 2c 52 32 2c 23 31 3c |.N*SUB R1,R2,#1<| 000046e0 3c 32 33 20 20 20 20 20 20 20 20 20 20 20 20 20 |<23 | 000046f0 20 20 20 3b 20 70 69 2f 32 0d 16 58 0d 43 4d 50 | ; pi/2..X.CMP| 00004700 20 52 30 2c 52 31 0d 16 62 0f 4d 4f 56 47 54 20 | R0,R1..b.MOVGT | 00004710 52 31 2c 52 30 0d 16 6c 28 4d 4f 56 47 54 20 52 |R1,R0..l(MOVGT R| 00004720 30 2c 52 32 20 20 20 20 20 20 20 20 20 20 20 20 |0,R2 | 00004730 20 20 20 20 20 20 20 20 20 3b 20 70 69 0d 16 76 | ; pi..v| 00004740 33 42 4c 47 54 20 66 70 5f 73 75 62 20 20 20 20 |3BLGT fp_sub | 00004750 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004760 20 3b 20 52 30 3d 70 69 2d 72 61 64 69 61 6e 73 | ; R0=pi-radians| 00004770 0d 16 80 18 82 47 54 20 73 69 67 6e 2c 73 69 67 |.....GT sign,sig| 00004780 6e 2c 23 31 3c 3c 33 31 0d 16 8a 1e 3b 20 47 65 |n,#1<<31....; Ge| 00004790 74 20 69 6e 64 65 78 20 69 6e 74 6f 20 73 69 6e |t index into sin| 000047a0 20 74 61 62 6c 65 0d 16 94 36 41 44 44 20 52 30 | table...6ADD R0| 000047b0 2c 52 30 2c 23 31 30 3c 3c 32 33 20 20 20 20 20 |,R0,#10<<23 | 000047c0 20 20 20 20 20 20 20 20 20 20 3b 20 6d 75 6c 74 | ; mult| 000047d0 69 70 6c 79 20 62 79 20 31 30 32 34 0d 16 9e 37 |iply by 1024...7| 000047e0 4d 4f 56 20 52 32 2c 52 30 20 20 20 20 20 20 20 |MOV R2,R0 | 000047f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004800 3b 20 73 61 76 65 20 72 61 64 69 61 6e 73 2a 31 |; save radians*1| 00004810 30 32 34 0d 16 a8 30 42 4c 20 66 70 5f 66 69 78 |024...0BL fp_fix| 00004820 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004830 20 20 20 20 20 20 20 3b 20 41 73 20 69 6e 74 65 | ; As inte| 00004840 67 65 72 0d 16 b2 34 41 44 52 20 52 36 2c 66 70 |ger...4ADR R6,fp| 00004850 5f 73 69 6e 74 61 62 20 20 20 20 20 20 20 20 20 |_sintab | 00004860 20 20 20 20 20 20 20 3b 20 54 61 62 6c 65 20 6f | ; Table o| 00004870 66 20 73 69 6e 65 73 0d 16 bc 40 41 44 44 20 52 |f sines...@ADD R| 00004880 34 2c 52 36 2c 52 30 2c 4c 53 4c 20 23 33 20 20 |4,R6,R0,LSL #3 | 00004890 20 20 20 20 20 20 20 20 20 20 20 3b 20 61 64 64 | ; add| 000048a0 72 65 73 73 20 6f 66 20 73 69 6e 20 74 61 62 6c |ress of sin tabl| 000048b0 65 20 65 6e 74 72 79 0d 16 c6 3d 4c 44 4d 49 41 |e entry...=LDMIA| 000048c0 20 52 34 2c 7b 52 34 2c 52 35 7d 20 20 20 20 20 | R4,{R4,R5} | 000048d0 20 20 20 20 20 20 20 20 20 20 20 3b 20 73 69 6e | ; sin| 000048e0 20 2b 20 61 64 6a 75 73 74 6d 65 6e 74 20 66 61 | + adjustment fa| 000048f0 63 74 6f 72 0d 16 d0 05 3b 0d 16 da 12 4c 44 52 |ctor....;....LDR| 00004900 20 52 37 2c 66 70 5f 31 36 30 38 0d 16 e4 38 53 | R7,fp_1608...8S| 00004910 55 42 20 52 37 2c 52 37 2c 52 30 20 20 20 20 20 |UB R7,R7,R0 | 00004920 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b | ;| 00004930 20 69 6e 64 65 78 20 6f 66 20 63 6f 73 20 76 61 | index of cos va| 00004940 6c 75 65 0d 16 ee 05 3b 0d 16 f8 3e 42 4c 20 66 |lue....;...>BL f| 00004950 70 5f 66 6c 74 20 20 20 20 20 20 20 20 20 20 20 |p_flt | 00004960 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 72 61 | ; ra| 00004970 64 69 61 6e 20 76 61 6c 75 65 20 6f 66 20 62 61 |dian value of ba| 00004980 73 65 20 73 69 6e 0d 17 02 0d 4d 4f 56 20 52 31 |se sin....MOV R1| 00004990 2c 52 30 0d 17 0c 0d 4d 4f 56 20 52 30 2c 52 32 |,R0....MOV R0,R2| 000049a0 0d 17 16 48 42 4c 20 66 70 5f 73 75 62 20 20 20 |...HBL fp_sub | 000049b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000049c0 20 20 20 20 3b 20 72 61 64 69 61 6e 20 64 69 66 | ; radian dif| 000049d0 66 65 72 65 6e 63 65 20 66 72 6f 6d 20 74 61 62 |ference from tab| 000049e0 6c 65 20 65 6e 74 72 79 0d 17 20 0d 4d 4f 56 20 |le entry.. .MOV | 000049f0 52 31 2c 52 35 0d 17 2a 3a 4d 4f 56 20 52 35 2c |R1,R5..*:MOV R5,| 00004a00 52 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |R0 | 00004a10 20 20 20 20 20 20 20 20 20 3b 20 73 61 76 65 20 | ; save | 00004a20 72 61 64 69 61 6e 20 66 72 61 63 74 69 6f 6e 0d |radian fraction.| 00004a30 17 34 3a 42 4c 20 66 70 5f 6d 75 6c 20 20 20 20 |.4:BL fp_mul | 00004a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004a50 20 20 20 3b 20 63 61 6c 63 20 73 69 6e 65 20 64 | ; calc sine d| 00004a60 69 66 66 65 72 65 6e 63 65 0d 17 3e 0d 4d 4f 56 |ifference..>.MOV| 00004a70 20 52 31 2c 52 34 0d 17 48 34 42 4c 20 66 70 5f | R1,R4..H4BL fp_| 00004a80 61 64 64 20 20 20 20 20 20 20 20 20 20 20 20 20 |add | 00004a90 20 20 20 20 20 20 20 20 20 20 3b 20 63 6f 6d 62 | ; comb| 00004aa0 69 6e 65 20 72 65 73 75 6c 74 0d 17 52 33 84 52 |ine result..R3.R| 00004ab0 20 52 30 2c 52 30 2c 73 69 67 6e 20 20 20 20 20 | R0,R0,sign | 00004ac0 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 73 | ; s| 00004ad0 69 67 6e 20 6f 66 20 72 65 73 75 6c 74 0d 17 5c |ign of result..\| 00004ae0 2f 4d 4f 56 20 52 34 2c 52 30 20 20 20 20 20 20 |/MOV R4,R0 | 00004af0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004b00 20 3b 20 73 61 76 65 20 73 69 6e 65 0d 17 66 41 | ; save sine..fA| 00004b10 3b 20 44 6f 20 63 6f 73 69 6e 65 2e 20 4e 62 2e |; Do cosine. Nb.| 00004b20 20 66 72 69 67 20 62 65 63 61 75 73 65 20 6f 66 | frig because of| 00004b30 20 31 36 30 38 2e 35 20 65 6e 74 72 69 65 73 20 | 1608.5 entries | 00004b40 69 6e 20 53 69 6e 65 20 74 61 62 6c 65 0d 17 70 |in Sine table..p| 00004b50 12 4c 44 52 20 52 30 2c 66 70 5f 63 6f 73 31 0d |.LDR R0,fp_cos1.| 00004b60 17 7a 2d 43 4d 50 20 52 35 2c 52 30 20 20 20 20 |.z-CMP R5,R0 | 00004b70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004b80 20 20 20 3b 20 52 35 3e 30 2e 35 3f 0d 17 84 14 | ; R5>0.5?....| 00004b90 4c 44 52 47 45 20 52 30 2c 66 70 5f 63 6f 73 32 |LDRGE R0,fp_cos2| 00004ba0 0d 17 8e 3a 53 55 42 47 45 20 52 37 2c 52 37 2c |...:SUBGE R7,R7,| 00004bb0 23 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |#1 | 00004bc0 20 20 20 20 3b 20 70 72 65 76 69 6f 75 73 20 74 | ; previous t| 00004bd0 61 62 6c 65 20 65 6e 74 72 79 0d 17 98 35 4d 4f |able entry...5MO| 00004be0 56 20 52 31 2c 52 35 20 20 20 20 20 20 20 20 20 |V R1,R5 | 00004bf0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 | ; | 00004c00 72 61 64 69 61 6e 20 66 72 61 63 74 69 6f 6e 0d |radian fraction.| 00004c10 17 a2 34 42 4c 20 66 70 5f 73 75 62 20 20 20 20 |..4BL fp_sub | 00004c20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004c30 20 20 20 3b 20 69 6e 76 65 72 74 20 66 6f 72 20 | ; invert for | 00004c40 63 6f 73 0d 17 ac 41 41 44 44 20 52 36 2c 52 36 |cos...AADD R6,R6| 00004c50 2c 52 37 2c 4c 53 4c 20 23 33 20 20 20 20 20 20 |,R7,LSL #3 | 00004c60 20 20 20 20 20 20 20 3b 20 61 64 64 72 65 73 73 | ; address| 00004c70 20 74 61 62 6c 65 20 65 6e 74 72 79 20 66 6f 72 | table entry for| 00004c80 20 63 6f 73 0d 17 b6 3d 4c 44 4d 49 41 20 52 36 | cos...=LDMIA R6| 00004c90 2c 7b 52 36 2c 52 37 7d 20 20 20 20 20 20 20 20 |,{R6,R7} | 00004ca0 20 20 20 20 20 20 20 20 3b 20 63 6f 73 20 2b 20 | ; cos + | 00004cb0 61 64 6a 75 73 74 6d 65 6e 74 20 66 61 63 74 6f |adjustment facto| 00004cc0 72 0d 17 c0 3b 4d 4f 56 20 52 31 2c 52 37 20 20 |r...;MOV R1,R7 | 00004cd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004ce0 20 20 20 20 20 3b 20 63 6f 73 20 61 64 6a 75 73 | ; cos adjus| 00004cf0 74 6d 65 6e 74 20 66 61 63 74 6f 72 0d 17 ca 39 |tment factor...9| 00004d00 42 4c 20 66 70 5f 6d 75 6c 20 20 20 20 20 20 20 |BL fp_mul | 00004d10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004d20 3b 20 63 61 6c 63 20 43 6f 73 20 64 69 66 66 65 |; calc Cos diffe| 00004d30 72 65 6e 63 65 0d 17 d4 0d 4d 4f 56 20 52 31 2c |rence....MOV R1,| 00004d40 52 36 0d 17 de 34 42 4c 20 66 70 5f 61 64 64 20 |R6...4BL fp_add | 00004d50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004d60 20 20 20 20 20 20 3b 20 63 6f 6d 62 69 6e 65 20 | ; combine | 00004d70 72 65 73 75 6c 74 0d 17 e8 15 3b 20 54 61 6e 3d |result....; Tan=| 00004d80 53 69 6e 65 2f 43 6f 73 69 6e 65 0d 17 f2 0d 4d |Sine/Cosine....M| 00004d90 4f 56 20 52 31 2c 52 30 0d 17 fc 0d 4d 4f 56 20 |OV R1,R0....MOV | 00004da0 52 30 2c 52 34 0d 18 06 0d 42 4c 20 66 70 5f 64 |R0,R4....BL fp_d| 00004db0 69 76 0d 18 10 1a 4c 44 4d 46 44 20 52 31 33 21 |iv....LDMFD R13!| 00004dc0 2c 7b 52 32 2d 52 37 2c 50 43 7d 5e 0d 18 1a 05 |,{R2-R7,PC}^....| 00004dd0 3b 0d 18 24 45 2e 66 70 5f 31 36 30 38 20 44 43 |;..$E.fp_1608 DC| 00004de0 44 20 31 36 30 38 20 20 20 20 20 20 20 20 20 20 |D 1608 | 00004df0 20 20 20 20 20 3b 20 4e 75 6d 62 65 72 20 6f 66 | ; Number of| 00004e00 20 65 6e 74 72 69 65 73 20 69 6e 20 73 69 6e 65 | entries in sine| 00004e10 20 74 61 62 6c 65 0d 18 2e 3e 2e 66 70 5f 63 6f | table...>.fp_co| 00004e20 73 31 20 a4 66 70 28 22 44 46 53 20 30 2e 34 39 |s1 .fp("DFS 0.49| 00004e30 35 34 33 38 36 33 22 29 20 3b 20 61 64 6a 75 73 |543863") ; adjus| 00004e40 74 6d 65 6e 74 20 66 61 63 74 6f 72 20 66 6f 72 |tment factor for| 00004e50 20 63 6f 73 0d 18 38 22 2e 66 70 5f 63 6f 73 32 | cos..8".fp_cos2| 00004e60 20 a4 66 70 28 22 44 46 53 20 31 2e 34 39 35 34 | .fp("DFS 1.4954| 00004e70 33 39 36 33 22 29 0d 18 42 1b 2e 66 70 5f 70 69 |3963")..B..fp_pi| 00004e80 20 a4 66 70 28 22 44 46 53 20 22 2b c3 28 af 29 | .fp("DFS "+.(.)| 00004e90 29 0d 18 4c 0e 2e 66 70 5f 73 69 6e 74 61 62 0d |)..L..fp_sintab.| 00004ea0 18 56 05 5d 0d 18 60 0f e7 20 61 73 6d 20 80 20 |.V.]..`.. asm . | 00004eb0 32 20 8c 0d 18 6a 0b 20 20 73 69 6e 3d 30 0d 18 |2 ...j. sin=0..| 00004ec0 74 1a 20 20 e3 20 73 3d 30 20 b8 20 af 2f 32 20 |t. . s=0 . ./2 | 00004ed0 88 20 31 2f 31 30 32 34 0d 18 7e 18 20 20 20 20 |. 1/1024..~. | 00004ee0 73 69 6e 78 3d b5 28 73 2b 31 2f 31 30 32 34 29 |sinx=.(s+1/1024)| 00004ef0 0d 18 88 10 20 20 20 20 5b 4f 50 54 20 61 73 6d |.... [OPT asm| 00004f00 0d 18 92 1a 20 20 20 20 a4 66 70 28 22 44 46 53 |.... .fp("DFS| 00004f10 20 22 2b c3 28 73 69 6e 29 29 0d 18 9c 1f 20 20 | "+.(sin)).... | 00004f20 20 20 a4 66 70 28 22 44 46 53 20 22 2b c3 28 73 | .fp("DFS "+.(s| 00004f30 69 6e 78 2d 73 69 6e 29 29 0d 18 a6 0a 20 20 20 |inx-sin)).... | 00004f40 20 3a 5d 0d 18 b0 10 20 20 20 20 73 69 6e 3d 73 | :].... sin=s| 00004f50 69 6e 78 0d 18 ba 07 20 20 ed 0d 18 c4 1b cc 20 |inx.... ...... | 00004f60 50 25 2b 3d 31 36 31 30 2a 38 3a 4f 25 2b 3d 31 |P%+=1610*8:O%+=1| 00004f70 36 31 30 2a 38 0d 18 ce 05 cd 0d 18 d8 06 3d 30 |610*8.........=0| 00004f80 0d ff |..| 00004f82