0

I have the following code

.model small
.stack 100h 
.data
 msg         db 10, 13, "Introduce string: $"
 bufferSize  db 21  ; 20 char + RETURN
 inputLength db 0   ; numarul de caractere citite - number of characters
 buffer      db 21 DUP("$") ; actual buffer

 .code
   main proc

  mov ax, @data ; ma mut in segmentul de date
  mov ds, ax
  lea dx, msg
  mov ah, 09h ;output
  int 21h

  mov dx, offset bufferSize ; load our pointer to the beginning of the structure
  mov ah, 10 ; GetLine function - 10 este 0A in zecimal, folosim pentru afisarea imputului cu 
  buffer
  int 21h

   mov ax, @data 
   mov ds , ax 
   lea dx, buffer
   mov ah, 09 ;output
   int 21h

   endp
   end main  

I am using TASM and i have a dosbox installed. When i run this code and i write the string i want to output, it overrides with what was already in dx, which is the message. It shows something like this:

Introduce string : Hello, world ==> it outputs Hello, worldtring : How do I correct this? Also i'd like to output the lenght of my string as well and i don't know how to do that. Any ideas ?

JustAsking
  • 27
  • 6
  • 3
    I don't see if you print a CRLF *after* the first string – Michael Chourdakis Jan 18 '22 at 22:27
  • 2
    [Displaying numbers with DOS](https://stackoverflow.com/q/45904075) for printing numbers. int 21h / AH=0ah leaves the size in memory, and you labeled that byte separately. – Peter Cordes Jan 18 '22 at 22:34
  • I know how to print numbers but i want to count the characters.. I don't get what you guys are saying? @MichaelChourdakis – JustAsking Jan 18 '22 at 22:38
  • 1
    To end the string input, you're presumably pressing the Enter key, which also gets echoed to the screen like your other input, and what it does is move the cursor back to the first column (i.e. Carriage Return). So you'll want to print a Line Feed character (ASCII 10) to get to the next line. – Michael Jan 19 '22 at 06:42

0 Answers0