Acá va un ejemplo:
TITLE String Concatenate (StrConcat.asm)
; This program concatenates a source
; string to the end of a target string.
INCLUDE Irvine32.inc
INCLUDE Bsearch.inc
STRING_SIZE = 10
Str_concat PROTO,
source:PTR BYTE, ; source string
target:PTR BYTE ; target string
.data
targetStr BYTE "ABCDE",10 DUP(0)
sourceStr BYTE "FGH",0
.code
main PROC
; Display
mov edx,OFFSET targetStr
call WriteString
call Crlf
call WaitMsg
mov eax,LENGTHOF sourceStr
INVOKE Str_concat, ADDR sourceStr, ADDR targetStr
mov edx,OFFSET targetStr
call WriteString
call Crlf
exit
main ENDP
;------------------------------------------------------------
FillString PROC USES eax edi ecx edx,
pString:PTR DWORD, ; pointer to array
Count:DWORD, ; number of elements
string_1:SDWORD, ; ABCDE
string_2:SDWORD ; FGH
;
; Fills the string with "ABCDE", then concatenates, "FGH" onto it.
; Returns: nothing
;------------------------------------------------------------
mov edi,pString ; EDI points to the string
mov ecx,Count ; loop counter
mov edx,string_1
sub edx,string_2 ; EDX = absolute range (0..n)
L1: mov eax,edx ; get absolute range
add eax,string_2 ; bias the result
stosd ; store EAX into [edi]
loop L1
ret
FillString ENDP
;------------------------------------------------------------
Str_concat PROC USES eax ecx esi edi,
source:PTR BYTE, ; source string
target:PTR BYTE ; target string
;------------------------------------------------------------
mov ecx,eax ; EAX = length source
mov esi,source
mov edi,target
add edi,5
cld ; direction = forward
rep movsb ; copy the string
ret
Str_concat ENDP
END main