This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Bug when passing more than 4 reals to a functions

Hello,

I have a problem when I try to pass more than four floats to a function: only four first parameters are passed right and all the others get wrong values. I know that the first 4 parameters are passed through RxH registers and others through stack. It seems that parameters are not pushed correctly to the stack by the calling function, so the called can't recover right values from stack.

In the following example (floating point support set to fpu32):

    void test(float a1,float a2,float a3,float a4,float a5,float a6){
      float b1=a1*2;
      float b2=a2*2;
      float b3=a3*2;
      float b4=a4*2;
      float b5=a5*2;
      float b6=a6*2;
    }

void main(){

...

test(1.0,2.0,3.0,4.0,5.0,6.0);
....

}

After compilation we get the following  assembly:

test:

311F4B FE16 ADDB       SP,#22
311F4C E203 MOV32      *-SP[10], R3H
311F4E E203 MOV32      *-SP[8], R2H
311F50 E203 MOV32      *-SP[6], R1H
311F52 E203 MOV32      *-SP[4], R0H
311F54 A842 MOVL       *-SP[2],XAR4

...

311F80 0006 LRETR

main:

30601B E802 MOVIZ      R0, #0x40c0
30601D E802 MOVIZ      R1, #0x40a0
30601F E203 MOV32      *-SP[2], R0H   -----> ONLY 0x40C0 IS PUSHED TO STACK
306021 8F00 MOVL       XAR4,#0x009180
306023 E802 MOVIZ      R3, #0x4080
306025 E802 MOVIZ      R2, #0x4040
306027 BFA9 MOV32      @ACC,*(0:0x0F16)
306029 E801 MOVIZ      R0, #0x3f80
30602B E802 MOVIZ      R1, #0x4000
30602D 7671 LCR        test

As a result of "30601F E203 MOV32      *-SP[2], R0H" only R0 (0x40C0) is pushed to stack, R1 is not pushed. It seems that  CCS generates wrong object code.

Did anybody face this problem before? Can be fixed using any compiler option (I haven't been able)?

Regards,

Daniel Gutierrez