本文介绍了如何使用"printf"用树莓派汇编语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
printf
是否可以打印的值数有限制?
Does printf
has a limit to the number of values you can print?
这是我的代码.
.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:
如您所见,R4中的值不能打印正确的值.
As you can see, the value in R4 does not print the right value.
我不知道为什么?
推荐答案
仅前4个参数在ARM的寄存器(r0-r3)中传递-其他任何args在堆栈中传递.查看程序调用ABI 详细信息.
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.
这篇关于如何使用"printf"用树莓派汇编语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!