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?



On Thu, 2005-09-01 at 17:46, Kurt Kennett wrote:
> hi.
> 
> I'm trying to do this:
> 
> ldr r0, =<32-bit constant>
> 
> The thing is, the constant is constructed at compile time in the .cpp file 
> that is invoking the arm inline assembler:
> 
> asm volatile (
> "ldr r0, =%0\n"
> :
> : "?"( 0xC0000000 | some-value-defined-in-a-C-header | 
> some-other-value-defined-in-another-C-header )
> );
> 
> my problem is that i can't find the constraint to use for the "?" character 
> above.  If i use 'm' i just get warnings about lvalues and stuff.   The 
> problem is i want to use my C/C++ defines and constants to make the value, 
> and not have to duplicate them in the assembler.

Sorry, gcc just can't handle this.  To use this from of loading a
constant gcc would have to understand how to place the real constant
value into one of its constant pools, but it can't do this because it
doesn't really understand which instruction is being used to do the load
(and different instructions have different amounts of pc-relative
addressing range), so it can't generate the code safely.  So the only
alternative is to pass the constant in as a register value and (if you
need it in some specific register) to copy it there with a mov
instruction.

R.