2010-07-26 09:36 PM
Assembler program and ILink linker problems
2011-05-17 05:00 AM
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 Eric2011-05-17 05:00 AM
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.2011-05-17 05:00 AM
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