0

Hi,
I am using NASM and I am having a problem finding the correct instruction to capture string (more than one character) data from the keyboard.

I can capture int data (read_int) or even one character with get_kb

Any help would be appreciated.
Thanks

4
Contributors
5
Replies
8
Views
9 Years
Discussion Span
Last Post by sajid1
0

Call your single key routine in a loop until
- the buffer where you're storing the string becomes full
- some previously determined character (say newline) is received.

0

Thanks for your reply. So, there is not a readstring command?

0

Thanks for your reply. So, there is not a readstring command?

Nope -- in assembly language you have to roll your own. You can use C library functions, but that would defeat the purpose of you writing assembly language.

0

when i run this code, it takes only 5 inputs.
how should i make it to take inputs untill i press "enter key"?


org 0x0100

xor ax,ax
xor dx,dx

;print a string
mov dx,ask
mov ah,9h
int 21h

;read and display a character
mov cx,0ah
mov si,getname

loop1:
mov ah,1h
int 21h

cmp al,0dh
je loop2

mov [si],al
inc si
loop loop1

loop2:
mov ah,9h
mov dx,name
int 21h


mov ax,0x4c00
int 21h

ask: db 'Enter data:$'
name: db 0dh,0ah
getname: db '$$$$$$$$$$$$$$'

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.