Yahoo Groups archive

Lpc2000

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

Message

Re: Example of C and inline ASM in a file?

2006-04-10 by brendanmurphy37

Jaya,

I have to say, you're a great source of amusement and entertainment! 

Someone presents an example of incorrect usage, and you go to great 
lengths to show how incorrect it is! Doh!

I haven't enjoyed myself so much since reading about your "surprise" 
interrupts. Based as they are on a complete misunderstanding of how 
ARM's handle interrupts, it's no wonder you were surprised.....

Keep up the good work!

Brendan

--- In lpc2000@yahoogroups.com, "jayasooriah" <jayasooriah@...> wrote:
>
> --- In lpc2000@yahoogroups.com, "Paul Curtis" <plc@> wrote:
> 
> > You're acting like a spoilt child.
> 
> I will ignore this comment knowing you for what you are :)
> 
> > Something concrete:
> > 
> > void do_something_nasty(void)
> > {
> >   // I need to do something fast without a call, I need a 
register,
> >   // so I'll pick r5 as the/ code generator seems it's not using 
that
> >   // one when I run it under the debugger.
> >   asm("ldr r5, =0x12345678");
> > 
> >   // Now do soemthing with r5 because I did something above.
> > }
> 
> Excellent example of INCORRECT use of inline assembly.
> 
> You want to use "r5" for your own purpose but have chosen not to 
tell
> the compiler.  You appear not to know, or to have forgotten, that 
the
> compiler is responsible for allocation of registers.
> 
> Although I question the validity your particular requirement (as I 
can
> gather from your comments), the compiler nonetheless will accodomate
> your requirement (subject to reasonable limits) if you were to 
include
> the following declaraction in your function:
> 
> > register int r5 asm ("r5");
> 
> If you do not tell the compiler you are using a register that it 
also
> uses, you should not be surprised at what happens as a result.
> 
> While the reference to "r5" in the ASM statement may be obvious to 
you
> as a human, the compiler does not parse this string at all.
> 
> 
> Jaya
>

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.