The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: thatsgreat2345 on November 24, 2006, 07:36:38 PM

Title: Input Help
Post by: thatsgreat2345 on November 24, 2006, 07:36:38 PM
well im still learning but idk why it isnt working can someone shed some light on what im doing incorrect

.486
include \masm32\include\masm32rt.inc

    .code

start:
   mov eax, sval(input("First number:"))
   mov ecx, sval(input("Second Number:"))
   add eax,ecx
   .if eax < 10
    print str$(eax)
    inkey
.else
@@:
print str$(esi)
dec eax
cmp eax,0
jnz @B
inkey
.endif
invoke ExitProcess,0

end start
Title: Re: Input Help
Post by: Tedd on November 24, 2006, 09:03:31 PM
Calls to functions tend to destroy the values in eax, ecx, edx, so when you call print and inkey it will mess up your value in eax.


    mov eax, sval(input("First number:"))
    mov ecx, sval(input("Second Number:"))
    add eax,ecx
    .if eax < 10
        print str$(eax)
        inkey
    .else
      @@:
        push eax          ; <----
        print str$(esi)
        pop eax           ; <----
        dec eax
        cmp eax,0         ;this isn't actually needed - "dec" will set the zero-flag if necessary ;)
        jnz @B
        inkey
    .endif
    invoke ExitProcess,0

Title: Re: Input Help
Post by: thatsgreat2345 on November 24, 2006, 09:30:31 PM
thanks i was just curious ive been trying to find a good resource to explain what pop push and eax and ecx and what everything is and is used for do you happen to know of one?
Title: Re: Input Help
Post by: Tedd on November 25, 2006, 03:50:34 PM
There are quite a few resources/tutorials lurking around, if you can manage to find them :wink
For beginners, I suppose http://webster.cs.ucr.edu/AoA/index.html and/or http://www.drpaulcarter.com/pcasm would be the main suggestions; other members may have more.