Hi im writing a program in 80x86 assembly language using masm that concatenates two strings. What I'm attempting to do is find where the end of the first string is then add the contents of the second string onto the first. Here's the code I have so far:
.586
.MODEL FLAT
.STACK 4096
INCLUDE io.h
.DATA
prompt BYTE "Input String", 0
string1 BYTE 80 DUP (?)
string2 BYTE 80 DUP (?)
displayLbl BYTE "Concatenated string", 0
.CODE
_MainProc PROC
input prompt, string1, 80 ; ask for first string
input prompt, string2, 80 ; repeat for second string
lea eax, string1
push eax
lea ebx, string2
push ebx
call strConcatenation ; procedure to concatenate the strings
add esp, 8 ; remove parameters
output displayLbl, string1 ; display result
mov eax, 0 ; exit with return code 0
ret
_MainProc ENDP
strConcatenation PROC
push ebp
mov ebp, esp
push edi
push esi
pushfd
mov edi, [ebp+8]
repnz scasb ; scan for null in string1
mov esi, [ebp+12]
dec edi
cld
whileConcStr:
cmp BYTE PTR [esi], 0 ; null source byte?
je endWhile ; stop copying if null
lodsb ; load data
stosb ; store data
jmp whileConcStr ; go check next byte
endWhile:
mov BYTE PTR [edi], 0 ; terminate destination string
popfd ; restore flags
pop esi ; restore registers
pop edi
pop ebp
ret
strConcatenation ENDP
END
When I enter strings like 'assembly' and 'language' nothing changes. Any help is appreciated, thanks.