Question: One common pattern in machine-level programs is to add a constant value to a register. With the Y86-64 instructions presented thus far, this requires first
One common pattern in machine-level programs is to add a constant value to a register. With the Y86-64 instructions presented thus far, this requires first using an irmovq instruction to set a register to the constant, and then an addq instruction to add this value to the destination register. Suppose we want to add a new instruction iaddq with the following format:

This instruction adds the constant value V to register rB. Rewrite the Y86-64 sum function of Figure 4.6 to make use of the iaddq instruction. In the original version, we dedicated registers %r8 and %r9 to hold constant values. Now, we can avoid using those registers altogether.
Byte iaddq V, rB 0 1 0 F rB 2 3 4 LO 5 6 V 7 00 9
Step by Step Solution
3.40 Rating (163 Votes )
There are 3 Steps involved in it
Using the iaddq instruction we can rewrite the sum function a... View full answer
Get step-by-step solutions from verified subject matter experts
