From 5e0632c6703a1f4316afb87ab637f52e0c4a6c82 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sat, 24 Aug 2024 11:46:18 +0800 Subject: [PATCH] Fix str cmp assert breaking the stack --- tests/assert.asm | 4 ++++ tests/value_to_str_test.asm | 12 ++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/assert.asm b/tests/assert.asm index 5b8a152..117b056 100644 --- a/tests/assert.asm +++ b/tests/assert.asm @@ -314,6 +314,8 @@ assert_ok: %macro assert_str_eq 3 ; assert_str_eq [expected] [actual] [__LINE__] + push_registers + mov rbp, rsp sub rsp, 16 mov qword [rbp-16], %1 @@ -337,6 +339,8 @@ assert_ok: call assert_ok mov rsp, rbp + + pop_registers %endmacro assert_entry: diff --git a/tests/value_to_str_test.asm b/tests/value_to_str_test.asm index 79e517e..8cd1db1 100644 --- a/tests/value_to_str_test.asm +++ b/tests/value_to_str_test.asm @@ -3,13 +3,6 @@ _start: init_test __FILE__ - ; print_label s_assert_expected - ; mov rax, rsp - ; mov rdi, 8 - ; call print_hexdump - ; call print_newline - - test_int_to_str: mov rax, 10 mov rdi, assert_actual_buf @@ -18,6 +11,7 @@ test_int_to_str: str_to_stack "10" assert_str_eq rax, rdi, __LINE__ mov rsp, rbp + test_negative_int_to_str0: mov rax, -10 mov rdi, assert_actual_buf @@ -35,7 +29,5 @@ test_ptr_to_str: assert_str_eq rax, rdi, __LINE__ mov rsp, rbp - ; TODO: this fails - exit 0 - ; end_test __LINE__ + end_test __LINE__