I am running a C program that calls an external assembly function. For academic purposes, I am trying to perform strcat. I pass the two strings to my assembly program as char * parameters. I push ebp to the stack and assign string1 and string2 to edx and ebx like so:
mov edx, [ebp+8]
mov ebx, [ebp+4]
Now the rest is as follows:
procStr1:
cmp BYTE PTR [edx], 0
jne readStr1
procStr2:
cmp BYTE PTR [ebx], 0
jne readStr2
jmp bottom
readStr1:
inc edx
jmp procStr1
readStr2:
mov BYTE PTR [edx], 'a'
inc edx
inc ebx
jmp procStr2
bottom:
inc edx
mov BYTE PTR [edx], 0
pop ebx
pop edx
pop ebp
ret
I am simply testing to see if it works by adding a’s to the end of string1. If I enter ‘hi’ and ‘bye’ I expect to get hiaaa printed out by the C program (by printing out string1). Instead I get usually 13 a’s after string1, no matter how big string2 is. I would appreciate any input, it is really boggling my mind..
Did you do a:
at the top?
If so, your arguments are now found at:
Also,