cancel
Showing results for 
Search instead for 
Did you mean: 

Assembler program and ILink linker problems

sue
Associate III
Posted on July 27, 2010 at 06:36

Assembler program and ILink linker problems

3 REPLIES 3
epassoni950
Associate II
Posted on May 17, 2011 at 14:00

Hello,

The problem is not the linker but in your code. When you write assembly code in which you reference a data variable from a code section, assembler does not know the absolute address of variable. So it put in object file somes directives to tell to the linker how to modify somes instructions to have the good address. But the linker can make only some simple modification.

For example, i you write :

   movw r0,#var

   ldr r1,[r0,#0]

With movw instruction, you can only load a 16 bits constant in r0. Assembler is ok for this code. But assembler does not know address of var. It put directive in object file to tell the linker to put real address of var in movw instruction. But if address of var does not fit in 16 bits, linker report an error.

If you send your assembly source code, somebody can help you.

Regards

Eric

picguy2
Associate II
Posted on May 17, 2011 at 14:00

You can use the literal form: ldr Rx,=Adrs.  It generates a word pointing to Adrs then loads it PC relative.

Or for an extra half word of code space use the faster mov32 Rx,Adrs.  It generates two 32-bit instructions that together load an arbitrary 32-bit value into Rx.
sue
Associate III
Posted on May 17, 2011 at 14:00

Thankyou for your replies.  Yes, indeed, the literal form solved the problem but I cannot find this form of the instruction in the STM Programming Manual so I did not know it existed.  I ended up using it only because I have used that form in other Assemblers in the past and wondered if it might work.  I also wonder how  many others have been stumped by this.

Cheers