立即注冊 登錄
返回首頁

uid:111517的個人空間

日志

ARM條件碼

已有 13166 次閱讀2016-9-23 16:27 |個人分類:學(xué)習(xí)

一、    程序狀態(tài)寄存器(CPSR)條件標(biāo)志位的具體含義:      

標(biāo)志位

     

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:網(wǎng)格型; 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;}

當(dāng)用兩個補碼表示的帶符號數(shù)進行運算時,

N=1 表示運算的結(jié)果為負數(shù);

N=0 表示運算的結(jié)果為正數(shù)或零;

Z

Z=1 表示運算的結(jié)果為零;

Z=0 表示運算的結(jié)果為非零;

C

可以有4種方法設(shè)置C的值:

    加法運算(包括比較指令CMN):

C=1當(dāng)運算結(jié)果產(chǎn)生了進位時(無符號數(shù)溢出);

C=0當(dāng)運算結(jié)果沒有產(chǎn)生了進位時(無符號數(shù)溢出)

減法運算(包括比較指令CMP):當(dāng)運算時產(chǎn)生了借位(無符號數(shù)溢出)

C=0否則C=1

對于包含移位操作的非加/減運算指令,C為移出值的最后一位。

對于其他的非加/減運算指令,C的值通常不改變。

V

可以有2種方法設(shè)置V的值:

對于加/減法運算指令,當(dāng)操作數(shù)和運算結(jié)果為二進制的補碼表示的帶符號數(shù)時,V=1表示符號位溢出。

對于其他的非加/減運算指令,V的值通常不改變。

Q

ARM v5及以上版本的E系列處理器中,用Q標(biāo)志位指示增強的DSP運算指令是否發(fā)生了溢出。在其他版本的處理器中,Q標(biāo)志位無定義。

備注

N、ZC、V均為條件碼標(biāo)志位。它們的內(nèi)容可被算術(shù)或邏輯運算的結(jié)果所改變,并且可以決定某條指令是否被執(zhí)行。在ARM狀態(tài)下,絕大多數(shù)的指令都是有條件執(zhí)行的。在Thumb狀態(tài)下,僅有分支指令是有條件執(zhí)行的。

 

二、    ARM條件碼

 

操作碼

 

條件碼助記符

 

標(biāo)志

含義

0000

EQ

EQual

Z=1

相等

0001

NE

(Not Equal)

Z=0

不相等

0010

CS/HS

(C Set/Higher or Same)

C=1

無符號數(shù)大于或等于

0011

CC/LO

(C Clear/LOwer)

 C=0

無符號數(shù)小于

0100

MI

(MInus)

N=1

負數(shù)

0101

PL

(PLus)

N=0

正數(shù)或零

0110

VS

(V Set)

V=1

溢出

0111

VC

(V Clear)

V=0

沒有溢出

1000

HI

(HIgher)

C=1,Z=0

無符號數(shù)大于

1001

LS

(Lower or Same)

C=0,Z=1

無符號數(shù)小于或等于

1010

GE

(Greater or Equal)

N=V

有符號數(shù)大于或等于

1011

LT

(Less Than)

N!=V

有符號數(shù)小于

1100

GT

(Greater Than)

Z=0,N=V

有符號數(shù)大于

1101

LE

(Less or Equal)

Z=1,N!=V

有符號數(shù)小于或等于

1110

AL

 

任何

無條件執(zhí)行(默認(rèn))

1111

NV

 

任何

從不執(zhí)行

 

附:節(jié)選自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:網(wǎng)格型; 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;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

返回頂部