Problem with gas macros
Arun Vishwanathan
arun.vishwanathan@nevisnetworks.com
Wed Feb 25 15:14:00 GMT 2004
Thanks Ian. I understand the problem now.
Actually one of my macros did something like this and it worked.
.macro beq r1, r2,label
.short (0x6000 | \r1 << 8 | \r2 << 5 | ((\label - .) & 0x1F))
.endm
I now understand why this worked and the j macro did not.
An absolute value is generated for the expression (\label - .)
in this case and so the assembler is happy.
Regards.
> -----Original Message-----
> From: Ian Lance Taylor [mailto:ian@wasabisystems.com]
> Sent: Wednesday, February 25, 2004 8:14 PM
> To: Arun Vishwanathan
> Cc: binutils@sources.redhat.com
> Subject: Re: Problem with gas macros
>
>
> "Arun Vishwanathan" <arun.vishwanathan@nevisnetworks.com> writes:
>
> > I have written a gas macro as follows :
> >
> > .macro j label
> > .short (0xA000 | \label)
> > .endm
>
> In general this can not work. You can only apply the
> bitwise-or operator to absolute values. A label is not an
> absolute value; it will not become an absolute value until
> the linker assigns it a value.
>
> The wrong section error occurs because LABEL is not in the
> absolute section. We might be able to give a better error
> message here; it's an odd case that probably rarely arises.
>
> Ian
>
More information about the Binutils
mailing list