| | |
Help with End of Line character
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 33
Reputation:
Solved Threads: 0
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.
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.
Assembly Syntax (Toggle Plain Text)
[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, "$"
It's passion that drives me.
0
#2 Oct 30th, 2009
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.
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.
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.
Assembly Syntax (Toggle Plain Text)
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.
Last edited by NotNull; Oct 30th, 2009 at 1:03 am.
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
•
•
Join Date: Oct 2009
Posts: 33
Reputation:
Solved Threads: 0
0
#3 Oct 30th, 2009
Hey, thanks.. But i've actually changed my code around a little, and this is not as much of a problem anymore.
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.
Assembly Syntax (Toggle Plain Text)
[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.
It's passion that drives me.
![]() |
Similar Threads
- detecting end of line with a file. (C++)
- read to end of line problem (C)
- New line Character in column alias (MS SQL)
- How to read end of line? (C++)
- EASY question? checking for line feed (return) in a html file with C++ (C++)
Other Threads in the Assembly Forum
- Previous Thread: x86 32-bit registers
- Next Thread: add [bx+si],al means what?
Views: 441 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 :( adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop newbie nohau osdevelopment print program range read remainder shape string text theory tsr x86





