title: How to check if input is int?
body: <p>I have this homework that requires me to ask for two integers from the user, let them choose between addition or subtraction and then display the result. One of the requirements for the assignment is that you must send an error message if the input is invalid. For example, if instead of a number you input a letter or any other character, or if you input any character other than '+' or '-'.</p>
  
  <p>I tried to compare the input to each digit(which I know is not ideal and uses more memory, but couldn't think of anything else) but it didn't work.</p>
  
  <pre><code>INPUT OF NUMBER:   
  
          mov     dx,offset MSG_1     
          mov ah,09h          
          int 21h         
  
          mov bx,offset VALUE_1   
          call    STRING_INPUT        
  
          mov bx,offset OUT_DATA_1    
          call    STRING_MOVE 
  
  STRING_INPUT    
  
          proc    near
          mov ah,0Ah          
          mov dx,offset IN_BUF    
          int 21h         
  
          mov al,byte ptr[IN_BUF + 1]     
          cmp al,0                
          jbe ST_IN_ERR
  
          mov al,byte ptr[IN_BUF + 1] 
          mov ah,00h          
          mov si,ax           
  
          mov word ptr[bx],0      
  
          mov word ptr[UNIT],1    
  
  STRING_INPUT_LOOP:  
  
          cmp si,0            
          je  STRING_INPUT_NEXT   
  
          mov al,byte ptr[IN_BUF + 1 + si]    
          sub al,30h          
          mov ah,0            
          mul word ptr[UNIT]      
          add word ptr[bx],ax     
          dec si          
  
          mov ax,word ptr[UNIT]   
          mul word ptr[TEN]       
          mov word ptr[UNIT],ax
          jmp STRING_INPUT_LOOP   
  
  STRING_INPUT_NEXT:  
        ret
  
  STRING_INPUT  
        endp
  </code></pre>
  
  <p>The program is supposed to send an error if the input is any character other than a digit, but  when I input a letter, it transform that letter into a value(which I suspect is the hexadecimal value or something of the sorts) and continues as normal. In the code above the part where i tried to compare the value to each digit is not included because I deleted it in a fit of frustration.</p>