problem in passing float value as argument


I am using HEW IDE with Renesas c/c++ compiler

Problem statement = When I call a function and pass float value as argument in it, then inside body of that called function, that float arguments value changes, it is not the same value which passed during function call



int Fun_ABC(float a);


void main()


int d;

d = Fun_ABC(55.5);



int Fun_ABC(float a)




when I enter into Fun_ABC and then I check value of "a" using "Add watch" option -> then it shows different value of "a" like 3.144 etc.

Please tell me the corresponding solution

  • I think the problem statement that you have mentioned is not correct. You change the question to how to monitor float value...
    Possible Answer: When you are trying to pass a float value to a function it will receive the data in a local variable which maps to a register in an assembly language. Hence when you are trying to monitor variable a it shows garbage value. Try to monitor assembly language registers you will be able to decode original float value.
    Since you have doubt that function is not accepting float as an argument try to return the same value at the end and assign it to another global float variable you will be able to monitor the returned value in watch window.
    I hope this clarify your doubt... :-)
  • Chapter 9.3.2 of the compiler manual explains about parameter passing to functions. In your case the float should be in register R4.
    But depending on the necessity in the function the compiler may shift the local variable also to other registers or the local variable will be deleted in a function if it is not being used any more.
    As Renu said, if you want to monitor a variable use a global variable for it.

  • apu,

    Have you resolved your missing float issues?

    Mike Clements
    RenesasRulz Moderator
  • This thread will be archived due to inactivity.

    Mike Clements
    RenesasRulz Moderator