IMX53 inline assembler with use of module/global variables

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IMX53 inline assembler with use of module/global variables

1,136 Views
davidgolke
Contributor I

I am wondering if there is a way to make use of the __asm() or asm() with global or module variables.  Say for example, I have myModuleVariable and I wish to variable inside of the __asm() or asm() inline assembler functions, is this possible? 

Say for example, I want to set a global variable to 1 by doing something like this:

__asm(

"        MOV      R0,#+1\n"

"        LDR      R3,myModuleVariable\n"

"        STRB     R0,[R3, #+0]\n"
);

This is giving me the following error:
Error[Lp002]: relocation failed: value out of range or illegal: (someAddress)

I notice that the other disassembled functions that make use of this do so through means of the data table such  as

LDR R3, ??DataTable1_1 when disassembled to a .s file.  However because of the risk of the data table changing throughout compilations I cannot use this ??DataTableX_X, unless I were to double check and update with every build. 

Labels (1)
0 Kudos
Reply
3 Replies

944 Views
igorpadykov
NXP Employee
NXP Employee

Hi David

LDR,STR instructions have limit on branch, details are prvided for example in arm

documentation Table 3-2 Offsets and architectures, LDR/STR DUI0489C_arm_assembler_reference.pdf

One can add additional table with long branches in visibility of problematic instruction

or use other ways, depending on linker capabilities. This should be described in linker

documentation.

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

944 Views
davidgolke
Contributor I

Also, I really only have two variables.  One that is holding an address that I need to load into a register, and another that I simply need to set to 1 based on test conditions. 

0 Kudos
Reply

944 Views
davidgolke
Contributor I

Hello Igor,

I'm wondering if it is possible to make use of global/module variables at all with the inline assembler functionality (__asm/asm()) and any instructions.  Not necessarily the LDR, but that is one I was going to use.  I can look into the DUI0489C_arm_assembler_reference.pdf but if it is not possible to use these variables at all with __asm then I will likely have to find a new solution. 

Thanks,

David

0 Kudos
Reply