ARM的一些汇编
1. ^后缀
ARM ® Developer Suite Version 1.2 Assembler Guide P128
4.2.4 LDM and STM
^ is an optional suffix. You must not use it in User mode or System mode.
It has two purposes:
• If op is LDM and reglist contains the pc (r15), in addition to the normal multiple register transfer, the SPSR is copied into the CPSR. This is for returning from exception handlers. Use this only from exception modes.
• Otherwise, data is transferred into or out of the User mode registers instead of the current mode registers.
例如
只有当pop/LDM列表中有pc时, 才会cpsr:=spsr. 例
ldmia sp,{r0-pc}^
这里^表示 将spsr复制到cpsr.stmdb r0, {sp, lr}^
这里^表示访问的是usr 模式下的寄存器
2. SUBS和MOVS(S后缀)
在异常模式下, SUBS pc, lr
会执行CPSR:=SPSR, 且修改PC(即跳转), 也就是用来完成从异常模式退出.
3. pop
ldm和stm指令 registers是按寄存器编号排序的(和书写顺序无关), 低编号的得到低地址的, 高编号得到高地址的.
按照寄存器编号, 而不是指令中的书写顺序来入栈和出栈.
4. blx
bl和blx的区别? 答:blx根据情况会切换到thumb.
BX{cond} Rm
Rm is an ARM register containing the address to branchto.
Bit 0 of Rm is not used as part of the address. 不管是arm或者thumb模式下, bit 0都不用作寻址.
If bit 0 of Rm is set, the instruction sets the T flag in the CPSR, and the code at the destination is interpreted as Thumb code. 如果bit 0被置位, 那么, 指令会设置CPSR的T标志位.
If bit 0 of Rm is clear, bit 1 must not be set.
本文地址: https://awakening-fong.github.io/posts/arm/arm_asm
转载请注明出处: https://awakening-fong.github.io
若无法评论, 请打开JavaScript, 并通过proxy.
blog comments powered by Disqus