Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with specifying registers for local variables?

8 views
Skip to first unread message

Toby Douglass

unread,
Nov 30, 2009, 4:49:13 PM11/30/09
to
Hi.

I'm using GCC 4.3.4 on ARM.

I've some inline assembly which uses LDREXD. This instruction has a
constraint that it must use contigious registers (and that the first
register is an even number, but that's not the issue here).

To control register use in the __asm__, I'm trying to specify, when I
define local variables, which register they use, e.g.

register unsigned long int __r4 asm("r4");

AFAICT, this syntax is correct.

The compile error I am receive is;

src/abstraction/abstraction_dcas.c:253: error: expected '=', ',', ';',
'asm' or '__attribute__' before 'asm'
src/abstraction/abstraction_dcas.c:253: warning: implicit declaration of
function 'asm'
src/abstraction/abstraction_dcas.c:253: error: lvalue required as left
operand of assignment
src/abstraction/abstraction_dcas.c:254: error: '__r4' undeclared (first
use in this function)

A Google search for the text of the first error gives one hit, from Sep
23rd this year, of someone having the same problem, except on Intel.

The GCC docs are pretty straightforward in this matter, so I'm finding
it hard to see where I could have gone wrong.

Toby Douglass

unread,
Nov 30, 2009, 4:59:31 PM11/30/09
to
a...@b.com wrote:

Apologies - I misquoted the example source.

It should be;

> register unsigned long int __r4 asm("r4") = first_argument;

> src/abstraction/abstraction_dcas.c:253: error: expected '=', ',', ';',
> 'asm' or '__attribute__' before 'asm'
> src/abstraction/abstraction_dcas.c:253: warning: implicit declaration of
> function 'asm'
> src/abstraction/abstraction_dcas.c:253: error: lvalue required as left
> operand of assignment
> src/abstraction/abstraction_dcas.c:254: error: '__r4' undeclared (first
> use in this function)

Which is why the third error occurs.

Alan Curry

unread,
Nov 30, 2009, 5:53:28 PM11/30/09
to
In article <MPG.257e5c43b...@text.giganews.com>,

Toby Douglass <a...@b.com> wrote:
>
>register unsigned long int __r4 asm("r4");
>
>AFAICT, this syntax is correct.
>
>The compile error I am receive is;
>
>src/abstraction/abstraction_dcas.c:253: error: expected '=', ',', ';',
>'asm' or '__attribute__' before 'asm'

It appears that you are using gcc in one of the "standard C" modes
(-ansi, -std=c99, etc.) in which "asm" is not a keyword. Use __asm__.

The error message would have been more helpful if it had said it was
expecting __asm__

--
Alan Curry

Toby Douglass

unread,
Nov 30, 2009, 6:06:30 PM11/30/09
to
pac...@kosh.dhis.org wrote:
> Toby Douglass <a...@b.com> wrote:

> >register unsigned long int __r4 asm("r4");
> >AFAICT, this syntax is correct.
> >The compile error I am receive is;
> >src/abstraction/abstraction_dcas.c:253: error: expected '=', ',',
';',
> >'asm' or '__attribute__' before 'asm'

> It appears that you are using gcc in one of the "standard C" modes
> (-ansi, -std=c99, etc.) in which "asm" is not a keyword. Use __asm__.

-std=c99



> The error message would have been more helpful if it had said it was
> expecting __asm__

You are correct. Thanks! it's not obvious that the C mode is the
problem; and the GCC docs in their examples use 'asm' without indicating
compile mode sensitivity. Shame the GCC docs aren't a wiki.

0 new messages