Hi
I have a piece of code that looks like this:
uint32 i;
uint32 a = 0;
for (i=0;i<u;i++)
a += (3*i+7);
i have added the "volatile" keyword to both varaibles, and i noticed that "NOP" instructions were added to the code.
for example: (copied from CCs 5 disassembly window)
without volatile:
for (i=0;i<u;i++)
MOV dbl(*SP(#02h)),AC0
ADD #1,AC0
MOV AC0,dbl(*SP(#02h))
MOV dbl(*SP(#00h)),AC0
MOV dbl(*SP(#02h)),AC1
CMPU AC1 < AC0, TC1
BCC C$L7,TC1
with volatile:
for (i=0;i<u;i++)
MOV dbl(*SP(#02h)),AC0
ADD #1,AC0
MOV AC0,dbl(*SP(#02h))
NOP
NOP
MOV dbl(*SP(#00h)),AC0
MOV dbl(*SP(#02h)),AC1
CMPU AC1 < AC0, TC1
BCC C$L7,TC1
Can you explain why are the "NOP" instructions added?
Thanks
Yaron