I cant debug the code sucessfully there was a problem in the div ebx line please change the code to make it work, Im not sure what to do anymore the goal is to make a GCD greatest common divisor algorithm please rewrite it in following assembly coding
I cant debug the code sucessfully there was a problem in the div ebx line please change the code to make it work, Im not sure what to do anymore
the goal is to make a GCD greatest common divisor
please rewrite it in following assembly coding
INCLUDE Irvine32.inc
.data
msg1 BYTE "Enter two integers: ",0
msg2 BYTE "The GCD is ",0
numberOne SDWORD ?
numberTwo SDWORD ?
remainder DWORD ?
.code
main PROC
call Clrscr
mov ecx,5
L1:
call Integers
call GCD
call Display
loop L1
exit
main ENDP
Integers PROC
mov edx, OFFSET msg1
call WriteString
call readInt
mov numberOne, eax
call readInt
mov numberTwo, eax
call Crlf
ret
Integers ENDP
GCD PROC
mov eax,numberOne
mov ebx,eax
sar ebx,31
add eax, ebx
xor eax, ebx
mov numberOne,eax
mov eax,numberTwo
mov ebx,31
add eax, ebx
mov numberTwo,eax
L2:
mov eax,numberOne
mov edx,0
mov ebx,numberTwo
div ebx
mov edi,numberTwo
mov numberOne,edi
mov edi,remainder
mov numberTwo,edi
cmp numberTwo,0
jb L3
loop L2
L3:
mov eax,numberOne
ret
GCD ENDP
Display PROC
call WriteString
call WriteDec
call Crlf
call Crlf
ret
Display ENDP
END main
Step by step
Solved in 2 steps