title: Concatenate two given strings in 8086 + MOVSB does not work
body: <p>I'm trying to write a 8086 assembly program to concatenate two given strings.
  In order to do this, I used a "<em>REP MOVSB</em>" instruction, but the program didn't work well. So I wrote a program that should statically concatenate two strings, but it seems that "<em>REP MOVSB</em>" does not affect on strings at all.
  Here's the part of code I wrote for test:</p>
  
  <pre>                                          
  data    segment
  
  string1 db  "Lotfi", 0
  string2 db  "Ali ", 0 
  
  data ends
  
  
  code segment    
  
  ASSUME  CS: code, DS: data
  
  start:
      cld
      mov     ax  , data
      mov     DS  , ax
  
      mov     SI  , offset string1
      mov     DI  , offset string2
      add     DI  , 3 ; Adding the length of destination string to the DI
  
  
      mov     cx  , 5
      rep movsb ; This should concat two strings
  
      ; Printing the result character by character on the console
      mov     SI  , offset string2
  l:  lodsb           ; Printing loop
      mov dl, al
      mov ah, 2h
      int 21h
      jmp l
  
  
      hlt 
  
      code ends
  end start
  </pre>
  
  <p>The result of the code is something like:</p>
  
  <pre>
  Ali             ü,Z0???... (And so)
  </pre>
  
  <p>What's wrong with my code?
  Tanx</p>