Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

Students also viewed these Databases questions

Question

What is an RPIC, and where was it required?

Answered: 1 week ago

Question

=+What is the most that you should pay to complete development?

Answered: 1 week ago

Question

=+development and make the product, should you go ahead and do so?

Answered: 1 week ago