title: Assembly code to display string
body: <p>I have this piece of assembly code to accept a string and display the string back.</p>
  
  <p>My problem is I'm not able to figure out how exactly the name is getting stored in <code>name1</code> as we are using buff to store the input from the user.</p>
  
  <p>I know that</p>
  
  <pre><code>buff label byte
  maxchar db 50
  readchar db 0
  name1 db 48 dup(0)
  </code></pre>
  
  <p>is got something to do with this. But I'm not able to understand the working.</p>
  
  <pre><code>.model small
  .stack
  .data
      buff label byte
      maxchar db 50
      readchar db 0
      name1 db 48 dup(0)
      m1 db 10,13,"enter name: $"
      m2 db 10,13,"your name is: $"
  .code
      mov ax, @data
      mov ds, ax
      lea dx, m1
      mov ah, 09
      int 21h
      lea dx, buff
      mov ah, 10
      int 21h
  
  
      mov ah,0
      mov al, readchar
      add ax, 2
      mov si, al
      mov buff[si],24H ;ascii code for $ to terminate string
      lea dx, m2
      mov ah, 9
      int 21h
      lea dx, name1
      mov ah, 09
      int 21h
  
      mov ah, 4ch
      int 21h
  end
  </code></pre>
  
  <p>please help!</p>
  
  <p>thank you.</p>