Im just learning some ASM with 16bit x86 using A86, iv witten this code below which asks the user to enter three letters, if they are "yes the user should get the message "correct". But no matter what I always end up with "incorrect" I think its a problem with the CMP statement. Maybe someone could help.
This is probably a no-brainer for all of you but im stuck.

jmp start

msg db "Please Type the Correct Password!",10,13,"$"
ms1 db " <---This is Wrong!$"
ms2 db " <---This is Correct!$"
input1 db
input2 db
input3 db


start:
mov ah,09
mov dx,offset msg
int 21h

mov ah,01
int 21h
MOV input1,al

mov ah,01
int 21h
MOV input2,al

mov ah,01
int 21h
MOV input3,al


CMP  input1,121
JNZ wrong


CMP  input2,101
JNZ wrong


CMP  input3,115
JNZ wrong


correct:
mov ah,09
mov dx,offset ms2
int 21h
JMP exit

wrong:
mov ah,09
mov dx,offset ms1
int 21h
JMP exit

exit:
mov ah,4ch
mov al,00
int 21h


Thanks for any help or info explaining why this happens.

Orion
Posted on 2006-03-29 11:11:44 by orion1
I don't see anything wrong in your prog.
(just too many useless lines in code - you can compare al just after 01,21h
without saving it, anyway - the way you do it is not logically wrong, just not optimal)
For sure someone of inputs just didn't meet cmp conditions.
Wich one was that - you'd better look in debuger.
Or just add code before the exit that would display your inputs in decimal, so you can see what actually was in al.
Posted on 2006-03-29 17:11:00 by The Svin
This may not be the cause of your problem. However, it may be a good opportunity to avoid future frustration.

I can remember a few programs where one was required to type in "Y" or "N" to a question. But the program would accept only either lower case or upper case letters. You would bang on the "Y" key several times without any result and then realized that maybe using the <SHIFT> key along with the other keystroke is what is required.
FRUSTRATING TO NO END!!!!! :shock: :shock:

Your snipet only checks for lower case letters. You should check for both, or convert to whichever case you prefer before making the comparison.

Raymond
Posted on 2006-03-30 21:51:05 by Raymond
Yeah. Like
and al,not 20h.
Posted on 2006-03-31 10:29:39 by The Svin
Posted on 2006-04-11 00:22:53 by XCHG