Вопрос

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!

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top