#871 - I.C.E - Sat Jan 11, 2003 6:51 pm
I was initially just interested in what assember code the compiler turns code like this:
I have seen that because of storing test in memory it must be loaded to register and then 1 is added and then stored again into memory.
Then I remembered that there is the posibility to use the storage class register to advice the compiler to store the variable in question in a register. (by the way, i thought that the compiler usualy does this in such a construct, without explicity tell him to store it in register). I wrote this code instead of the above one:
I now used gdb to see what happend and to my astonishment a ASM dump of the loop looks like this:
Can anyone explain me why the compiler just done an endless loop?
| Code: |
|
while(1) test++; |
I have seen that because of storing test in memory it must be loaded to register and then 1 is added and then stored again into memory.
Then I remembered that there is the posibility to use the storage class register to advice the compiler to store the variable in question in a register. (by the way, i thought that the compiler usualy does this in such a construct, without explicity tell him to store it in register). I wrote this code instead of the above one:
| Code: |
|
{ register u32 test; while(1) test++; } |
I now used gdb to see what happend and to my astonishment a ASM dump of the loop looks like this:
| Code: |
|
0x8000cfc <initStage+776>: b 0x8000cfc <initStage+776> |
Can anyone explain me why the compiler just done an endless loop?