[英]Which register does store cmp result in arm?
I need to write a function that after work sets all registers except r0-r3 to their initial values.我需要编写一个函数,在工作后将除 r0-r3 之外的所有寄存器设置为其初始值。 I use push and pop, but I can't find which register stores the value of CMP.
我使用push和pop,但是我找不到哪个寄存器存储了CMP的值。
UPD .更新。 Thank you.
谢谢你。 It seems I am wrong.
看来我错了。 I had an assignment that had a hint: "Don't forget about callee-save registers", so it wasn't suggesting treating flags as callee saved)
我有一个提示:“不要忘记被调用者保存寄存器”,所以它不建议将标志视为被调用者保存)
cmp
, like all ARM instructions with an s
suffix like subs
, s et flags / condition codes. cmp
,就像所有带有s
后缀的 ARM 指令一样,如subs
、 s et 标志/条件代码。 These condition codes live in a register called CPSR
, the Current Program Status Register .这些条件代码存在于名为
CPSR
( 当前程序状态寄存器)的寄存器中。 Also https://en.wikipedia.org/wiki/ARM_architecture#Registers还有https://en.wikipedia.org/wiki/ARM_architecture#Registers
In all standard function-calling conventions, flags / condition codes are call-clobbered.在所有标准的函数调用约定中,标志/条件代码都被调用破坏了。 You don't need to save/restore the caller's CPSR.
您不需要保存/恢复呼叫者的 CPSR。 Just let it be call-clobbered, along with r0..3.
让它和 r0..3 一起被调用破坏。
But if you did, see https://heyrick.eu/armwiki/The_Status_register for examples like但是,如果您这样做了,请参阅https://heyrick.eu/armwiki/The_Status_register以获取类似的示例
MRS R0, CPSR ; Copy CPSR into R0
...
MSR CPSR, R0 ; Copy R0 into CPSR
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.