title: Getting error after copying 8086 code from book
body: <p>I am having troubles running this 8086 programs that take one letter input from keyboard and outputs &quot;the letter you typed is _&quot;</p>
  <p>I just started reading my college book on this and trying to run some code from the book on my computer but got stuck here.</p>
  <p>The code below is from my college book.
  I am running it in emu8086 emulator.</p>
  <pre><code>CODE SEGMENT
              ; set the DS register
  MOV AX, DATA
  MOV DS, AX
              ; Read Keyboard
  MOV AH, 08H
  INT 21H
              ; Save input
  MOV BL, AL
              ; Display first part of Message
  MOV AH, 09H
  MOV DX, OFFSET MESSAGE
  INT 21H
              ; Display character of BL register
  MOV AH, 02H
  MOV DL, BL
  INT 21H
              ; Exit to DOS
  MOV AX, 4C00H
  INT 21H
  
  CODE ENDS
  DATA SEGMENT
       MESSAGE DB “The letter you typed is $”
  DATA ENDS
  END
  </code></pre>
  <p>The error I am getting is</p>
  <pre><code>INT 21h, AH=09h - 
  address: 00020
  byte 24h not found after 2000 bytes.
  ; correct example of INT 21h/9h:
  mov dx, offset msg
  mov ah, 9
  int 21h
  ret
  msg db &quot;Hello$&quot;
  </code></pre>
  <p>After further debugging by myself I have concluded there is some problem with this</p>
  <pre><code>MOV AX, DATA
  MOV DS, AX
  </code></pre>
  <p>If I remove it from my code it executes but with some garbage in the start.</p>
  <p><img src="https://i.stack.imgur.com/oQ8WP.png" alt="Output after removing those statements" /></p>
  <p>Any suggestions will be appreciated.</p>
  <p>Update:
  Image of emulator around the string &quot;the letter you typed $&quot;
  <img src="https://i.stack.imgur.com/DdclW.png" alt="Image of emulator around the string &quot;the letter you typed $" /></p>