; test harness for int_to_string ; Registers: ; r8 - test address ; r9 - test method ; r12 - end of tests address li r8, tests li r12, end_of_tests next_test: ; Set up arguments and run test load_32 r1, [r8] ; Input value li r2, scratch ; Output buffer mov r3, 64 ; Output buffer size add r4, r8, 4 ; Base load_8 r4, [r4] mov r13, itoa_test_ret ; return address jmp stdlib.int_to_string.auto itoa_test_ret: nop ; For breakpoint after itoa but before r1 clobber ; Strcmp to check results add r1, r8, 5 ; expected output li r2, scratch ; actual output mov r13, itoa_strcmp_ret jmp stdlib.string.compare itoa_strcmp_ret: ; Verify results halt.ne ; Next test add r8, r8, 0x40 cmp r8, r12 jl next_test ; Done halt include ../src/stdlib @0x20000 tests: ; inlen is the number of input bytes the function is expected to consume ; addr int base result @0x20000 U32 0b0 U8 2 "0\0" @0x20040 U32 0xFFFFFFFF U8 2 "11111111111111111111111111111111\0" @0x20080 U32 0b101010 U8 2 "101010\0" @0x200c0 U32 0o0 U8 8 "0\0" @0x20100 U32 0o640 U8 8 "640\0" @0x20140 U32 0xFFFFFFFF U8 8 "37777777777\0" @0x20180 U32 0x0 U8 16 "0\0" @0x201c0 U32 0x32fF6 U8 16 "32FF6\0" @0x20200 U32 0xdeadbeef U8 16 "DEADBEEF\0" @0x20240 U32 0xFFFFFFFF U8 16 "FFFFFFFF\0" @0x20280 end_of_tests: scratch: U1024 0