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.

关于CC5.2程序优化的问题?



最近在使用28035做一个项目,在CCS5.2的编译环境下,但是出现了一些问题,比如说是GpioDataRegs.GPADAT.bit.GPIO24   =1;

                                                                                                                                             GpioDataRegs.GPADAT.bit.GPIO21   =1;

                                                                                                                                             GpioDataRegs.GPADAT.bit.GPIO8=0;

这样的几条语句时,当我在设置断点调试的时候是完全正常的,当时当我取消断点是全速运行程序,就发现GpioDataRegs.GPADAT.bit.GPIO24   =1;和GpioDataRegs.GPADAT.bit.GPIO21   =1;就没有被执行,感觉好像是被编译器优化了,后来我在几句程序中间加入了asm(" nop");语句,变成如下的形式:

                                                                                                                                            

asm(" nop");    

 asm(" nop");    

 asm(" nop");    

GpioDataRegs.GPADAT.bit.GPIO24   =PFC_ON;   //PFC on  

  asm(" nop");    

 asm(" nop");    

asm(" nop");

 GpioDataRegs.GPADAT.bit.GPIO21   =ZVS_ON;   //ZVS on   

  asm(" nop");   

  asm(" nop");   

  asm(" nop");

   GpioDataRegs.GPADAT.bit.GPIO8=0;

这样以后在开启全速运行,程序是一切正常了,我想问一下,这中情况下是不是程序被优化了呢,为什么会出现这样的问题呢?