Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: ldr rd,=value.....how does it work?

2006-05-18 by rtstofer

> Looking around at the few code snippetts I was able to find, I noticed
> the use of instructions like:
> 
> ldr rd,=0x12345678
> 
> I cannot find any form of this apparant 32 bit immediate adressing
> mode in the assembly tables. How does it work? Are there limitations?
> 

You are correct, you can not load a 32 bit immediate constant,
regardless of what the code looks like.  But, what you can do is load
a 32 bit constant from a 'literal pool' using PC relative addressing.

So, the compiler generates a block (pool) of constants as it goes
along and actually generates a PC relative load from the pool.

Ordinarily, the compiler would rather calculate the constant in 3
arithmetic operations than use the 'literal pool' so you will see a
lot of address calculation just to get to the VIC.

I imagine it is possible to specify an optimization that will cause
more 'literal pool' operations and less address calculations - perhaps
optimize for size.

Richard

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.