Re: [arm-gnu] load constructed constant in arm inline assembly - how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] load constructed constant in arm inline assembly - how?



I don't want to duplicate my important definitions accross assembler format and C format of defines. For example:

.equiv FOO, 0x100

is assembler syntax inside a .s file.

#define FOO  0x100

is C/C++ syntax inside a .h file.

I don't want to have to keep two sets of defines up to date if things change, or if I am making over 1000 new definitions, I don't want to have to make them all again in assembler syntax.

Also, I can use the offsetof() macro to get structure member offsets, rather than making offsets for each member of a struct in assembler:

i.e.

instead of

.equiv EXSTRUCT_LA_OFFSET, 0x0
.equiv EXSTRUCT_FA_OFFSET, 0x4
.equiv EXSTRUCT_MA_OFFSET,  0x8

to access in assembler the C/C++ structure:

struct EXSTRUCT {
 unsigned long LA;
 unsigned long FA;
 unsigned long MA;
};

I don't have to write the assembler definitions if I can use offsetof() and c/c++ code with the inline assembler.

I do:

(if r1 has the address of an EXSTRUCT)
asm volatile ( "ldr r0, [r1, %0]\r\n" : : "i"(offsetof(EXSTRUCT,LA)) );

k2


From: Charles Manning <manningc2@xxxxxxxxxxxxx>
To: arm-gnu@xxxxxxxxxxxxxxxx
CC: "Kurt Kennett" <kurt_kennett@xxxxxxxxxxx>
Subject: Re: [arm-gnu] load constructed constant in arm inline assembly - how?
Date: Fri, 2 Sep 2005 09:52:42 +1200

Perhaps not the answer you want, but why not use real assembler instead?


_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.