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:

Byte iaddq V, rB 0  1 0 F rB 2 3 4 LO 5 6 V 7 00 9

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

1 Expert Approved Answer
Step: 1 Unlock

Using the iaddq instruction we can rewrite the sum function a... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Systems A Programmers Perspective Questions!