The clever ARM64 MOVN instruction
The bit twiddling office called. They want a function to compute a sequence of ARM64 instructions that fills a register with an arbitrary constant 64-bit number.
Zeros in positive number
All ARM64 instructions are 32 bits long, so one instruction can’t possibly
handle all 64-bit patterns. One straightforward way to assemble the desired bit
pattern is to use
MOVK
which sets any one of the four 16-bit chunks of the register without touching
any other chunks. So, four MOVK
instructions can assemble any 64-bit pattern.