Question: Help please 6. [5pt] Bonus problem The following code computes the 128-bit product of two 64-bit signed values x and y and stores the result

 Help please 6. [5pt] Bonus problem The following code computes the

Help please

6. [5pt] Bonus problem The following code computes the 128-bit product of two 64-bit signed values x and y and stores the result in memory: \( \begin{array}{ll}1 & \text { typedef } \\ 2 & \text { int128 int128_t; } \\ 3 & \text { void store_prod(int128_t } * \text { dest, int64_t } x \text {, int64_t y) }\{ \\ 4 & \text { *dest }=x *(\text { int128_t) y; } \\ 5 & \}\end{array} \) Gcc generates the following assembly code implementing the computation: \( \begin{array}{lcl}1 & \text { store_prod: } \\ 2 & \text { movq } & \% r d x, \% r a x \\ 3 & \text { cqto } & \\ 4 & \text { movq } & \% r s i, \% r c x \\ 5 & \text { sarq } & \$ 63, \% r c x \\ 6 & \text { imulq } & \% r a x, \% r c x \\ 7 & \text { imulq } & \% r s i, \% r d x \\ 8 & \text { addq } & \% r d x, \% r c x \\ 9 & \text { mulq } & \% r s i \\ 10 & \text { addq } & \% r c x, \% r d x \\ 11 & \text { movq } & \% r a x,(\% r d i) \\ 12 & \text { movq } & \% r d x, 8(\% r d i) \\ 13 & \text { ret } & \end{array} \) This code uses three multiplications for the multiprecision arithmetic required to implement 128-bit arithmetic on a 64-bit machine. Describe the algorithm used to compute the product, and annotate the assembly code to show how it realizes your algorithm. Hint: When extending arguments of x and y to 128 bits, they can be rewritten as x=264xh+xl and y=264yh+yl, where xh,xl,yh, and yl are 64bit values. Similarly, the 128-bit product can be written as p=264ph+pl, where ph and pl are 64-bit values. Show how the code computes the values of ph and pl in terms of xh,xl,yh, and yl

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!