Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#326978 - 22/10/2009 17:45 GNU assembler & ARM
sn00p
addict

Registered: 24/07/2002
Posts: 618
Loc: South London
Hi,

Wonder if anybody here knows if GNU assembler can do macro concatenation (like armasm), I was porting some code from armasm to gnu assembler this morning and got stuck at a macro for a good few hours, it seemed that GNU was unable to handle a specific situation.

Code:
out .req r0
x_r .req r1
x_i .req r2
y_r .req r3
y_i .req r4
z_r .req r5
z_i .req r6

.macro test a,b,c
 add \a,\b_i,\c_r
.endm


The code above has names defined for registers, where values x,y,z have real and imaginary parts that are handled by postfixing the name with _r or _i, all is good so far, until you realise that the macro will not replace \b or \c with the argument value as I assume it believes the argument name is \b_i or \c_r. The armasm assembler copes with this by using syntax line $a._r where the argument has a start and end token, which is a much better idea.

I spent a good hour or so searching the web for a solution but to no avail, luckily my workaround is simple, instead of post fixing the with _r or _i, I prefix the register with r_ or i_ and then the macro argument concatenation works in my situation as the argument is stopped by the operand, so:

Code:
out .req r0
r_x .req r1
i_x .req r2
r_y .req r3
i_y .req r4
r_z .req r5
i_z .req r6

.macro test a,b,c
 add \a,i_\b,r_\c
.endm


Seems like a bit of an oversight that there isn't a mechanism to do the former, either that or I didn't find the magic escape character to make it all work.

Adrian


Edited by sn00p (22/10/2009 17:46)

Top
#326980 - 22/10/2009 18:17 Re: GNU assembler & ARM [Re: sn00p]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
add \a,\b\()_i,\c\()_r

Since binutils 2.18, anyway.

Peter

Top
#326982 - 22/10/2009 18:33 Re: GNU assembler & ARM [Re: peter]
sn00p
addict

Registered: 24/07/2002
Posts: 618
Loc: South London
Originally Posted By: peter
add \a,\b\()_i,\c\()_r

Since binutils 2.18, anyway.

Peter


Superb, why didn't I just post this morning when I wasted an hour trying to do this. I'd looked at that documentation before, but I must have been looking at an older one as it definitely didn't have that particular feature mentioned, unsure what version I'm running, I shall check it out tomorrow.

Thanks peter!

Adrian

Top
#326985 - 22/10/2009 18:46 Re: GNU assembler & ARM [Re: sn00p]
sn00p
addict

Registered: 24/07/2002
Posts: 618
Loc: South London
And the answer is, my dev environment uses 2.17 and doesn't support it or if it does, it's not documented.

http://sourceware.org/binutils/docs-2.17...d-directive-393

Anyway, it's good to know for the future!

Once again, many thanks.

Adrian

Top