--- In lpc2000@yahoogroups.com, Jan Thogersen <jan@...> wrote: > > Hi, > > My declarations is like the following: > global: > #define T0MR0 (*(volatile unsigned long *)0xE0004018) > static uint8 buf_inpos; > > local inside function: > register uint8 buf_outpos; > > Is the strange asm output because of the volatile thingy? AFAIK volatile > tells the compiler NOT to reuse values left in regs. Instead reload it > from the original location every single time? Right? > > regards > Jan Yes, you're correct: volatile tells it to load the specified object each time. The odd thing here though is that it's loading the address of the object twice. I'd advise you to check the T0MR0 declaration very carefully that you're not casting the constant to a "volatile pointer to an int" rather than a "pointer to a volatile int". The two aren't the same: you need the latter. Maybe someone else could advise: I'm afraid I don't carry around the prcedence rules in my head. Having said that chances are it's correct. It's still a mystery why the compiler didn't just to a "mov r2, r3" having gone to the trouble of loading up the literal. Given there's no "memory increment" ARM instruction (I think!), it's always going to have to do a "load/increment/store" by the way. Given the declaration of the buffer pointers, the other generated code kind of makes sense: it certainly explains why they are loaded differently (one being global, the other a local). Brendan
Message
Re: Strange GCC compiler assembler output
2006-05-03 by brendanmurphy37
Attachments
- No local attachments were found for this message.