Question: Operation C car B A - - - - - - - - - - - - - - - - - - - -
Operation C car B A
Start
Shift C left, Shift B left, Add A
Shift C left, Shift B left, Add A
Shift C left, Shift B left
Shift C left, Shift B left, Add A
The result, is which is what you get with times 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
iterations.
Your task is to translate the above algorithm into a functional code block that would allow a
multiplication of any bit integers You will also need a loop counter to keep track of
how many iterations you complete. Note : Clear the carry bit before you start the process.
Note : Where does B have to sit in an 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 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 gobbledup 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
