int 21h with 0ah (help me please!) ;)

Started by FuLL_MaSSa, May 15, 2006, 02:32:14 PM

Previous topic - Next topic

FuLL_MaSSa

i'm trying to use the function 0ah of int 21h. i know that dx must contain the address of the memory position where the keyboard input will be stored.
the following code is printing strange carcateres. maybe from the wrong memory position, i don't know..

;--begin code--------------------------------------------------------------------------------------------

.MODEL SMALL
.DATA
.386

assume cs:codigo,ds:dados,es:dados,ss:pilha   ;codigo = code, dados = data, pilha = stack (i'm brazilian ^^)

dados segment

         buffer   db   6 dup(0)

dados ends

codigo segment 'code'
   inicio:
         mov   ax,seg dados
         mov   ds,ax
         mov   es,ax
         mov   ax,seg pilha
         mov   ss,ax
         call   print
         jmp   fim
   
   print proc near
   
         mov   ah, 0ah
         lea   dx,buffer
         int   21h
         mov   ah,09h
         lea   dx,buffer
         int   21h
   
         ret

   print endp

   fim:

codigo ends

pilha segment stack
         db 100h dup(0)
pilha ends

end inicio

;-------------------------------------------------------------------------------------------end code--

what's wrong ?

thank you very much !

Ossa

Hi,

first, this should be in the 16-bit section... but it will be moved, I'm sure...

Second, take a look at this: http://www.ctyme.com/intr/rb-2563.htm

Notice what all the bytes in the buffer have to be set to... you just output random stuff that was in memory before, I'm guessing.

Ossa
Website (very old): ossa.the-wot.co.uk

ChrisLeslie

Hi FuLL_MaSSa

Using int21h/ah=09h to display, your memory buffer needs a '$' to mark the end of the string to display, not a zero-termination. Therefore you are simply displaying everything in memory after your buffer until a random '$' happens to occur by chance. A cheats way to do this would be: buffer   db   6 dup('$'). A better way would be to insert a '$' at the end of your buffer after you have inputted the characters.

Regards

Chris