This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Question About $REGUSE

For an assembly coded function intended for C, is it necessary to include parameter registers in the $REGUSE statement?

If you don't include these in the ASM function's $REGUSE statement, will the compiler assume that parameter registers are intact upon return and, thus, may reuse them?

Ex:

int  int_parm;
MyASMFunction1( int_parm )   // Passed in R6R7
MyASMFunction2( int_parm )   // Also passed in R6R7

Now, assuming the ASM coding for MyASMFunction1(.) does not specify R6 and R7 in its $REGUSE statement, are there any cases where the compiler might assume the values for R6 and R7 are still intact upon return from MyASMFunction1(.), and skip loading R6R7 before calling MyASMFunction2(.) ???

Yes, I know... "never assume anything". I guess I'm simply asking for a clear understanding of how the compiler optimizes register parameters across function calls in cases like this.

Thanks for any help.

Parents
  • I have always taken the documentation to mean that $REGUSE should list all the registers that are used by the function - i.e. those registers that are not garanteed to have an unchanged value on return to the calling function.

    In the case of parameters passed in registers: if the register contents do not change, there is no need to list them.

Reply
  • I have always taken the documentation to mean that $REGUSE should list all the registers that are used by the function - i.e. those registers that are not garanteed to have an unchanged value on return to the calling function.

    In the case of parameters passed in registers: if the register contents do not change, there is no need to list them.

Children
No data