Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this exercise we will look at a couple of other ways to improve the performan

ID: 3647864 • Letter: I

Question

In this exercise we will look at a couple of other ways to improve the performance of multiplication, based primarily on doing more shifts and fewer arithmetic operations. The following table shows pairs of hexadecimal numbers:

A B
a. 33 55
b. 8a 6d

As discussed in the text, one possible performance enhancement is to do a shift and add instead of an actual multiplication. Since 9 x 6, for example, can be written (2 x 2 x 2 x 1) x 6, we can calculate 9 x 6 by shifting 6 to the left 3 times and then adding 6 to that result. Show the best way to calculate A x B using shifts and adds/subtracts. Assume that A and B are 8-bit unsigned integers.





Explanation / Answer

a. 0x24 × 0xC9 = 0x1C44. 0x24 = 36, and 36 = 32 + 4, so we can shift 0xC9 left 5 places, then
   add to that value (0x1920) 0xC9 shifted left 2 places (0x324) = 0x1C44. Total 2 shifts, 1 add.
b. 0x41 × 0x18 = 0x618 0x41 = 64 + 1, 0x18 = 16 + 2. Best way would be to shift 0x18 left 6
   places, and then add 0x18. 1 shift, 1 add.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote