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

I need assistance in writing a MASM program that finds the Greatest Common Divis

ID: 649876 • Letter: I

Question

I need assistance in writing a MASM program that finds the Greatest Common Divisor and filling out the following procedures and solving it using the recursion method. I am having trouble understanding how the two procedures really work and how to use INVOKE correctly. So far my understanding is that int1 and int2 are arguments for the function but again, I am not entirely sure how this works. Please help!

I also have to use this array to find the GCD between each two numbers, I know I have to set the loop 5 times and use a pointer to correctly move forward in the array.

Explanation / Answer

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

   mov   ax,'8'
   sub ax, '0'
   mov    bl, '2'
   sub bl, '0'
   div    bl
   add   ax, '0'
   mov    [res], ax
   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