I am new to arm assembly, i'm trying to print integer to screen instead of their ASCII representation of that number. Below is the code which i'm trying with instead of printing 99 i'm getting 'c'
@ write to num variable
mov r8, #99
ldr r9, =num
str r8, [r9]
@read from num variable and print to screen
mov r7, #4 @ syscall
mov r0, #1 @ std output
ldr r1, =num @ starting address
mov r2, #2 @ number of character to print
swi 0 @ interrupt
mov r7, #1
num: .word 0
I have checked online resources which has numerous examples of printing strings but not numbers.
as -o num.o num.s
ld - num num.o
[root@alarmpi ]# ./num
Kindly let me know how to output numbers using ARM assembly (possibly without using C libraries).
I think you'll need to write yourself a function to convert into ascii, then pass the result to semihosting call. For reference, here is a list of the available semihosting calls:
Martin Weidmann Thank you. I will check it out.
View all questions in Classic processors forum