ARM 汇编以十进制形式打印寄存器值
我有一个求幂子例程,可以进行计算并将结果放入 r0 中。目前我可以以十六进制打印结果,但我也想以十进制打印它。在网上进行了大量搜索后,我还没有找到直接的方法。似乎是一个简单的任务,但我无法弄清楚。
谢谢
I have an exponentiation subroutine that does the calculation and puts the result in r0. Currently I can print the result in hexadecimal, but I also want to print it in decimal. After doing a lot of searching online I haven't found a straightforward way of doing it. Seems like a simple task to do but I can't figure it out.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很想说“链接到 C 库并调用 printf”。如果这不是一个选项,那么给定一个在 r0 中输出 ASCII 字符的“putchar”函数,这里可能会起作用。它反复将数字除以 10,将数字写入堆栈上的一个小缓冲区,然后以相反的顺序输出它们。 “umull”指令需要 4M 或更好的架构。
I'm tempted to say "link with a C library and call printf". If that's not an option, here is something that probably works, given a "putchar" function that outputs the ASCII character in r0. It repeatedly divides the number by 10, writing the digits into a small buffer on the stack, then outputs them in reverse order. It requires architecture 4M or better for the "umull" instruction.