2.19 [10] <§2.6> Find the shortest sequence of LEGv8
instructions that extracts
bits 16 down to 11 from register X10 and uses the value of this
field to replace bits 31
down to 26 in register X11 without changing the other bits of
registers X10 or X11.
(Be sure to test your code using X10 = 0 and X11 =
0xffffffffffffffff.
Doing so may reveal a common oversight.)
Here is a solution with a set of 4 instructions. It will extract bits 16 down to 11 from register X10 and uses the value of this field to replace bits 31 down to 26 in register X11 without changing the other bits of registers X10 or X11. This is also the shortest one.
Note that, SRL instruction is used to shift the 32 bits to right in the specified register by operand 1 and SLL shifts the 32 bits to the left.
SRL X22, X10, 11
SLL X22, X22, 26
SRL X11, X11, 6
ADD X22, X22, X10
Get Answers For Free
Most questions answered within 1 hours.