sahara
sahara

Reputation: 13

how to load an immediate value to the register in arm64?

I want to load an immediate value (0x48f0d0) to the register x0, but I have an error "Assembler messages:

/tmp/ccUzTnfa.s:257: Error: immediate cannot be moved by a single instruction"

this is the instruction I used:

mov x0, #0x48f0d0

Upvotes: 1

Views: 2724

Answers (1)

fuz
fuz

Reputation: 93172

Only certain constants can be expressed as immediate operands on ARM64. To work around this restriction, either load from a literal pool

ldr x0, =0x48f0d0

or use a movz/movk pair:

movz x0, #0xf0d0
movk x0, #0x48, lsl #16

Upvotes: 3

Related Questions