Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Operation C car B A - - - - - - - - - - - - - - - - - - - -

Operation C car B A
------------------------------------------------------------
(Start)00000000011010011
Shift C left, Shift B left, Add A 00000011110100011
Shift C left, Shift B left, Add A 00001001101000011
Shift C left, Shift B left 00010010010000011
Shift C left, Shift B left, Add A 00100111100000011
The result, 00100111 is 32+7=39, which is what you get with 3\times 13. As you can see
by the above, when the shift of B sets the carry bit, then one adds A, otherwise one only
completes the shifts. Regardless of the numbers A and B, the process always takes exactly 4
iterations.
Your task is to translate the above algorithm into a functional code block that would allow a
multiplication of any 4-bit integers (0-15). You will also need a loop counter to keep track of
how many iterations you complete. Note 1: Clear the carry bit before you start the process.
Note 2: Where does B have to sit in an 8-bit register for the shifts to work properly? Hint:
what does the command SWAPF do?
Alternate algorithm? Notice that the contents of register B are destroyed. Also notice that
those bits must live in the top nybble of the 8-bit register that is shifted left. One could use
a single register to hold the result C (which grows from the right) and the operand B (which
is gobbled-up at the left) as each shift is carried out. Thus: one less variable and one less
shift per iteration.

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_2

Step: 3

blur-text-image_3

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

Discuss the impact of margin on risk and return.

Answered: 1 week ago