Question

I'm trying to concatenate two strings in Assembly but I can't seem to get it working. I have the following piece of code:

.data

message: .asciz "message"
leading: .asciz "leading"

.globl main

main:
    push $message
    push $leading

    call strcat

    push %eax

    call printf
...

When I try to append a string with more than 16 characters to another string, it gives a segmentation fault in the strcat call according to gdb. Am I missing something here? Is there any way to make strcat working on strings longer than 16 characters?

Thank you!

Was it helpful?

Solution

You haven't allocated more than a total 16 bytes. You need to reserve enough memory for the resulting string to fit in the destination.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top