I have the created a minimal example that displays my problem.
I am reading user input (extracted for neatness and replaced with a static int) and printing the integer to the terminal through a "ToString" method. However is is printing extra details
.global _start
//; r0 the int to display
str:
push {lr}
push {r4-r11}
mov r2, #0x0
mov r3, #1000
mov r7, #10
str_loop:
mov r4, #0x0
udiv r4, r0, r3
add r4, r4, #0x30
ldr r5, =to_string
add r5, r5, r2
strb r4, [r5]
add r2, r2, #1
sub r4, r4, #0x30
mul r6, r4, r3
sub r0, r0 ,r6
udiv r6, r3, r7
mov r3, r6
cmp r3, #0
beq return_str
b str_loop
return_str:
mov r4, #0xa
ldr r5, =to_string
add r5, r5, r2
add r5, r5, #1
strb r4, [r5]
pop {r4-r11}
pop {pc}
display:
push {lr}
push {r4-r11}
mov r7, #0x4
mov r0, #0x1
ldr r1, =to_string
mov r2, #0x8
svc 0x0
pop {r4-r11}
pop {pc}
_start:
mov r0, #999
bl str
bl display
//; exit program
mov r7, #0x1
mov r0, #0
svc 0x0
.section .data
to_string:
.skip 10
When I execute this code after compilation using
arm-linux-gnueabi-as assignment.asm -o assignment.o
arm-linux-gnueabi-gcc-11 assignment.o -o assignment -static -nostdlib
It displays 0999 to the terminal I don't want the leading zero so I would like it to print just "999" to the screen.
How do I do that?