Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Strange GCC compiler assembler output

2006-05-03 by brendanmurphy37

Jan,

Looking at it again, the declaration is fine. Still a mystery why the 
compiler loaded the literal twice though, rather than copied from one 
register to another.

Brendan

--- In lpc2000@yahoogroups.com, "brendanmurphy37" 
<brendanmurphy37@...> wrote:
>
> --- 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.
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.