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

Best way to see "optimizations"

Hello everyone,

So, I have a program I'm working on an 8051W core chip using Keil's C51 software and have a loop that looks like this:

        /* If Pressure2 is saturated low*/
        if ((Pressure2>>3) < (signed short)(P2SatLow))
        {
                DAC2MSB = (unsigned char)(((P2SatLow)&0xFF00)>>8);
                DAC2LSB = (unsigned char)((P2SatLow)&0xFF);

                DAC2Error = 1;
        }

        /* If Pressure2 is saturated high */
        else if ((Pressure2>>3) > (signed short)(P2SatHigh))
        {

                DAC2MSB = (unsigned char)(((P2SatHigh)&0xFF00)>>8);
                DAC2LSB = (unsigned char)((P2SatHigh)&0xFF);

                DAC2Error = 1;
        }

My first case has Pressure2 saturated low so it goes through the DAC2MSB and LSB commands but then enters the DAC2Error portion in the Sat High routine. Now, from a functional standpoint, it doesn't matter, it all works out exactly the same. Regardless though, I'd like to be able to view what exactly the code is doing. I currently have optimization level 8 (which has code folding, I believe, which is what is causing it to combine these two. When I go to optimization level 7, it enters the correct DAC2Error code in the SatLow section).

Unfortunately, my code in optimization level 8 is sitting at 7.3k and I have more code to add, so I can't drop down the optimization level (well, I could for now but I'd have to remove it down the road when I add additional code). At this point, I just want to understand what the optimized version of the code looks like but I'm not sure if that's possible.

Let me know if any of you have any suggestions about how to examine this. Thanks!

0