movk
Move Keep
MOVK <Wd>, #<imm16> {, lsl #<shift>}
Inserts a 16-bit immediate into a register, keeping other bits unchanged.
Details
Inserts a 16-bit immediate value into Wd at the position specified by the shift, leaving other 16-bit half-words unchanged. No condition flags are affected. This is an AArch64-only instruction commonly used to build large constants or patch specific 16-bit fields in registers.
Pseudocode Operation
shift_amount ← hw × 16
mask ← 0xFFFF ≪ shift_amount
Wd ← (Wd ∧ ¬mask) ∨ (imm16 ≪ shift_amount)
Example
MOVK w0, #16
Encoding
Binary Layout
0
11
100101
hw
imm16
Rd
Operands
-
Wd
Destination 32-bit integer register -
imm16
Imm -
shift
Shift (0,16)
Reference (Arm A64 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x72800000 | MOVK <Wd>, #<imm>{, LSL #<shift>} | A64 | 0 | 11 | 100101 | hw | imm16 | Rd | ||
| 0xF2800000 | MOVK <Xd>, #<imm>{, LSL #<shift>} | A64 | 1 | 11 | 100101 | hw | imm16 | Rd |
Description
Move wide with keep moves an optionally-shifted 16-bit immediate value into a register, keeping other bits unchanged.
Operation
bits(datasize) result; result = X[d, datasize]; result<pos+15:pos> = imm16; X[d, datasize] = result;