News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

get useriput

Started by xellos, August 09, 2009, 05:05:47 PM

Previous topic - Next topic

xellos

how can i get input from the user?
i looked on this site http://spike.scu.edu.au/~barry/interrupts.html
it says you can use AH 06 console input/output

but there is no tut on how to do that.
can someone help me out?

dedndave

i suggest you download Ralf Brown's Interrupt List
http://www.cs.cmu.edu/~ralf/files.html

xellos

i dont understand all that im just starting asm

dedndave

well, it is a useful reference
get it and browse through the functions you already know and understand
that will help you read other functions

as for INT 21h, function 6, i think it requires a data structure

oh - it is for single character input

        mov     ah, 6
        mov     dl, 255
        int     21h

if there is a character, it is returned in AL and removed from the keyboard buffer
if there is no character, the ZF is set (i.e. ZERO = true)

FORTRANS

Hi,

   MS-DOS function 1 is "Read Keyboard with Echo".
Waits for a keypress if none available, single character.


        MOV     AH,1
        INT     21H
        MOV     [InputChar],AL


   Function 6 is "Direct Console I/O".   For input, it
is a deadndave says, looks for a char, but does not
wait.


        MOV     DL,0FFH ; Indicate input wanted
        MOV     AH,6
        INT     21H
        JZ      NoCharYet
        MOV     [InputChar],AL


   Function 7 is "Direct Console Input".  It waits for a
character but does not echo it to the screen..  It also
does not check for a Ctrl-C.


        MOV     AH,7
        INT     21H
        MOV     [InputChar],AL


   Function 8 is "Read Keyboard Without Echo".  This is
Like fn 7 except for Ctrl-C checking.

   Function 0AH is "Buffered Keyboard Input".  It will get
an entire string, but rquires an input buffer structure.
See the thread "Buffered Input.[solved]", and reuse it if
you still have questions.

http://www.masm32.com/board/index.php?topic=10689.0

HTH,

Steve N.

xellos

i have managed to make this but whats wrong?


.model small
.stack 100h
.data

    string db 20,0,21 dup('$')

.code

start: 

    mov dx, offset string
    mov ah, 0ah
    int 21h

    mov dx, offset string
    mov ah, 09h
    int 21h
   
    mov ah, 4ch             ; exit program.
    int 21h   

end start

i can type something but when i hit enter instead of printing the text i typed it prints a mess of chars.

dedndave

try this...

        mov dx, offset string
        mov ah, 0ah
        int 21h

        mov dx, offset string+2
        mov ah, 09h
        int 21h

dedndave

#7
actually, the data should look like this...

BufLen  db 20
RetLen  db 0
BufInp  db 21 dup(?)


then, in the code, terminate the string...

        mov     dx,offset BufLen
        mov     ah,0Ah
        int     21h

        xor     bx,bx
        mov     bl,RetLen
        mov byte ptr BufInp[bx],24h     ;'$'

        mov     dx,offset BufInp
        mov     ah,9
        int     21h


that way, when you go to use the buffer a second time, it gets properly terminated

FORTRANS

Hi,

   It looks as if you need to initialize your data segment register DS.
On startup it points to the PSP, not your data.

Steve

dedndave

what Steve said - lol
oh yah - that would also help