From ca6d6e6d3157fbf3aee2acf1e61cfcc472095ece Mon Sep 17 00:00:00 2001 From: Kwarde Date: Sun, 27 Jul 2025 21:11:53 +0200 Subject: [PATCH] Fix strcat SIGSEGV crash --- src/console.asm | 12 ++++++------ src/tests.asm | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/console.asm b/src/console.asm index b1d9102..26fb55d 100644 --- a/src/console.asm +++ b/src/console.asm @@ -31,8 +31,8 @@ print: mov rsi, rdi call strlen mov rdx, rax - mov rax, NR_write - mov rdi, FD_stdout + mov eax, NR_write + mov edi, FD_stdout syscall add rsp, SIZE_QWORD ret @@ -48,11 +48,11 @@ print: puts: sub rsp, SIZE_QWORD call print - mov rsi, mNL + mov esi, mNL mov r10, rax - mov rax, NR_write - mov rdi, FD_stdout - mov rdx, 1 + mov eax, NR_write + mov edi, FD_stdout + mov edx, 1 syscall mov rax, r10 inc rax diff --git a/src/tests.asm b/src/tests.asm index 3ccbf8f..faff6a3 100644 --- a/src/tests.asm +++ b/src/tests.asm @@ -1013,14 +1013,14 @@ _start: call puts ; TEST 4: strcat(strBuff1, str4, 1) - ;printTest(strcat4) - ;lea rdi, [rel strBuff1] - ;lea rsi, [rel str4] - ;mov rdx, 1 - ;call strcat ;SIGSEGV - ;assert_eq(strBuff1) - ;lea rdi, [rel strBuff1] - ;call puts + printTest(strcat4) + lea rdi, [rel strBuff1] + lea rsi, [rel str4] + mov rdx, 1 + call strcat ;SIGSEGV + assert_eq(strBuff1) + lea rdi, [rel strBuff1] + call puts %endif ;--- strclr()