.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
Include io.h
cr equ 0DH
Lf equ 0AH
.STACK 4096
.DATA
string byte 40 Dup (?)
number dword ?
rejected byte cr, Lf, "Rejected", 0
.code
_start:
main PROC
forever: input string, 40
atod string
mov number, eax
cmp number,0
jne processing
je finish
jmp forever
processing:
cmp number,10
jg message
cmp number,-10
jl message
message: output rejected
finish:
INVOKE ExitProcess, 0
main endp
PUBLIC _start
END
What i'm trying to accomplish: Read in a number one at a time, process that number and check if it is 0, if so, exit the program, if the number is > 10 or < -10 print a message "rejected." I'm have a lot of trouble creating my jump statements, how do I make the loop continue to process numbers until 0 ? Even when I enter a "valid" number, it still prints the message "rejected" but then exits the program. Maybe I can't have multiple jump statements after a compare ?
You put the loop in the wrong order. When
0
is entered you exit, otherwise you process it andTHEN
you want to repeat the loop until0
is entered, optionally you have to print the message when the input was a wrong value.