I have a single precision floating point routine in my ASM file, which I am trying to call from my C code. I've never had a problem doing this before, but it doesn't seem to be working with a floating argument. If I define the variables angle and n as floats as shown below, the disassembler shows that the assignment of 2.5 to angle properly stores it as a single word. When I call the sinsp function, the disassembly shows conversion of the variable to a double at 304b88 before it calls the routine. Is this a compiler bug or have I missed something? I seems that the compiler should know that the variable is single precision as it was defined, and pass it that way in A4.
Thanks for your help,
Ron
// from the C file
float angle,n;
angle = 2.5;
n = sinsp(angle);
// disassembly
2531
angle = 2.5;
C$RL393:
00804b78: 0180A358 MVK.L1 0,A3
00804b7c: E1200082 .fphead n, l, W, BU, nobr, nosat, 0001001
00804b80: 01A01068 MVKH.S1 0x40200000,A3
00804b84: ECB5 STW.D2T1 A3,*B15[7]
2532
n = sinsp(angle);
00804b86: 91C7 MV.L2X A3,B4
00804b88: 021000A2 SPDP.S2 B4,B5:B4
00804b8c: 2C6E NOP 2
00804b8e: 9246 MV.L1X B4,A4
00804b90: 10021F13 CALLP.S2 sinsp (PC+4344 = 0x00805c78),B3
00804b94: 02941FD8 || OR.L1X 0,B5,A5 C$RL394:
00804b98: 01900958 INTSP.L1 A4,A3
00804b9c: E1400000 .fphead n, l, W, BU, nobr, nosat, 0001010
00804ba0: 4C6E NOP 3
00804ba2: 8D35 STW.D2T1 A3,*B15[8] 2533 for(angle = 2.75;angle < 5.5;angle += .01){
; from ASM file - cossp/sinsp copied from mathlib
.global _cossp
.global _sinsp
;---------------------------------------------------------------------------------------------
; cossp.asm - single precision floating point cosine
; optimized hand ASM single sample
.newblock
PIo2ssp .set 0x3fc90fdb ; PI/2 = 1.5707964 (in SP FP)
InvPissp .set 0x3ea2f983 ; 1/PI = 0.31830987
C1ssp .set 0x40490000 ; C1 = 3.1406250
C2ssp .set 0x3a7daa22 ; C2 = 9.6765358e-4
s4ssp .set 0x362e9c5b ; s4 = 2.6019031e-6
s3ssp .set 0xb94fb222 ; s3 =-1.9807418e-4
s2ssp .set 0x3c08873e ; s2 = 8.3330255e-3
s1ssp .set 0xbe2aaaa4 ; s1 =-1.6666657e-1
PIssp .set 0x40490fdb ; PI = 3.1415927
; SP FP Cosine _cossp: ; entry for SP FP Cosine function (radians)
mvkl .S2 PIo2ssp,B6 ; SP FP PI/2 = 1.5707964
|| clr .S1 A4,31,31,A4 ; arg1 = |arg1|
mvkh .S2 PIo2ssp,B6
addsp .L1x B6,A4,A4 ; new arg1 = |arg1| + PI/2
nop 1 ; wait for cosine new arg1
; continues into SP FP Sine
_sinsp: ; entry for SP FP Sine function (radians)
mvkl .S1 InvPissp,A5 ; T = 1/Pi
mvkh .S1 InvPissp,A5
mv .L2X A4,B4
extu .S2 B4,1,1,B4 ; Y = absolute arg1
mpysp .M2X B4,A5,B5 ; X = Y*(1/Pi)
nop 3 ; wait for mpysp X
spint .L2 B5,B5 ; X = int(X)
mvkl .S1 C1ssp,A5 ; T = C1 coef.
mvkh .S1 C1ssp,A5
nop 1 ; wait for spint X
intsp .L2 B5,B1 ; Z = float (X)
nop 3 ; wait for intsp Z
mpysp .M1X B1,A5,A3 ; F = X * C1