Hey all, I've been working on this little program in NASM 16 bit assembly, under a windows operating system.

It works, I just have a problem. If you don't pass it any arguments, it fails to see that there is an end of line character.

You pass arguments as..
INKEY a
and it responds "Press a to continue . . ."

If you don't pass anything, by just saying
INKEY
then it responds "Press to continue . . ." and will not exit unless I "End now"

Here's my code, any nudge in the right direction would be appreciated.


NOTE: I am using my own library for this, so if you do not recognize some commands, that is why.. Hopefuly you can see the basic idea of what's happening though, I always try to comment on every line.

[org 0100h]
%include "Library.asm"

[section .text]

string msg1		;Display "Press"
arg			;Grab the arguments off the stack
mov si,bx		;LODSB!
jmp GRABKEY		;Get the FIRST argument

GRABKEY:
lodsb			;Advance ONE character in SI
cmp al,0d		;Check if End of Line
je INVALID		;If it is, exit with ERRORLEVEL 0
mov [character],al	;Store this character in a word
string character	;Display the character
string msg2		;Display "to continue. . ."
jmp INPUTKEY		;Start asking for the key

INPUTKEY:
input [character]	;Use library procedure to check\compare AL
			;For the key passed as an argument
je VALIDPRESS		;If it's equal, we can leave!
jmp INPUTKEY		;Loop if it's not equal

INVALID:
exit 0

VALIDPRESS:
exit 1

[section .data]

character dw 0, "$"
msg1 db "Press ", "$"
msg2 db "to continue . . .", 13, 10, "$"

On the MS-DOS system functions for input I usually
use, atimes a Carriage-Return character is at the
end of the buffer lest the maximum count of
characters is met. 21/3F
0xd ends the input, that is, from the
console.
0D or 13 the Carriage Return is the end of line character.

Read a byte from a string pointed to by source index into
al, increment si to advance to the offset of the next character
in the string.

CLD ; make DF zero
MOV SI, 200h
LODSB ; get byte at DS:SI, after execution SI=201h
CMP AL, 66h ; did we retrieve the MARK???
JZ EXITER

Acidio hex burner is very pleased to have these inverted bits.
A text-file is nothing but a string or array of bytes,
in which every "line" of the file is suffixed by an ending
carriage return character, which indicates end of line.

Thats why, "I am hated", more about inverted words:
radio static beat inverted.
The interdimensional vortex: REIGN!!!! engulfed by nothingness.

Working well for a new-tomorrow.
Have a good day.

Edited 7 Years Ago by NotNull: n/a

Hey, thanks.. But i've actually changed my code around a little, and this is not as much of a problem anymore.

[org 0100h]
%include "Library.asm"

[section .text]

arg			;Grab the arguments off the stack
mov si,bx		;LODSB
jmp GRABKEY		;Get the FIRST argument

GRABKEY:
lodsb			;Advance ONE character in SI
cmp al,2dh		;Check if a "-" (Hide text)
je GRABKEY2		;If equal, jump to new procedure
mov [character],al	;Store this character in a word
jmp DISPLAYTEXT		;Start asking for the key

GRABKEY2:
lodsb			;Advance one MORE character in SI
			;This gets the actual character to display
mov [character],al	;Store the character in a word
jmp INPUTKEY


DISPLAYTEXT:
string msg1		;Display "Press"
string character	;Display the FIRST letter passed as an argument
string msg2		;Display "to continue . . ."
jmp INPUTKEY

INPUTKEY:
input [character]	;Use library procedure to check\compare AL
			;For the key passed as an argument
je VALIDPRESS		;If it's equal, we can leave!
cmp al,1bh		;Check if ESCAPE is pressed
je INVALID		;Exit if it was pressed
jmp INPUTKEY		;Loop if it's not equal

INVALID:
exit 0

VALIDPRESS:
exit 1

[section .data]

character dw 0, "$"
msg1 db "Press ", "$"
msg2 db "to continue . . .", 13, 10, "$"

You see, I changed how most of it works, and made it so you can press ESCAPE as a "Backup" way to make it exit. I also made it so you can put a "-" sign before your argument to hide the text.

This question has already been answered. Start a new discussion instead.