Reputation: 129
Does printf
has a limit to the number of values you can print?
Here is my code.
.data
.balign 4
string: .asciz "\n%d %d %d %d\n"
.text
.global main
.extern printf
main:
push {ip, lr} @ push return address + dummy register
@ for alignment
ldr r0, =string @ get address of string into r0
mov r1, #11
mov r2, #22
mov r3, #33
mov r4, #444
bl printf @ print string and pass params
@ into r1, r2, and r3
pop {ip, pc} @ pop return address into pc
When I compile and execute this code it prints this:
11 22 33 1995276288
As you can see, the value in R4 does not print the right value.
I don't know why?
Upvotes: 3
Views: 12648
Reputation: 126175
Only the first 4 arguments are passed in registers (r0-r3) on the ARM -- any additional args are passed on the stack. Check out the procedure call ABI for details.
Upvotes: 11