I am using RVDS6_13 compiler and my processor is Cortex X1 (HERA). For a test where I need to do a bit of assembly language programming, I am getting below error in compilation:
Error: A1616E: Instruction, offset, immediate or register combination is not supported by the current instruction set 9 00000000 MOV x28,0xD02E7F30
Basically I need to load 0xB41138A4 to address location 0xD02E7F30 and below is my code:
MOV x28,0xD02E7F30
STR x28,0xB41138A4
CodePudding user response:
Load the value with the special “literal pool” LDR
instruction and the partial address (everything but the low 12 bits) with the ADRP
instruction. Then store with the remaining address bits as a displacement:
LDR w28, =0xD02E7F30
ADRP x29, 0xB4113000
STR w28, [x29, 0x8A4]
(I have changed your store to be a 32 bit store as I assume you've mistakingly used a 64 bit store)
Instead of the ldr w28, =...
instruction you can also use a MOVZ
/MOVK
pair to get rid of the literal pool load:
MOVZ w28, 0x7F30, LSL #0
MOVK w28, 0xD02E, LSL #16
ADRP x29, 0xB4113000
STR w28, [x29, 0x8A4]
If your binary is supposed to be position independent, you'll also have to load the address using LDR w29, =...
or MOVZ
/MOVK
as ADRP
loads a PC
-relative address:
MOVZ w28, 0x7F30, LSL #0
MOVK w28, 0xD02E, LSL #16
MOVZ x29, 0x38A4, LSL #0
MOVK x29, 0XB411, LSL #16
STR w28, [x29]