In A64 assembler, there are different ways to specify addresses.
/*
[base{,#0}] Simple register (exclusive) - Immediate Offset
[base{,#imm}] Offset - Immediate Offset
[base,Xm{,LSL #imm}] Offset - Register Offset
[base,Wm,(S|U)XTW {#imm}] Offset - Extended Register Offset
[base,#imm]! Pre-indexed - Immediate Offset
[base],#imm Post-indexed - Immediate Offset
label PC-relative (literal) load - Immediate Offset
*/
I would like to use "Offset - Immediate Offset" in inline assembler.
__asm__("ldp x8, x9, %0, 16 \n\t"
:
: "m" (*somePointer)
: "x8", "x9");
This gets translated to
ldp x8, x9, [x0], 16
My goal is to reach
ldp x8, x9, [x0, 16]
How can I write such instructions with inline assembler?
asm("ldp x8, x9, [%0, %1]" : : "r" (somePointer), "i"(16) : "x8", "x9");
? – David Wohlferdasm("ldp x8, x9, [%0, %1]" : : "r" (somePointer), "i"(16), "m" (*somePointer) : "x8", "x9");
(ie have the constraint, but don't reference it). Or add the "memory" clobber. Note that as written, you are only telling the compiler that the asm reads the memory, not that it changes it. – David Wohlferd