home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 181.img / TASM-101.ZIP / CHAPXMPL.ARC / SUB1.ASM < prev    next >
Assembly Source File  |  1989-05-02  |  1KB  |  43 lines

  1.      DOSSEG
  2.      .MODEL    SMALL
  3.      .DATA
  4.      GLOBAL    FinalString:BYTE
  5.      .CODE
  6. ;
  7. ; Subroutine copies first one string, and then another
  8. ; to FinalString.
  9. ;
  10. ; Input:
  11. ;    DS:AX = pointer to first string to copy
  12. ;    DS:BX = pointer to second string to copy
  13. ;
  14. ; Output: None
  15. ;
  16. ; Registers destroyed: AL, SI, DI, ES
  17. ;
  18.      PUBLIC    ConcatenateStrings
  19. ConcatenateStrings  PROC
  20.      cld                         ;strings count up
  21.      mov  di,SEG FinalString
  22.      mov  es,di
  23.      mov  di,OFFSET FinalString
  24.                                  ;ES:DI points to the destination
  25.      mov  si,ax                  ;first string to copy
  26. String1Loop:
  27.      lodsb                       ;get string 1 character
  28.      and  al,al                  ;is it 0?
  29.      jz   DoString2              ;yes, done with string 1
  30.      stosb                       ;save string 1 character
  31.      jmp  String1Loop
  32. DoString2:
  33.      mov  si,bx                  ;second string to copy
  34. String2Loop:
  35.      lodsb                       ;get string 2 character
  36.      stosb                       ;save string 2 character
  37.                                  ; (including 0 when we find it)
  38.      and  al,al                  ;is it 0?
  39.      jnz  String2Loop            ;no, do next character
  40.      ret                         ;done
  41. ConcatenateStrings   ENDP
  42.      END
  43.