title: Assembly save and compare characters
body: <p>I am new to Assembly and I am trying to do the following:</p>
  
  <p><strong>pseudo code:</strong></p>
  
  <pre><code> loop:
        input
        if(input == $)
          end loop
        else if(input &lt; savedInput)
          savedInput = input
      ;
      print savedInput
  </code></pre>
  
  <p>basically it is a constant loop that detects user inputs and compares the ASCII value of saved input with the new input if new input is lower then it replaces the saved input. If input equals $ then ends loop and prints the saved input.</p>
  
  <p><strong>This is my code</strong></p>
  
  <pre><code>.MODEL SMALL
  .STACK 100h
  .DATA
      insertMsg DB 13, 10, 'Introduce un dato: ', 13, 10, '$'
  
  .CODE
      main:
          mov ax,@data
          mov ds,ax                   ; Set DS to point to the data segment
          mov dx,OFFSET insertMsg     ; Point to the insertMsg
      back:
          mov ah,9                    ; DOS: print string: Service 21h, 09h
          int 21h                     ; Display inputMsg
          mov ah,1                    ; DOS: get character: Service 21h, 01h
          int 21h                     ; Get a single-character response
          cmp al,'$'                  ; if character equals $
          je display                  ; goto display
          loop back                   ; loop back
  
      display:
          mov ah,9            ;DOS: print string: Service 21h, 09h
          int 21h             ;display input
          mov ah,4Ch          ;DOS: terminate program: Service 21h, 4Ch
          mov al,0            ;return code will be 0
          int 21h             ;terminate the program
      end main
  </code></pre>
  
  <p>The problem is that I do not know how to save and compare ASCII values</p>