# Test for fmt_decimal .org 0 # Provide program starting address to linker .global _start .extern fmt_decimal /* newlib system calls */ .set SYSEXIT, 93 .set SYSWRITE, 64 .section .rodata inputs: .word 0, 1, 2, 3, 9, 10, 100, 0x80000000 inputs_end: .section .bss buf: .skip 11 .text _start: # li a0, '\n' # la a1, buf # sb a0, 8(a1) # append newline to buf la s0, inputs # init loop variables la s1, inputs_end loop: lw a0, 0(s0) la a1, buf jal fmt_decimal mv a2, a0 # store length of decimal string into a2 for use by SYS_write li a0, '\n' la a1, buf add t0, a1, a2 # offset to end of buffer sb a0, 0(t0) # append newline to buf li t0, SYSWRITE # "write" syscall li a0, 1 # 1 = standard output (stdout) la a1, buf # load address of output string addi a2, a2, 1 # add one to length for newline ecall # invoke syscall to print the string addi s0, s0, 4 # increment input pointer to next inputs bltu s0, s1, loop # if the input address is less than inputs_end, loop li t0, SYSEXIT # "exit" syscall la a0, 0 # Use 0 return code ecall # invoke syscall to terminate the program