From 9ff0a3192cb1a48692c9ecec5f9812eb582a842b Mon Sep 17 00:00:00 2001 From: PleegWat Date: Wed, 2 Sep 2026 21:33:58 +0200 Subject: [PATCH] Fix binary parsing and more tests --- strint.asm | 4 ++-- strint_test.asm | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/strint.asm b/strint.asm index 7c0783c..3830e2b 100644 --- a/strint.asm +++ b/strint.asm @@ -77,7 +77,7 @@ atoi_bin_loop: load_8 r3, [r2] cmp r3, 0x30 ; '0' jl atoi_done -cmp r3, 0x39 ; '1' +cmp r3, 0x31 ; '1' jg atoi_done add r2, r2, 1 sub r3, r3, 0x30 ; '0' @@ -143,4 +143,4 @@ add r2, r2, 1 sub r3, r3, 0x37 ; 'A' - 10 lsl r1, r1, 4 add r1, r1, r3 -jmp atoi_hex_loop \ No newline at end of file +jmp atoi_hex_loop diff --git a/strint_test.asm b/strint_test.asm index 2fa06ac..4ac78b7 100644 --- a/strint_test.asm +++ b/strint_test.asm @@ -47,6 +47,20 @@ mov r13, test7_pass jmp atoi_test test7_pass: +mov r1, 8 +mov r2, test8 +mov r3, test8_end +mov r13, test8_pass +jmp atoi_test +test8_pass: + +mov r1, 9 +mov r2, test9 +mov r3, test9_end +mov r13, test9_pass +jmp atoi_test +test9_pass: + success: jmp success @@ -103,5 +117,10 @@ test6_end: "\0" test7: U32 19 "023" test7_end: "9\0" +test8: U32 11 "0b1011" +test8_end: "\0" + +test9: U32 17 "0b10001" +test9_end: "2\0" include stdlib