This is a simple project which creates a random digit from the system clock. It takes a number, transforms it into a digit, then adds 48 so it matches in the ASCII table. The problem I have is that it doesn't print anything. From what I can tell, it needs to be a string in order to even consider printing. Is there a way I can "cast" it? Like yeah, I know, it's an integer, but pretend that it's on the ascii table? Here's my code for reference. Everything works except "prnt_clock". Last thing, I cannot use any C code/functions so no, I cannot use printf.
.global rand
.equ STDOUT, 1
.equ WRITE, 4
rand:
PUSH {LR}
BL get_clock
LDR R1, =time
ADD R1, R1, #5
LDRB R0, [R1]
BL num_to_digit
ADD R0, R0, #48
MOV R1, R0
BL prnt_clock
B rand_leave
get_clock:
MOV R7, #78 @ Get time of day
LDR R0, =time @ address of holder for time_t
MOV R1, #0 @ time zone not needed
SWI 0
MOV PC, LR
// Assumes the number is in R0
num_to_digit:
CMP R0, #9 @ Compare num to 9
SUBGT R0, R0, #10 @ If greater than, substract 10
BGT num_to_digit @ Repeat until its eq or lower than 9
MOV PC, LR @ Comeback to main
prnt_clock:
MOV R0, #STDOUT @ Print to terminal
MOV R2, #1 @ Print only the digit
MOV R7, #WRITE @ Write Syscall
@MOV R3, #0 @ Create a counter
SWI 0
rand_leave:
POP {LR}
MOV PC, LR
.data
time: .space 9