Add some cases, fix an octal bug

This commit is contained in:
PleegWat
2026-09-02 21:28:29 +02:00
parent e8cf5ae35f
commit fd5469aafc
2 changed files with 25 additions and 4 deletions
+1 -1
View File
@@ -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'
+24 -3
View File
@@ -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