title: Assembly x86 program. Counting numbers in an input
body: <p>Hello I am just learning assembly so I don't really understand many things yet.</p>
  
  <p>I have to write a program where the user inputs some kind of line of various letters numbers etc. And the program should count how many numbers there are in the input and print the counter out.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    .model small
  .stack 100h
  
  .data
  
      buffer      db 100, ?, 100 dup (0)
      count       db 0
  
  .code
  
  start:
  
      mov ax, @data
      mov ds, ax
  
      mov dx, offset buffer
      mov ah, 0Ah
      int 21h
  
      mov ah, buffer
      xor si, si
      xor cx, cx
    .loop:
  
    .notdigit:
  
      mov dl, buffer[si]
      inc Si
      cmp dl, 0
      jz .end
  
      cmp dl, '0'
      jb .notdigit
      cmp dl, '9'
      ja .notdigit
      inc count
      jmp .loop
  
    .end:
  
  ; count contains the digit count
  
  
      mov dl, count
      mov ah, 2h
      int 21h
  </code></pre>
  
  <p>I get no errors but the program doesn't really work when I run it.</p>
  
  <p>What is wrong here? And how should I change it?</p>