News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Input Help

Started by thatsgreat2345, November 24, 2006, 07:36:38 PM

Previous topic - Next topic

thatsgreat2345

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

Tedd

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

No snowflake in an avalanche feels responsible.

thatsgreat2345

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?

Tedd

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.
No snowflake in an avalanche feels responsible.