title: How do I input a number upto 3 digits in ASM
body: <p>I want to write a progam which checks if the number is prime.</p>
  
  <p><strong>My first problem:</strong> How can I store an input (from 0-999) number?</p>
  
  <pre><code>.MODEL SMALL
  .STACK 100h
  .DATA
  
  DisplayString DB 'Enter number up to 120:', 13,10,'$'
  
      .CODE
  Begin:
      MOV AX,@DATA
      MOV DS,AX
  
      MOV AH,9
      MOV DX,OFFSET DisplayString
      INT 21h
  
      MOV ah,1h
      INT 21h ;read into AL
  
      ;The code to store the number here
  
  
  
  
      MOV AH,4Ch
      INT 21h
      END Begin
  </code></pre>
  
  <p>Well, if it is 0-9 it is easy, but if the numbe is like 120? how can I store it? I thought about using an array, and multiplying each element by 10, and then adding the next one.</p>
  
  <p>For example, 120 will be something like: (((1*10) + 2)*10)+0</p>
  
  <p>MY CODE:</p>
  
  <pre><code>; //READ 3 DIGITS // ;
  ;read first digit fo e.g. '1'
  MOV ah,1h
  INT 21h ;read into AL
  
  ; BL will be 10.
  MUL num ; AX = AL * num
  MOV BL,AL
  
  ; read second digit for e.g. '2'
  MOV ah,1h
  INT 21h ;read into AL
  
  ;BL will be '11' now.
  ADD BL,AL
  
  ;BL will be '110' now.
  MUL num ; AX = AL * num
  MOV BL,AL
  
  ;read third digit
  MOV ah,1h
  INT 21h ;read into AL
  
  ;AL is 3, so BL will be '123'
  ADD BL,AL
  
  ; // FINISH READING 3 DIGITS // ;
  </code></pre>