im looking for a way to move any 32 bit constant in arch64 register X1.
Is there a way to perform the equivalent operation of
MOV X1, #imm32
imm32 can be any random 32 bit value like 0xaf41d32c
I know how it can be done in A32 using MOVW and MOVT. I do not want to use LDR X1, =0xaf41d32c, because i am not writing assembly code directly, but instead storing instructions in cache by writing their 32 bit ARM encodings in memory. So i basically cannot form an encoding for LDR X1, =0xaf41d32c.
For eg => According ARMv7 ref manual encoding for a instruction ADD R1, R1, #1 is 0xe2811001. So i store this in I Cache at a location and then start executing from that location.
Do A64 equivalents of MOVW and MOVT exist ? Can you suggest a solution ?
See movk .
$ echo "long foo() {return 0xaf41d32c;}" | aarch64-linux-android-gcc -O2 -S -o- -xc -
.cpu generic+fp+simd
.file ""
.text
.align 2
.global foo
.type foo, %function
foo:
mov x0, 54060
movk x0, 0xaf41, lsl 16
ret
.size foo, .-foo
.ident "GCC: (GNU) 4.9 20140827 (prerelease)"
.section .note.GNU-stack,"",%progbits
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.