;; Simple recursive function to print out a number
;; in any base.

PR:	DC	"Number:\0"
SYMS:	DC 	"0123456789abcdefghijklmnopqrstuvwxyz\0"

BASE:	EQU	16

	ld	t0,	PR(x0)
	ecall	x10, 	t0, 	5
	add	t3,	x10,	x0
	addi	x11,	x0,	BASE
	jal	ra,	bconv

	ebreak	x0,	x0, 0

bconv:
	beq	x0,	x10,	end
	addi	sp,	sp,	-24
	sd	x1,	0(sp)
	sd	x10,	8(sp)
	sd	x11,	16(sp)
	div	x10,	x10, x11
	jal	ra,	bconv
	ld	x1,	0(sp)
	ld	x10,	8(sp)
	ld	x11,	16(sp)
	addi	sp,	sp,	24
	rem	x10, 	x10,	x11
	lbu	t0,	SYMS(x10)
	ecall	x1,	t0,	3
	jalr	x0,	0(ra)

end:
	lbu	t0,	SYMS(x0)
	ecall	x1,	t0,	3
	jalr	x0,	0(ra)
