Question: MASM 1 . Implement Bitwise Multiplication algorithm 2 . Apply loop 3 . Write user defined procedure 4 . Use user defined procedure 5 .

MASM 1. Implement Bitwise Multiplication algorithm 2. Apply loop 3. Write user defined procedure 4. Use user defined procedure 5. Apply Irvine32.inc library Problem Description: Write a procedure named BitwiseMultiply that multiplies any unsinged 32-bit integer by EAX, using only sifting and addition. Pass the integer to the procedure in the EBX register and return the product in the EXA register. Write a short test program that calls the procedure and displays the product (We will assume that the product is never larger than 32 bits). This is a fairly challenging program to write. One possible approach is to use a loop to shift the multiplier to the right, keeping track of the number of shifts that occur before the Carry flag is set. 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 (Refer to Programming Exercise #7 on page 285) Sample RunC:Irvine\Examples\Project32_VS2015\Project32_VS2015\Debug\Project.exe
I have a working code, but can't get a continue loop.
INCLUDE Irvine32.inc
.data
prompt1 db "Enter the multiplicand: ",0
prompt2 db "Enter the multiplier: ",0
resultStr db "The product is ",0
.code
main PROC
call Clrscr
mov edx, OFFSET prompt1
call WriteString
call ReadInt
mov ebx, eax
mov edx, OFFSET prompt2
call WriteString
call ReadInt
call BitwiseMultiply
mov edx, OFFSET resultStr
call WriteString
call WriteInt
call Crlf
exit
main ENDP
BitwiseMultiply PROC
; EBX: multiplicand
; EAX: multiplier
; ECX: counter for loop (32 times)
; EDX: Temporary storage for accumulating result
xor edx, edx
multiply_loop:
test eax, 1
jz skip_add
add edx, ebx
skip_add:
shl ebx, 1
shr eax, 1
loop multiply_loop
mov eax, edx
ret
BitwiseMultiply ENDP
END main
MASM 1 . Implement Bitwise Multiplication

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!