立即注册 登录
返回首页

uid:111517的个人空间

日志

ARM条件码

已有 13061 次阅读2016-9-23 16:27 |个人分类:学习

一、    程序状态寄存器(CPSR)条件标志位的具体含义:      

标志位

     

Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:等线; mso-ascii-font-family:等线; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:等线; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:等线; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;} table.MsoTableGrid {mso-style-name:网格型; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-priority:39; mso-style-unhide:no; border:solid windowtext 1.0pt; mso-border-alt:solid windowtext .5pt; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-border-insideh:.5pt solid windowtext; mso-border-insidev:.5pt solid windowtext; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:等线; mso-ascii-font-family:等线; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:等线; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:等线; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;}

当用两个补码表示的带符号数进行运算时,

N=1 表示运算的结果为负数;

N=0 表示运算的结果为正数或零;

Z

Z=1 表示运算的结果为零;

Z=0 表示运算的结果为非零;

C

可以有4种方法设置C的值:

    加法运算(包括比较指令CMN):

C=1当运算结果产生了进位时(无符号数溢出);

C=0当运算结果没有产生了进位时(无符号数溢出)

减法运算(包括比较指令CMP):当运算时产生了借位(无符号数溢出)

C=0否则C=1

对于包含移位操作的非加/减运算指令,C为移出值的最后一位。

对于其他的非加/减运算指令,C的值通常不改变。

V

可以有2种方法设置V的值:

对于加/减法运算指令,当操作数和运算结果为二进制的补码表示的带符号数时,V=1表示符号位溢出。

对于其他的非加/减运算指令,V的值通常不改变。

Q

ARM v5及以上版本的E系列处理器中,用Q标志位指示增强的DSP运算指令是否发生了溢出。在其他版本的处理器中,Q标志位无定义。

备注

NZCV均为条件码标志位。它们的内容可被算术或逻辑运算的结果所改变,并且可以决定某条指令是否被执行。在ARM状态下,绝大多数的指令都是有条件执行的。在Thumb状态下,仅有分支指令是有条件执行的。

 

二、    ARM条件码

 

操作码

 

条件码助记符

 

标志

含义

0000

EQ

EQual

Z=1

相等

0001

NE

(Not Equal)

Z=0

不相等

0010

CS/HS

(C Set/Higher or Same)

C=1

无符号数大于或等于

0011

CC/LO

(C Clear/LOwer)

 C=0

无符号数小于

0100

MI

(MInus)

N=1

负数

0101

PL

(PLus)

N=0

正数或零

0110

VS

(V Set)

V=1

溢出

0111

VC

(V Clear)

V=0

没有溢出

1000

HI

(HIgher)

C=1,Z=0

无符号数大于

1001

LS

(Lower or Same)

C=0,Z=1

无符号数小于或等于

1010

GE

(Greater or Equal)

N=V

有符号数大于或等于

1011

LT

(Less Than)

N!=V

有符号数小于

1100

GT

(Greater Than)

Z=0,N=V

有符号数大于

1101

LE

(Less or Equal)

Z=1,N!=V

有符号数小于或等于

1110

AL

 

任何

无条件执行(默认)

1111

NV

 

任何

从不执行

 

附:节选自ARM TOOLS ARM条件码

 

{cond} Suffix

Tested Status Flags

Description

EQ

Z set

equal

NE

Z clear

not equal

CS/HS

C set

unsigned higher or same

CC/LO

C clear

unsigned lower

MI

N set

negative

PL

N clear

positive or zero

VS

V set

overflow

VC

V clear

no overflow

HI

C set and Z clear

unsigned higher

LS

C clear or Z set

unsigned lower or same

GE

N equals V

signed greater or equal

LT

N not equal to V

signed less than

GT

Z clear AND (N equals V)

signed greater than

LE

Z set OR (N not equal to V)

signed less than or equal

AL

(ignored)

always (usually omitted)

Examples:

     CMP    R5,#10   // compare R5 with 10

     BHI    lab1     // branch to lab1 if value in R5 is higher than 10

      :

lab1:

     TST    R5,#10   // test content of R5 against 10

     ADDEQ  R6,#40   // add 40 to R6 if R5 contains 10

 

Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:等线; mso-ascii-font-family:等线; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:等线; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:等线; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;} table.MsoTableGrid {mso-style-name:网格型; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-priority:39; mso-style-unhide:no; border:solid windowtext 1.0pt; mso-border-alt:solid windowtext .5pt; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-border-insideh:.5pt solid windowtext; mso-border-insidev:.5pt solid windowtext; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:等线; mso-ascii-font-family:等线; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:等线; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:等线; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;}

路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

返回顶部