Question: Need help in assembly x86. Write a subroutine named ShiftMultiplication that multiplies any unsigned 32-bit integer by EAX: Use only shifts and addition instructions. Pass
Write a subroutine named ShiftMultiplication that multiplies any unsigned 32-bit integer by EAX: Use only shifts and addition instructions. Pass the integer to the subroutine in the EBX register, and return the product in the EAX register. Assume that the product is never larger than 32 bits. You are only to use a loop (do-while) to shift the multiplier to the right, keeping track of the number of shifts that occur. The resulting shift count can then be applied to the SHL instruction, using the multiplicand as the destination operand. Then, the same process must be repeated until you find the last 1 bit in the multiplier. You are not allowed to use the loop instruction and are not allowed to use the factoring method. Run your program using the debugger to verify your answers. The main program that calls the subroutine and displays the product is given to you as shown below: Submit the following: Lastname3.asm INCLUDE Irvine.32inc .data p1 BYTE "Enter the multiplicand: ", 0 p2 BYTE "Enter the multiplier: ".0 p3 BYTE "The product is ", 0 .code main PROC call Clrscr:Input the multiplicand mov edx.OFFSET p1 call WriteString call ReadDec:ReadDec stores the first input (multiplicand) in eax mov ebx, eax:save eax in ebx so the next ReadDec will not overwrite it:Input the multiplier mov edx.OFFSET p2 call Writestring call ReadDec:ReadDec stores the second input (multiplier) in eax call Crlf multiply EBX by EAX, producing EAX call Multiply:Display the product in EAX mov edx.OFFSET p3 call WriteString call WriteDec call Crlf exit main ENDP
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
