I'm trying to solve exercism.io problem on x86_64 assembly track and am stuck on segfault within the first test.
DEFAULT REL
section .rodata
string db "One for you, one for me.", 0
section .text
global two_fer
two_fer:
mov rdi, [rsp + 8]
mov rsi, [string]
mov rcx, 1
movsb
ret
Test is as follows:
void test_no_name_given(void) {
char buffer[BUFFER_SIZE];
two_fer(NULL, buffer);
TEST_ASSERT_EQUAL_STRING("One for you, one for me.", buffer);
}
Inspecting through gdb, it segfaults at movsb instruction.
Any ideas as to what is going wrong here?