From fd5469aafc729e7d9f8ab22e03b9bc868c230eb2 Mon Sep 17 00:00:00 2001 From: PleegWat Date: Wed, 2 Sep 2026 21:28:29 +0200 Subject: [PATCH] Add some cases, fix an octal bug --- strint.asm | 2 +- strint_test.asm | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/strint.asm b/strint.asm index 9ad1d86..7c0783c 100644 --- a/strint.asm +++ b/strint.asm @@ -101,7 +101,7 @@ atoi_oct_loop: load_8 r3, [r2] cmp r3, 0x30 ; '0' jl atoi_done -cmp r3, 0x39 ; '7' +cmp r3, 0x37 ; '7' jg atoi_done add r2, r2, 1 sub r3, r3, 0x30 ; '0' diff --git a/strint_test.asm b/strint_test.asm index 6e028eb..2fa06ac 100644 --- a/strint_test.asm +++ b/strint_test.asm @@ -33,10 +33,24 @@ mov r13, test5_pass jmp atoi_test test5_pass: +mov r1, 6 +mov r2, test6 +mov r3, test6_end +mov r13, test6_pass +jmp atoi_test +test6_pass: + +mov r1, 7 +mov r2, test7 +mov r3, test7_end +mov r13, test7_pass +jmp atoi_test +test7_pass: + success: jmp success -; test strint.fn_atoi +; test strint.atoi ; Arguments: ; r1 - test number ; r2 - test data label @@ -48,7 +62,7 @@ jmp success ; r9 - Expected result in r1 ; r10 - Expected result in r2 ; Notes: -; Depends on fn_atoi not clobbering r8-r10. +; Depends on atoi not clobbering r8-r10. atoi_test: mov r8, r1 load_32 r9, [r2] @@ -81,6 +95,13 @@ test4: U32 42 "42" test4_end: "\0" test5: U32 67 "67" -test5_end: "lol" +test5_end: "lol\0" + +test6: U32 1690 "0x69a" +test6_end: "\0" + +test7: U32 19 "023" +test7_end: "9\0" + include stdlib