The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: shawn on April 09, 2010, 07:48:33 PM

Title: how can I write if there is no input?
Post by: shawn on April 09, 2010, 07:48:33 PM
hello it's kind of cmp problem

if eax = 0
we can write
cmp eax,0
ze somewhere

then
there is no input and just hit enter button,
how can I write it?

thank you
Title: Re: how can I write if there is no input?
Post by: oex on April 09, 2010, 07:53:27 PM
inkey "Press a key to continue..."

and I think you mean....

cmp eax, 0
je

not ze :)
Title: Re: how can I write if there is no input?
Post by: shawn on April 09, 2010, 08:01:34 PM
I mean how can i write the code for non input

how my code regognize there is no input and jump to exit.

Thank you   :bg
Title: Re: how can I write if there is no input?
Post by: oex on April 10, 2010, 01:30:17 AM
I'm not sure that I understand the question.... I think you need to list more code.... if there is no/null input and either a pointer to the input/null is in eax or the length of input is in eax then

cmp eax, 0
je exit

; There is input so execute code on input here

exit:
Title: Re: how can I write if there is no input?
Post by: hutch-- on April 10, 2010, 03:13:16 AM
Shawn,

We are not capable of guessing what you are doing wth your code but from the little you have told us its something like this.


  cmp eax, 0
  je exitlabel
  ; other code
.....................
  exitlabel:
    invoke ExitProcess etc ....
Title: Re: how can I write if there is no input?
Post by: clive on April 10, 2010, 04:02:51 AM
I think the question is one about no parsable input. With a routine to convert ASCII numbers to a binary value in EAX, perhaps it sets the carry flag if the input is null/void or contains characters other than numbers.

For example sscanf(input, "%d", &number) returns 0 if there is no usable input, 1 if it does, and the value is in 'number'.

  call  getnumber
  jc    failed

  cmp eax,0
  jz  zeroentered

-Clive