Getting a string from the keyboard - Help 
Author Message
 Getting a string from the keyboard - Help

I know you can use the mov ah,00 then int 16 but is there a way to get
a whole string? Im trying to be able to have the user input a
filename.



Mon, 29 May 2000 03:00:00 GMT  
 Getting a string from the keyboard - Help

Quote:

> I know you can use the mov ah,00 then int 16 but is there a way to get
> a whole string? Im trying to be able to have the user input a
> filename.

int 21h function 0ah.

David



Mon, 29 May 2000 03:00:00 GMT  
 Getting a string from the keyboard - Help

Quote:

>I know you can use the mov ah,00 then int 16 but is there a way to get
>a whole string? Im trying to be able to have the user input a
>filename.

here's one way:

user_string     label   byte
max_len         db      30h
name_len        db      ?
filename        db      31h dup (' '), 13, 10,36
lea dx, prompt1  ; prompt user for filename
int 21h

mov ah, 0ah             ; Read filename
lea dx, user_string
int 21h

mov bl,name_len         ;clear c/r from end of  
mov bh, 0               ; file input string
add bx, offset filename
mov [bx], byte ptr 0

Jim Kajpust - Personal Freedoms - Michigan



Tue, 30 May 2000 03:00:00 GMT  
 Getting a string from the keyboard - Help

Quote:

> I know you can use the mov ah,00 then int 16 but is there a way to get
> a whole string? Im trying to be able to have the user input a
> filename.

Sorry, there's no interrupt routine in DOS or in the BIOS, so you have to
write your own routine.:
-----------------------------------------------------------
.code
_get_string:
push ds
pop es            ; be sure es = ds
lea bp, string    ; make bp point to the string

_loop:
 mov ah,00h
 int 16            ; Get the character..
 cmp ah, 13d         ; this is the CR or carriage return, mean string is
finish..
    je _finish        ; if equal, jump to the label..
 mov es:[bp], al        ; move the character to the string
 inc bp                ; increase bp to point to the next character in the
string
jmp _loop        ; do the loop again

_finish:
...

.data
string db 13 dup (?)
---------------------------------------------------

If you need a zero terminated string, then, write the same code, but after

the finish label, write this line..:

---------------------------
_finish:
mov es:[bp], 00h
---------------------------

You can also have a more versatile routine, that will let you erase
character :

--------------------------------------------
_get_string:
push ds
pop es  ; es = ds
lea bp, string ; point to string in memory..

_loop:
 mov ah,00h
 int 16            ; Get the character..
 cmp ah, 13d         ; this is the CR or carriage return, mean string is
finish..
    je _finish        ; if equal, jump to the label..
 cmp ah, 14d        ; this is the BS or backspace character..
    je _backspace
 mov es:[bp], al        ; move the character to the string
 inc bp                ; increase bp to point to the next character in the
string
jmp _loop        ; do the loop again
_backspace:
 dec bp            ; decrease bp to point to the previous character..
 jmp _loop

_finish:
...
----------------------------------------------

If you need more detailed examples, contact me.




Tue, 30 May 2000 03:00:00 GMT  
 Getting a string from the keyboard - Help

Quote:

>I know you can use the mov ah,00 then int 16 but is there a way to get
>a whole string? Im trying to be able to have the user input a
>filename.

Int 21h, Function 0Ah - Buffered keyboard input
Call:  AH = 0Ah
       DS:DX => buffer

Buffer has following format:
       Byte 0: Maximum number of characters to read 1..255
            1: Count of number of chars read (less 0Dh)
            2++ actual characters read (incl 0Dh)

    ...red

--
Support the anti-Spam amendment
  Join at http://www.cauce.org/



Wed, 31 May 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help! Getting binary string variable from C.

2. Help - Converting gets string to integer

3. Getting Ascii string from hex 'string'

4. Getting input from the keyboard.

5. Getting input from keyboard

6. Problem for getting the keyboard…

7. Getting input from the keyboard.

8. Question: Getting a keyboard entry without hitting ENTER

9. Getting keystokes from the keyboard

10. getting keyboard input in nasm

11. getting input from the keyboard....

12. getting keyboard input 1 char at a time

 

 
Powered by phpBB® Forum Software