title: change string in TASM
body: <p>I'm try to write program for searching smallest word in the input string using this algorithm.</p>
  
  <p>My Algorithm:</p>
  
  <pre><code>Read character from input, but not echo
  If character is space:
      current_string_length = 0;
      current_string = "";
      echo character
  Else If character belong to English alphabet:
      current_string_length++;
      current_string += character;
      if current_string_length &lt; max_string_length:
         max_string = current_string;
         max_string_length = current_length_string;
      echo character
  Else If character is "\n":
      print max_string
  </code></pre>
  
  <p>But i'm new in assembly and can't find way to add character to string and clean string. How can i do this, or maybe i need to choose different algorithm for this task?</p>
  
  <p>My code:</p>
  
  <pre><code>.model small
  .stack 100h                             ; reserves 100h bytes for stack
  
  .data
  ;---------------------------------------------------------------------------------- 
  ; Variables
  maxString           db 128 dup('$') 
  currentString       db 128 dup('$')
  maxLength           dw 0
  currentLength       dw 0
  ;---------------------------------------------------------------------------------- 
  ; Messages
  helloMessage  db 10,13,'Assembly Shortest Word Finder Version 1.0 Copyright (c) 2016 RodionSoft',10,13,10,13,'Usage: enter string with length of words not more then 128 characters',10,13,10,13,10,13,10,13,'Enter string: $'
  resultMessage db 10,13,"Shortest word: $"
  ;---------------------------------------------------------------------------------- 
  ; Program
  .code
  start :
  MOV AX, @data
  MOV DS, AX
  ;----------------------------------------------------------------------------------
  ; Print helloMessage
      lea dx, helloMessage                ; LEA - Load Affective Address 
      mov ah, 9                           ; print the string of the adress 
      int 21h                             ; present in DX register
  
  
  ;----------------------------------------------------------------------------------
  ; main loop
      repeat:
          ; -------------------------------------------------------------------------
          ; Read character but not echo
          mov ah, 08h                     
          int 21h
          mov ah, 0                       ; ah = 0
  
          cmp al, 13h                     ; if(al == enter)
          jz printResult                  ;   printResult()
          cmp al, 20h                     ; if(al == enter)   
          jz spaceinput                   ;   spaceInput()
          ; -------------------------------------------------------------------------
          cmp al, 41h                     ; if(al &lt; 'A')
          jl badInput                     ;   badInput()
          cmp al, 7Ah                     ; if(al &gt; 'z')
          jg badInput                     ;   badInput()
          cmp al, 5Bh                     ; if(al &lt; '[')
          jg goodInput                    ;   goodInput()
          cmp al, 60h                     ; if(al &gt; '`')
          jg goodInput                    ;   goodInput()
          jmp badInput                    ; else badInput()
  
          goodInput:
              inc currentString
              ; currentString += al
  
  
          badInput:
              jmp repeat
  
          spaceInput:
              mov currentLength, 0
              ;clean currentString
  
          endOfIteration:
              mov ah, 2                       ; echo
              int 21h
              jmp repeat                      ; loop
  ;---------------------------------------------------------------------------------- 
  printResult:
      lea dx, secondMessage               
      mov ah, 9                           
      int 21h 
      lea dx, maxString               
      mov ah, 9                           
      int 21h 
  ;----------------------------------------------------------------------------------
  exit:
      MOV AX, 4c00h
      INT 21h
  
  StringComparison proc 
      push cx dx bx ax bp si di           ; save general-purpose registers    
  
      mov cx, maxLength                   ; cx = maxLength
      mov dx, currentLength               ; dx = currentLength
      cmp cx, dx                          ; if(currentLength &gt; maxLength)
      jl currentBigger                    ;   currentBigger()
      jmp return                          ; else return
  
      currentBigger:
          ; maxString = currentString
      return:
      pop di si bp ax bx dx cx            ; restore general-purpose registers
      ret 
  endp
  end start
  </code></pre>