title: Storing and incrementing integer variables in MASM x86 assembly
body: <p>I'm trying to understand assembly. Today's topic is: "Storing and incrementing int variables and printing numbers" :)</p>
  
  <p>So here's my code</p>
  
  <pre><code>dane segment
       count     db     0
  dane ends
  
  code segment
  start:
       inc     byte ptr ds:[count]
       inc     byte ptr ds:[count]
       inc     byte ptr ds:[count]
  
       mov     dl,ds:[count]
       mov     ah,2
       int     21h
  
       mov     ah,4ch
       int        21h
  code ends
  end start
  </code></pre>
  
  <p>When I compile and run, I got this error:</p>
  
  <p><img src="https://i.stack.imgur.com/wuWig.png" alt="enter image description here"></p>
  
  <p>It only happens when <code>count</code> is incremented more than once.
  What wrong am I doing?</p>
  
  <p>Can somebody explain why I can't simply write:</p>
  
  <pre><code>inc     count
  </code></pre>
  
  <p>Also, why I have to put <code>byte ptr</code> when incrementing values, but not if I copy it to <code>dl</code> register?</p>