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

Selectively disable optimization on macro?

I have a macro:

#define EnterCritical()
  do {     SP++;     *(unsigned char idata *)(SP-1) = IE;     EA = 0;   } while (0);

that I call multiple times (along with its complement, ExitCritical()) in a particular function. With C51's optimization level set at 9, the optimizer is turning these in-line macros into a function and calling them -- this obviously won't work, due to the operations on SP.

Is there a way for me to maintain the OPTIMIZE(9,SIZE) settings for the module but ensure that the macro is left in its original in-line state whenever I invoke it?

Thanks,

Parents
  • Opps, I forgot the &ltpre&gt and &lt/pre&gt tags. ( Sure would be nice if the following message was before the message box: "Use &ltpre&gt and &lt/pre&gt tags surrounding any code posted." )<br>
    <br>
    May I suggest this simpler, faster C code.<br>
    <br>

    void main()
    {
      //some code ..
      {
        bit ie = IE; IE = 0;
        //critical code ..
        IE = ie;
      }
      //some more code ..
    } 
    
    <br>
    <br>

Reply
  • Opps, I forgot the &ltpre&gt and &lt/pre&gt tags. ( Sure would be nice if the following message was before the message box: "Use &ltpre&gt and &lt/pre&gt tags surrounding any code posted." )<br>
    <br>
    May I suggest this simpler, faster C code.<br>
    <br>

    void main()
    {
      //some code ..
      {
        bit ie = IE; IE = 0;
        //critical code ..
        IE = ie;
      }
      //some more code ..
    } 
    
    <br>
    <br>

Children
No data