I have this problem, when i run this sentence they enter in an infinite loop, and i don't know why ?
Can anybody help me?
Thanks !! ;)
str2 and str4 are locals
mov edi,sval(str2)
mov edx,sval(str4)
.WHILE (edi != edx)
.IF edi > edx
mov esi, edi
sub esi, edx
mov aux1, ustr$(esi)
print aux1
.ELSEIF
mov esi, edx
sub esi, edi
mov aux2, ustr$(esi)
print aux2
.ENDIF
;.BREAK .IF aux1 == aux2
.ENDW
Can anybody help me?
Thanks !! ;)
str2 and str4 are locals
mov edi,sval(str2)
mov edx,sval(str4)
.WHILE (edi != edx)
.IF edi > edx
mov esi, edi
sub esi, edx
mov aux1, ustr$(esi)
print aux1
.ELSEIF
mov esi, edx
sub esi, edi
mov aux2, ustr$(esi)
print aux2
.ENDIF
;.BREAK .IF aux1 == aux2
.ENDW
From what I can see, the value in edx is getting changed by the print macro.
That could be your problem.
Rags
That could be your problem.
Rags
i also think so. when you call a function or macro you must be prepared that the registers eax,ecx,edx might be changed. just save the register on the stack with a push&pop or better use ebx register instead of edx.
or
.WHILE (edi != edx)
push edx
.IF edi > edx
mov esi, edi
sub esi, edx
mov aux1, ustr$(esi)
print aux1
.ELSE
mov esi, edx
sub esi, edi
mov aux2, ustr$(esi)
print aux2
.ENDIF
pop edx
.ENDW
or
.WHILE (edi != ebx)
.IF edi > ebx
mov esi, edi
sub esi, ebx
mov aux1, ustr$(esi)
print aux1
.ELSE
mov esi, ebx
sub esi, edi
mov aux2, ustr$(esi)
print aux2
.ENDIF
.ENDW
Nothing, the solucion that you put here, do the same, the loop is infinite, and don't stop.
i have a question when you use sub esi, ebx, where the instruccion put the result in esi, or in eax ??
i have a question when you use sub esi, ebx, where the instruccion put the result in esi, or in eax ??
Nothing, the solucion that you put here, do the same, the loop is infinite, and don't stop.
i have a question when you use sub esi, ebx, where the instruccion put the result in esi, or in eax ??
load it into a debugger (i like ollydbg) and see what happens in your loop. then you will also get the answear what happens with "sub esi,ebx"... ;)
you can learn a lot while watching your code in the debugger.
I try whit this i't work but only if eax > ebx and don't know why? if eax < ebx the code don't work.
:sad:
mov eax,var2
mov ebx,var4
mov aux1, ustr$(eax)
.WHILE (eax != ebx)
.IF eax > ebx
sub eax,ebx
mov aux1,ustr$(eax)
mov eax,sval(aux1)
.ELSE
sub ebx,eax
mov aux1, ustr$(ebx)
mov ebx,sval(aux1)
.ENDIF
.ENDW
loc 10,24
print "The Result Is: "
loc 46,24
print aux1
:sad:
mov eax,var2
mov ebx,var4
mov aux1, ustr$(eax)
.WHILE (eax != ebx)
.IF eax > ebx
sub eax,ebx
mov aux1,ustr$(eax)
mov eax,sval(aux1)
.ELSE
sub ebx,eax
mov aux1, ustr$(ebx)
mov ebx,sval(aux1)
.ENDIF
.ENDW
loc 10,24
print "The Result Is: "
loc 46,24
print aux1
Try using EBX, ESI and EDI if you want their values to be kept intact. The EAX, ECX and EDX registers will be trashed by masm32's macros, Windows API calls, etc. For example you could use EDI and EBX.
Another thing, are those integers supposed to be signed? The .IF macro assumes unsigned integers by default. Use this for signed values:
Another thing, are those integers supposed to be signed? The .IF macro assumes unsigned integers by default. Use this for signed values:
.IF (SDWORD ptr edi) > (SDWORD ptr ebx)
I have problems using ESI and EDI, that why i use EAX, EBX and EDX, but i try again with that.
Try using EBX, ESI and EDI if you want their values to be kept intact. The EAX, ECX and EDX registers will be trashed by masm32's macros, Windows API calls, etc. For example you could use EDI and EBX.
Another thing, are those integers supposed to be signed? The .IF macro assumes unsigned integers by default. Use this for signed values:
Try using EBX, ESI and EDI if you want their values to be kept intact. The EAX, ECX and EDX registers will be trashed by masm32's macros, Windows API calls, etc. For example you could use EDI and EBX.
Another thing, are those integers supposed to be signed? The .IF macro assumes unsigned integers by default. Use this for signed values:
.IF (SDWORD ptr edi) > (SDWORD ptr ebx)
What problems? I think you have to clear. You can't go to the doctor saying you are in pain, but don't know where the pain came from. ;)
I try whit this i't work but only if eax > ebx and don't know why? if eax < ebx the code don't work.
ustr$ and sval are altering EAX ?
This is the solution that i find, i don't know if is the correct way to do it, but it work.
;)
;Rutina para encontar el MCD
mov eax,var2
mov ebx,var4
mov aux1, ustr$(eax)
.WHILE (eax != ebx)
.IF eax > ebx
sub eax,ebx
mov aux1,ustr$(eax)
mov eax,sval(aux1)
.ELSE
sub ebx,eax
mov ebx,eax
mov aux1, ustr$(ebx)
mov ebx,sval(aux1)
.ENDIF
.ENDW
loc 10,24
print "El M.C.D (Maximo Comun Divisor) es: "
loc 46,24
print aux1
;)
;Rutina para encontar el MCD
mov eax,var2
mov ebx,var4
mov aux1, ustr$(eax)
.WHILE (eax != ebx)
.IF eax > ebx
sub eax,ebx
mov aux1,ustr$(eax)
mov eax,sval(aux1)
.ELSE
sub ebx,eax
mov ebx,eax
mov aux1, ustr$(ebx)
mov ebx,sval(aux1)
.ENDIF
.ENDW
loc 10,24
print "El M.C.D (Maximo Comun Divisor) es: "
loc 46,24
print aux1