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

Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. As

ID: 3903888 • Letter: U

Question

Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. Asks the user to enter 2 numbers. Assume that the user enters unsigned 32-bit integers only. 2. Displays the product of the two numbers. Assume that the result will never be larger than 32 bits. 3. This process will continue till the user enters 0 for both inputs. You can’t use mul instruction in your program: You need to use shifting and addition only. Your program must have at least one procedure called multiply.This procedure can’t use any global variables (variables that are inside .data segment). The caller of this procedure sends its argument through the stack. 3. The procedure receives the multiplicand and multiplier through the stack. It returns the product through the stack also. No passing by registers. 4. inside your procedure if you need to use a register, you have to preserve its original value.You can't use uses operator. 5. The procedure is in charge of cleaning the stack.

Explanation / Answer

Solution:

section .text
global _start ;must be declared for using gcc
  
_start: ;tell linker entry point

mov al,'3'
sub al, '0'
  
mov bl, '2'
sub bl, '0'
mul bl
add al, '0'
  
mov [res], al
mov ecx,msg  
mov edx, len
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
  
mov ecx,res
mov edx, 1
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
  
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel

section .data
msg db "The result is:", 0xA,0xD
len equ $- msg
segment .bss
res resb 1

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