Re: input and output strings
You need a buffer where the input can be both stored and printed - which means that you may also need to add some code that appends a "$" to the end of the input string if you use code 09 to output the name.
Quote:
Originally Posted by quicksilver_1931
a200
db 0d,0a,"Please enter your name: $"
a300
db 0d,0a,"Hello $"
a100
mov ah,09
mov dx,200
int 21
mov ah,0a
int 21
mov ah,09
mov dx,300
int 21
int 20
Re: input and output strings
There are two points in your code.
a) DOS 0ah function reserves the first 2 bytes of buffer for information about its available and actual lengths. If you want to use this function, you must to add 2 to dx register; otherwise there will be some strange chars at console.
My favorite way is using 3fh instead (see code below).
b) Print the actual buffer after writing "Hello " at the end.
The following code must work:
a200
db 0d,0a,"Please enter your name: $"
a300
db 0d,0a,"Hello $"
a100
mov ah,09
mov dx,200
int 21
;; DOS 0ah function replacement
;mov ah,0a
;int 21
mov ah,3fh
mov bx,0 ; handler for standard input (keyboard)
mov cx,80 ; catch at most 128 chars
mov dx,200 ; or wherever you want to store bytes
int 21
;; Insert '$' so console doesn't "go crazy" printing extra chars ...
;; anyway missing in your code
add dx,ax ;add actual input-length
mov di,dx
mov al,'$'
stosb
mov ah,09
mov dx,300
int 21
;; print actual buffer, so you get the "Hello Kitty" (or any other cool name)
mov ah,09
mov dx,200
int 21
int 20
Good luck