ARM汇编基础

来源:互联网 发布:仙界网络直播间txt网盘 编辑:程序博客网 时间:2024/06/06 07:51

ARM体系平台手册笔记01

PC 指针寄存器

读    ARM 模式下,其值为指令地址+8,bit[1:0],始终为0    Thumb模式下,其值为指令地址+4,bit[0],始终为0    当ARM STR或STM指令存储R15时,会发生上述规则的例外。    这样的指令可以存储指令的地址加上8个字节,如读取R15的其他指令,或指令的地址加上12个字节。写    正常情况下最低的两位,必须为bit[1:0]b00

CPSR寄存器

User mode and System mode do not have an SPSR, because they are not exception modes. All instructions that read or write the SPSR are UNPREDICTABLE when executed in User mode or System mode用户和系统模式 没有spsr寄存器Each exception mode also has a Saved Program Status Register (SPSR)每个异常模式都有一个spsr寄存器其格式如下:    31 30 29 28 27 26 25 24        23     20 19   16 15     10 9 8 7 6 5 4    0      N  Z  C  V  Q Res   J         RESERVED  GE[3:0] RESERVED  E A I F T M[4:0]用户模式可以写操作的位: N Z C V Q GE[3:0] E特权模式可以写操作的位:     特权位:A I F M[4:0]  在用户模式下写这些位将被忽略    执行状态位:J T  在用户模式下写这些位将被忽略,在ARM模式下,这两位始终是0    Privileged MSR instructions that write to the CPSR execution state bits must write            zeros to them, in order to avoid changing them. If ones are written to either or both            of them, the resulting behavior is UNPREDICTABLE. This restriction applies only to            the CPSR execution state bits, not the SPSR execution state bits.            使用MSR可以写CPSR时必须保证 J T两位为0。这个限制仅仅是写CPSR,SPSR不受此限制

状态标识位详细说明

简介    N :Negative    Z :Zero    C :Carry    V :Verflow    The condition code flags in the CPSR can be tested by most instructions to    determine whether the instruction is to be executed.        执行指令前,通过判断CPSR状态标识位,最终决定指令是否执行    N 标志位:        该结果被视为二进制补码有符号整数,        then N = 1 if the result is negative  N = 1 表示结果为负数        and N = 0 if it is positive or zero   N = 0 表示结果为正数    Z 标志位:        指令执行结果为0,设置这位为1(这个通常用来表示比较结果为相同),否则设置为0    C 标志位:        设置与否有以下四种规则:            对于加法,包括比较指令CMN,当产生进位时,C标志位设置为1(这个通常用来表示有符号数产生了溢出)            对于减法,包括比较指令CMP的减法,如果减法产生借位(即无符号下溢),则将C设置为0,否则为1。            对于包含移位操作的非加法/减法,C被设置为由移位器移出值的最后一位            对于其他非加法/减法,C通常保持不变    V 标志位:        设置与否有以下2种规则:            对于加法或减法,如果发生符号溢出,则将V设置为1,关于操作数和结果作为二进制补码有符号整数            对于其他非加法/减法,V通常保持不变  
0 0
原创粉丝点击