Condition Register

Control/status register (address: 64h) – used either to determine the status of the keyboard (when a value is read from the register) or to set up the keyboard (when a value is written to the register).

From: Computer Busses , 2000

Cortex-M3 Basics

Joseph Yiu , in The Definitive Guide to the ARM Cortex-M3 (Second Edition), 2010

three.2.1 Program Condition Registers

The PSRs are subdivided into three status registers:

Application Program Status register (APSR)

Interrupt Programme Status register (IPSR)

Execution Program Condition register (EPSR)

The 3 PSRs can be accessed together or separately using the special register access instructions MSR and MRS. When they are accessed as a collective item, the proper noun xPSR is used.

You can read the PSRs using the MRS instruction. You can also change the APSR using the MSR instruction, just EPSR and IPSR are read-only. For example:

MRS   r0, APSR   ; Read Flag state into R0

MRS   r0, IPSR   ; Read Exception/Interrupt state

MRS   r0, EPSR   ; Read Execution state

MSR   APSR, r0   ; Write Flag country

In ARM assembler, when accessing xPSR (all three PSRs every bit one), the symbol PSR is used:

MRS   r0, PSR   ; Read the combined plan condition word

MSR   PSR, r0   ; Write combined plan land word

The descriptions for the bit fields in PSR are shown in Table iii.1.

Table 3.one. Bit Fields in Cortex-M3 Program Condition Registers

Bit Description
Due north Negative
Z Zero
C Carry/borrow
V Overflow
Q Sticky saturation flag
ICI/IT Interrupt-Continuable Instruction (ICI) $.25, IF-And then educational activity condition bit
T Thumb state, always 1; trying to clear this bit volition cause a fault exception
Exception number Indicates which exception the processor is handling

If y'all compare this with the Current Program Status annals (CPSR) in ARM7, you might find that some chip fields that were used in ARM7 are gone. The Mode (Chiliad) bit field is gone because the Cortex-M3 does not have the functioning mode as defined in ARM7. Pollex-flake (T) is moved to fleck 24. Interrupt status (I and F) bits are replaced by the new interrupt mask registers (PRIMASKs), which are separated from PSR. For comparison, the CPSR in traditional ARM processors is shown in Figure 3.5.

Effigy 3.5. Current Plan Condition Registers in Traditional ARM Processors.

Read total chapter

URL:

https://www.sciencedirect.com/science/commodity/pii/B9781856179638000065

Estimator Architecture

William J. Buchanan BSc, CEng, PhD , in Software Evolution for Engineers, 1997

14.4.3 Status registers

Status registers are used to examination for various conditions in an operation, such as 'is the outcome negative', 'is the result zippo', and so on. The 2 status registers have 16 $.25 and are called the instruction arrow (IP) and the flag register (F):

IP, which is the teaching pointer. The IP annals contains the address of the adjacent teaching of the programme.

Flag register. The flag register holds a drove of xvi different conditions. Table 14.ane outlines the most used flags.

Table 14.1. Processor flags

Bit Flag position Name Description
C 0 Set on acquit Contains the carry from the most significant chip (left hand flake) following a shift, rotate or arithmetic functioning.
A 4 Set on ane/ii acquit
S 7 Fix on negative outcome Contains the sign of an arithmetics operation (0 for positive, ane for negative).
Z 6 Gear up on zero result Contains results of last arithmetic or compare result (0 for non-zero, ane for naught).
0 11 Assail overflow Indicates that an overflow has occurred in the most pregnant flake from an arithmetic performance.
P 2 Attack even parity
D x Direction
I 9 Interrupt enable Indicates whether the interrupt has been disabled.
T 8 Trap

Read total chapter

URL:

https://www.sciencedirect.com/science/article/pii/B9780340700143500591

Educational activity set up

Joseph Yiu , in Definitive Guide to Arm® Cortex®-M23 and Cortex-M33 Processors, 2021

5.fourteen.four Conditional branch

Conditional branches are executed conditionally based on the current value in the APSR (Northward, Z, C, and 5 flags, equally shown in Tabular array 5.56).

Table 5.56. Flags (condition $.25) in the APSR which tin can be used for controlling conditional branches.

Flag PSR scrap Clarification
Due north 31 Negative flag (last performance result is a negative value)
Z 30 Zero (last operation result returned a cypher value. For instance, the compare of two registers with identical values.)
C 29 Behave flag.

If the last performance is an ADD, and if the Behave flag is Fix, this indicates a carry out status.

If the last performance is a SUBTRACT, and if the Carry flag is CLEARED, this indicates a borrow status.

If the last operation is a SHIFT or ROTATE, the Carry flag is the concluding bit shifted out in the shift or rotate operation.

V 28 Overflow (the last operation resulted in an overflow situation)

APSR flags tin can be affected past:

Most 16-bit data processing instructions.

32-chip (Pollex-ii) data processing instructions with the S suffix; for example, ADDS.West.

Compare (east.g., CMP) and Test (eastward.thousand., TST, TEQ) instructions.

An instruction that writes to APSR/xPSR straight.

Unstacking operations at the end of an exception/interrupt service.

For Armv8-M Mainline processors, in that location is some other APSR flag fleck at chip 27—called the Q flag. It is for saturating arithmetic operations, but is not used for conditional branches.

The condition type of a conditional branch educational activity is indicated by a suffix, which is listed in Tabular array 5.58. These suffixes are as well used for conditional execution operations (encounter Department five.fourteen.6). Conditional branch instructions (Table 5.57, where <cond> is i of the condition suffixes) are available in 16-bit and 32-bit versions. The 16-bit and 32-bit versions take dissimilar co-operative ranges, with the Armv8-Yard Baseline only supporting the 16-bit version of the conditional co-operative instructions.

Table v.57. Instructions for conditional branch.

Instruction Description Brake

B   &lt;cond&gt; label

A sixteen-flake version of the conditional branch. &lt;cond&gt; is one of the condition suffixes in Table 5.58 It has a branch range of −256 bytes to +254 bytes

B   &lt;cond&gt;.West label

A 32-bit version of the conditional branch
Annotation: this tin can be written as "B   &lt;cond&gt; label" if the assembler automatically selects the 32-bit version when the first is &gt;   2KB.
&lt;cond&gt; is i of the condition suffixes in Table 5.58
It has a branch range of +/−1MB. Not supported in Armv8-M Baseline

The <cond> is one of the xiv possible condition suffixes listed in Table five.58.

Table five.58. Suffixes for conditional branches and provisional executions.

Suffix Branch condition Flags (APSR)
EQ Equal Z flag is gear up
NE Not equal Z flag is cleared
CS/HS Carry set/unsigned higher or same C flag is prepare
CC/LO Carry clear/unsigned lower C flag is cleared
MI Minus/negative Due north flag is gear up (minus)
PL Plus/positive or goose egg Northward flag is cleared
VS Overflow 5 flag is set up
VC No overflow Five flag is cleared
How-do-you-do Unsigned college C flag is set and Z is cleared
LS Unsigned lower or same C flag is cleared or Z is ready
GE Signed greater than or equal N flag is set and V flag is set, or
Northward flag is cleared and V flag is cleared (N   ==   5)
LT Signed less than N flag is ready and V flag is cleared, or
N flag is cleared and V flag is set (N   !=   V)
GT Signed greater than Z flag is cleared, and either both the Due north flag and Five flag are set, or both the Due north flag and V flag are cleared (Z   ==   0 and Due north   ==   V)
LE Signed less than or equal Z flag is set, or ane of the followings:
either the N flag is set and the Five flag is cleared, or the N flag is cleared and the V flag is prepare
(Z   ==   one or N   !=   V)

An case of using a conditional co-operative instruction is shown in Fig. five.16. The functioning in the diagram selects a new value for R3 based on the value in R0.

Fig. 5.16

Fig. five.sixteen. Elementary provisional branch example.

The program flow in Fig. five.16 tin be implemented using conditional branch and regular branch instructions as follows:

CMP   R0, #one   ; compare R0 to one

BEQ   p2   ; if Equal, then go to p2

MOVS   R3, #1   ; R3 = 1

B   p3   ; go to p3

p2   ; characterization p2

MOVS   R3, #ii

p3   ; label p3

...   ; other subsequence operations

Read full chapter

URL:

https://world wide web.sciencedirect.com/science/article/pii/B9780128207352000056

Architecture

Joseph Yiu , in Definitive Guide to Arm® Cortex®-M23 and Cortex-M33 Processors, 2021

Programme Condition Register (PSR)

The Program Status Register is 32-bit and tin can be subdivided into:

Application PSR—contains various "ALU flags" which are required for provisional branches and instruction operations that need special flags (e.thou., add with comport flag).

Execution PSR—contains execution country information.

Interrupt PSR—contains current interrupt/exception state data.

These three registers can be accessed as one combined register, sometimes referred to as "xPSR" in some documentation (e.g., Armv8-M Architecture Reference Transmission), as shown in Fig. 4.seven. In programming, the symbol PSR is used when accessing the whole PSR. For example,

Fig. 4.7

Fig. 4.7. Program Status Registers—APSR, IPSR, EPSR, and xPSR.

MRS r0, PSR; Read the combined programme condition word

MSR PSR, r0; Write combined plan land word

You can as well access each PSR individually. For example:

MRS r0, APSR; Read flag states into register r0

MRS r0, IPSR; Read exception/interrupt states into register r0

MSR APSR, r0; Write flag state

Tabular array four.2 shows the annals symbols available for accessing xPSR.

Table 4.2. Valid symbols of xPSR for programming.

Symbol Description
APSR Awarding PSR only
EPSR Execution PSR merely
IPSR Interrupt PSR only
IAPSR Combination of APSR and IPSR
EAPSR Combination of APSR and EPSR
IEPSR Combination of IPSR and EPSR
PSR Combination of APSR, IPSR, and EPSR

Delight note, there are some restrictions:

The EPSR cannot be accessed by software code directly past using the MRS (it is read as zip) or the MSR. Only it is visible during exception sequences (when xPSR is saved and restored into the stack), and is visible from debug tools.

The IPSR is read-just and cannot be changed using a MSR educational activity.

Tabular array 4.3 below lists the definitions of the bit fields in the PSRs.

Table 4.iii. Bit fields in the Plan Condition Registers.

Scrap Clarification
Due north Negative flag
Z Zilch flag
C Conduct (or NOT borrow) flag
5 Overflow flag
Q Sticky saturation flag (Available in Armv8-M Mainline and Arvmv7-K. Not available in Armv8-M Baseline and Armv6-G)
GE[three:0] Greater-Than or Equal flags for each byte lane (bachelor in Armv8-M Mainline and Arvmv7-M when the DSP extension is implemented). This is updated by a range of instructions in the DSP extension and can exist utilized past the SEL (select) instruction.
ICI/IT Interrupt-Continuable Instruction (ICI) bits and IF-And then teaching status flake for provisional execution (Available in Armv8-M Mainline and Armv7-G. Not available in Armv8-1000 Baseline and Armv6-M)
T Thumb state, ever 1 for normal operations. Attempts to clear this bit will cause a fault exception.
Exception Number Indicates which exception/interrupt service the processor is treatment.

Note: If TrustZone is implemented and if a Secure exception handlers calls a Non-secure part, the value of IPSR is set to ane during the office phone call to mask the identity of the Secure exception service.

Compared to the Armv6-M architecture, Armv8-G expanded the width of the exception number field in the Program Status Register to 9 bits. This enables the Armv8-M processor to support more than interrupts: The Cortex-M23 processor supports up to 240 interrupts compared to 32 interrupts in the Cortex-M0 and Cortex-M0+ processors (the exception number field is five-bit wide in these processors).

The other fields in the xPSR are the same equally those in the Armv6-Thousand or Armv7-M architectures. As in the past, some of the fleck fields are non bachelor in Armv8-M Baseline (i.due east., the Cortex-M23 processor).

Fig. 4.8 shows the PSR chip fields in various Arm architectures. Please note, PSRs in Cortex-M processors are different from classic processors similar the Arm7TDMI™. For example, classic Arm processors have Mode (Thou) bits, and the T bit is in bit five rather than flake 24. In addition, the interrupt masking bits (I and F) in archetype Arm processors is separated into new interrupt masking registers (e.g., PRIMASK, FAULTMASK).

Fig. 4.8

Fig. iv.viii. Comparison of Program Status Registers in different Arm architectures.

Detailed beliefs of the APSR is covered in Section 4.two.3.

The ICI/IT bits are available in Armv7-M and Armv8-M Mainline and serves 2 purposes:

During the execution of an IT (IF-THEN) instruction block, these bits (It) hold the conditional execution data.

During the execution of a multiple load/store teaching, these bits (ICI) concord the current progress condition of the teaching.

The ICI/Information technology bit fields overlap as most of the case program codes practice non use the two features at the aforementioned time. When an exception occurs, the ICI/IT state is saved as function of the automatic stacking operation(meet Section viii.4.3—the ICI/It bits are inside the stacked xPSR). After the interrupt is served, the execution of the interrupted code is resumed using the restored ICI/IT bits.

More than information on ICI/It bits is covered in Department 9.6.2.

Read full chapter

URL:

https://www.sciencedirect.com/scientific discipline/article/pii/B9780128207352000044

Cortex-G Compages

Trevor Martin , in The Designer'southward Guide to the Cortex-Thousand Processor Family (2d Edition), 2016

Plan Condition Register

The PSR equally its name implies contains all the CPU status flags (Fig. iii.iii).

Figure 3.3. The Program Status Register contains several groups of CPU flags. These include the condition codes (NZCVQ), Interrupt Continuable Educational activity (ICI) status bits, If So flag, and current exception number.

The PSR has a number of allonym fields that are masked versions of the total register. The three alias registers are the Application PSR, Interrupt PSR, and the Execution PSR. Each of these allonym registers contains a subset of the total register flags and can exist used equally a shortcut if yous need to access part of the PSR. The PSR is by and large referred to as the xPSR to betoken the full register rather than any of the allonym subsets (Fig. iii.4).

Figure three.4. The Program Status Register has 3 alias registers which provide access to specific subregions or the Plan Status Annals. Hence, the generic name for the plan status register is xPSR.

In a normal application program, your code will non make explicit admission to the xPSR or any of its allonym registers. Whatever utilize of the xPSR will be fabricated by compiler generated code. Equally a programmer you need to have an awareness of the xPSR and the flags contained in it.

The most significant four bits of the xPSR are the condition code bits, Negative, Zero, Carry, and oVerflow. These will be ready and cleared depending on the results of a information processing instruction. The result of Thumb-ii data processing instructions can set or articulate these flags. Nonetheless, updating these flags is optional.

SUB       R8, R6, #240 Perform a subtraction and practise not update the status code flags

SUBS R8, R6, #240 Perform a subtraction and update the status lawmaking flags

This allows the compiler to perform an instruction that updates the condition lawmaking flags, and so perform some boosted instructions that do not modify the flags, and so perform a conditional branch on the state of the xPSR status codes. Following the 4 condition lawmaking flags is a farther instruction flag the Q fleck.

Read total chapter

URL:

https://www.sciencedirect.com/science/article/pii/B9780081006290000037

Architecture

Joseph Yiu , in The Definitive Guide to ARM® CORTEX®-M3 and CORTEX®-M4 Processors (Tertiary Edition), 2014

4.iii Behavior of the application plan status register (APSR)

The APSR contains several groups of status flags:

Condition flags for integer operations (N-Z-C-5 bits)

Condition flags for saturation arithmetics (Q bit)

Status flags for SIMD operations (GE bits)

4.3.1 Integer status flags

The integer status flags are very similar to ALU status flags in many other processor architectures. These flags are afflicted past general data processing instructions, and are essential for decision-making conditional branches and provisional executions. In improver, one of the APSR flags, the C (Carry) bit, can also be used in add and subtract operations.

There are four integer flags in the Cortex®-One thousand processors, shown in Table 4.6. A few examples of the ALU flag results are shown in Tabular array 4.vii.

Table 4.half dozen. ALU Flags on the Cortex-1000 Processors

Flag Descriptions
N (flake 31) Set to bit[31] of the outcome of the executed instruction. When it is "i," the event has a negative value (when interpreted equally a signed integer). When information technology is "0," the result has a positive value or equal zero.
Z (bit 30) Set to "1" if the result of the executed instruction is naught. It can also exist set to "i" after a compare instruction is executed if the 2 values are the same.
C (fleck 29) Acquit flag of the result. For unsigned improver, this scrap is set to "ane" if an unsigned overflow occurred. For unsigned subtract operations, this bit is the inverse of the infringe output status. This bit is also updated by shift and rotate operations.
V (scrap 28) Overflow of the result. For signed improver or subtraction, this bit is set to "1" if a signed overflow occurred.

Table 4.vii. ALU Flags Example

Operation Results, Flags
0x70000000 + 0x70000000 Result = 0xE0000000, N= 1, Z=0, C = 0, V = ane
0x90000000 + 0x90000000 Result = 0x20000000, Due north= 0, Z=0, C = 1, V = 1
0x80000000 + 0x80000000 Result = 0x00000000, N= 0, Z=1, C = ane, V = one
0x00001234 − 0x00001000 Result = 0x00000234, N= 0, Z=0, C = 1, V = 0
0x00000004 − 0x00000005 Result = 0xFFFFFFFF, N= 1, Z=0, C = 0, V = 0
0xFFFFFFFF − 0xFFFFFFFC Result = 0x00000003, N= 0, Z=0, C = ane, V = 0
0x80000005 − 0x80000004 Consequence = 0x00000001, Northward= 0, Z=0, C = i, V = 0
0x70000000 − 0xF0000000 Event = 0x80000000, Due north= one, Z=0, C = 0, V = i
0xA0000000 − 0xA0000000 Result = 0x00000000, North= 0, Z=1, C = 1, V = 0

In the ARMv7-M and ARMv7E-One thousand architecture, most of the sixteen-chip instructions affect these four ALU flags. In most of the 32-scrap instructions one of the bits in the teaching encoding defines if the APSR flags should exist updated or not. Note that some of these instructions do not update the V flag or the C flag. For example, the MULS (multiply) education only changes the N flag and the Z flag.

In addition to provisional branch or conditional execution lawmaking, the Carry bit of APSR can also exist used to extend add and subtract operations to over 32 $.25. For example, when adding two 64-bit integers together, nosotros tin can use the carry bit from the lower 32-bit add operation as an extra input for the upper 32-flake add together operation:

// Computing Z = X + Y, where 10, Y and Z are all 64-flake

Z[31:0] = 10[31:0] + Y[31:0];   // Calculate lower word add-on,   // behave flag become updated

Z[63:32] = X[63:32] + Y[63:32] + Carry;   // Calculate upper   // word addition

The N-Z-C-V flags are available in all ARM® processors including the Cortex-M0 processor.

four.iii.two Q condition flag

The Q is used to bespeak an occurrence of saturation during saturation arithmetic operations or saturation adjustment operations. It is available in ARMv7-M (e.g., Cortex®-M3 and Cortex-M4 processors), but non ARMv6-M (e.g., Cortex-M0 processor). Afterward this flake is set, it remains set up until a software write to the APSR clears the Q bit. Saturation arithmetics/adjustment operations do not clear this fleck. Equally a result, you can use this scrap to make up one's mind if saturation occurred at the end of a sequence of Saturation arithmetics/adjustment operations, without the need to bank check the saturation status during each step.

Saturation arithmetic is useful for digital signal processing. In some cases, the destination register used to agree a calculation consequence might not have sufficient fleck width and as a result, overflow or underflow occurs. If normal data arithmetic instructions are used, the MSB of the result would be lost and tin cause a serious baloney in the output. Instead of just cutting off the MSB, saturation arithmetics forces the result to the maximum value (in case of overflow) or minimum value (in case of underflow) to reduce the touch of signal distortion (figure 4.16).

FIGURE 4.16. Signed saturation and unsigned saturation

The bodily maximum and minimum values that trigger the saturation depend on the instructions being used. In about cases, the instructions for saturation arithmetic are mnemonic starting with "Q," for instance "QADD16". If saturation occurred, the Q chip is set up for the following instructions - QADD, QDADD, QSUB, QDSUB, SSAT, SSAT16, USAT, USAT16; otherwise, the value of the Q bit is unchanged.

The Cortex-M3 processor provides a couple of saturation adjustment instructions, and the Cortex-M4 provides a full set of saturation arithmetic instructions, as well as those saturation adjustment instructions available in the Cotex-M3 processor.

4.3.iii GE bits

The "Greater-Equal" (GE) is a 4-bit wide field in the APSR in the Cortex®-M4, and is not available in the Cortex-M3 processor. It is updated by a number of SIMD instructions where, in most cases, each fleck represents positive or overflow of SIMD operations for each byte (Tabular array 4.viii). For SIMD instructions with sixteen-chip information, bit 0 and bit ane are controlled by the upshot of lower half-word, and flake 2 and bit 3 are controlled by the result of upper half-word.

Table iv.eight. GE Flags Results

SIMD Operation Results
SADD16, SSUB16, USUB16, SASX, SSAX If lower half-word upshot &gt;= 0 then GE[ane:0] = 2'b11 else GE[1:0] = ii'b00
If upper half-give-and-take effect &gt;= 0 then GE[three:2] = 2'b11 else GE[three:2] = 2'b00
UADD16 If lower half-word result &gt;= 0x10000 then GE[one:0] = 2'b11 else GE[ane:0] = ii'b00
If upper half-word result &gt;= 0x10000 then GE[3:2] = 2'b11 else GE[iii:two] = 2'b00
SADD8, SSUB8, USUB8 If byte 0 consequence &gt;= 0 and so GE[0] = one'b1 else GE[0] = i'b0
If byte i issue &gt;= 0 and so GE[1] = 1'b1 else GE[i] = ane'b0
If byte two result &gt;= 0 then GE[2] = 1'b1 else GE[2] = 1'b0
If byte 3 event &gt;= 0 then GE[3] = 1'b1 else GE[3] = 1'b0
UADD8 If byte 0 result &gt;= 0x100 then GE[0] = 1'b1 else GE[0] = 1'b0
If byte 1 event &gt;= 0x100 then GE[1] = 1'b1 else GE[1] = 1'b0
If byte 2 consequence &gt;= 0x100 then GE[2] = i'b1 else GE[2] = ane'b0
If byte iii result &gt;=0x100 and then GE[3] = 1'b1 else GE[3] = 1'b0
UASX If lower half-discussion result &gt;= 0 and so GE[ane:0] = 2'b11 else GE[ane:0] = two'b00
If upper half-word result &gt;= 0x10000 then GE[iii:2] = 2'b11 else GE[three:two] = 2'b00
USAX If lower half-give-and-take result &gt;= 0x10000 then GE[1:0] = 2'b11 else GE[ane:0] = 2'b00
If upper half-discussion outcome &gt;= 0x0 and so GE[3:2] = 2'b11 else GE[3:2] = 2'b00

The GE flags are used by the SEL instruction(Effigy 4.17), which multiplexes the byte values from two source registers based on each GE bit. When combining SIMD instructions with the SEL instruction, simple conditional data option can be created in SIMD arrangement for ameliorate performance.

Figure 4.17. SEL operation

Y'all can also read back the GE bits by reading APSR into a general purpose annals for additional processing. More details of the SIMD and SEL instructions are given in Chapter v.

Read total chapter

URL:

https://www.sciencedirect.com/science/article/pii/B978012408082900004X

Floating Point Operations

Joseph Yiu , in The Definitive Guide to ARM® CORTEX®-M3 and CORTEX®-M4 Processors (Tertiary Edition), 2014

13.ii.5 Floating point status and command register (FPSCR)

The FPSCR holds the arithmetic outcome flags and mucilaginous status flags, as well as bit fields to control the behavior of the floating point unit (Figure thirteen.14 and Table thirteen.four). The N, Z, C, and V flags are updated past floating point comparing operations, as shown in Table thirteen.5.

Tabular array xiii.iv. Bit Fields in FPSCR

Bit Clarification
North Negative flag (update by floating point comparison operations)
Z Goose egg flag (update by floating indicate comparison operations)
C Behave/borrow flag (update by floating point comparison operations)
Five Overflow flag (update by floating point comparison operations)
AHP Alternate half precision control bit:
0 – IEEE half-precision format (default)
1 – Culling half-precision format, see department 13.1.3
DN Default NaN (Not a Number) fashion control scrap:
0 – NaN operands propagate through to the output of a floating point operation (default)
1 – Whatever performance involving one or more NaN(s) returns the default NaN
FZ Affluent-to-cipher model command bit:
0 – Flush-to-aught manner disabled (default) (IEEE 754 standard compliant)
ane – Flush-to-null mode enabled; denormalized values (tiny values with exponent equal 0) are flushed 0
RMode Rounding Way Control field; the specified rounding mode is used by almost all floating point instructions:
00 – Round to Nearest (RN) mode (default)
01 – Round towards Plus Infinity (RP) mode
x – Round towards Minus Infinity (RM) way
11 – Round towards Nada (RZ) style
IDC Input Denormal cumulative exception bit; prepare to 1 when floating signal exception occurred, articulate past writing 0 to this chip
IXC Inexact cumulative exception bit; fix to one when floating indicate exception occurred, clear by writing 0 to this bit
UFC Underflow cumulative exception bit; set to 1 when floating signal exception occurred, articulate past writing 0 to this bit
OFC Overflow cumulative exception bit; set to one when floating betoken exception occurred, clear by writing 0 to this scrap
DZC Partition by Zero cumulative exception chip; ready to 1 when floating bespeak exception occurred, clear by writing 0 to this bit
IOC Invalid Operation cumulative exception bit; ready to ane when floating signal exception occurred, clear by writing 0 to this bit

Figure 13.14. Fleck field in FPSCR

Table xiii.5. Operation of N, Z, C, and Five Flags in FPSCR

Comparison Result N Z C V
Equal 0 1 1 0
Less than one 0 0 0
Greater than 0 0 1 0
Unordered 0 0 1 1

You can use the results of a floating point compare for conditional branch/conditional execution by copying the flags to APSR first:

  VMRS   APSR_nzcv, FPSCR   ; Copy flags from FPSCR to flags in APSR

The scrap fields AHP, DN, and FZ are control annals bits for special operation modes. By default, all these bits default to 0 and their behavior is compliant with IEEE 754 single precision operation. In normal applications at that place is no need to change the settings of the floating point performance control. Do not change these bits if your application requires IEEE 754 compliance.

The RMode flake field is for controlling the rounding mode for adding results. The IEEE 754 standard defines several rounding modes, as shown in Tabular array thirteen.6.

Table 13.half dozen. Rounding Modes Bachelor on the Cortex®-M4 FPU

Rounding Mode Descriptions
Circular to nearest Rounds to the nearest value. This is the default configuration.
IEEE 754 subdivides this mode to:
Circular to nearest, ties to even: round to the nearest value with an even (naught) LSB. This is the default for binary floating point and recommended default for decimal floating bespeak.
Circular to nearest, ties away from null: round to the nearest value above (for +ve numbers) or below (for –ve numbers). This is intended as an option for decimal floating signal.
Since the floating bespeak unit is using binary floating betoken only, the "Circular to nearest, ties abroad from zero" fashion is not bachelor.
Round toward +∞ Also known as rounding up or ceiling.
Round toward −∞ Likewise known as rounding downwardly or flooring.
Round toward 0 Also known as truncation.

The bits IDC, IXC, UFC, OFC, DZC, and IOC are gummy status flags that show whatsoever abnormalities (floating bespeak exceptions) during floating point operations. Software tin check these flags after the floating point operations, and can clear them by writing cipher to them. Department 13.v has more data on floating bespeak exceptions.

Read full chapter

URL:

https://www.sciencedirect.com/science/article/pii/B9780124080829000130

Fault Exceptions and Mistake Treatment

Joseph Yiu , in The Definitive Guide to ARM® CORTEX®-M3 and CORTEX®-M4 Processors (Third Edition), 2014

12.iv.ii Information for MemManage fault

The developer's model for the MemManage Fault Condition Register is shown in Table 12.3.

Table 12.3. MemManage Fault Status Register (everyman byte in SCB-&gt;CFSR)

Bits Name Type Reset Value Description
7 MMARVALID 0 Indicates the MMFAR is valid
half-dozen – (read every bit 0) Reserved
v MLSPERR R/Wc 0 Floating signal lazy stacking mistake (available on Cortex®-M4 with floating indicate unit only)
four MSTKERR R/Wc 0 Stacking error
3 MUNSTKERR R/Wc 0 Unstacking fault
ii – (read every bit 0) Reserved
1 DACCVIOL R/Wc 0 Data admission violation
0 IACCVIOL R/Wc 0 Didactics admission violation

Each fault indication condition bit (not including MMARVALID) is set when the fault occurs, and stays high until a value of one is written to the annals.

If the MMFSR indicates that the error is a data admission violation (DACCVIOL set to 1) or an instruction admission violation (IACCVIOL set to 1), the faulting code tin can be located by the stacked program counter in the stack frame.

If the MMARVALID bit is set up, it is also possible to make up one's mind the retentiveness location that acquired the fault past using the MemManage Fault Address Register (SCB->MMFAR).

MemManage faults which occur during stacking, unstacking, and lazy stacking (see sections 8.3.6 and 13.3) are indicated by MSTKERR, MUNSTKERR, and MLSPERR, respectively.

Read total chapter

URL:

https://world wide web.sciencedirect.com/science/article/pii/B9780124080829000129

INTRODUCTION TO THE ARM INSTRUCTION Set up

ANDREW N. SLOSS , ... CHRIS WRIGHT , in ARM System Programmer'due south Guide, 2004

3.5 PROGRAM STATUS REGISTER INSTRUCTIONS

The ARM instruction set provides 2 instructions to directly control a program status register ( psr). The MRS education transfers the contents of either the cpsr or spsr into a annals; in the contrary direction, the MSR instruction transfers the contents of a register into the cpsr or spsr. Together these instructions are used to read and write the cpsr and spsr.

In the syntax you tin see a label chosen fields. This can be any combination of control (c), extension (x), status (s), and flags (f). These fields relate to item byte regions in a psr, as shown in Figure three.9.

Figure 3.9. psr byte fields.

MRS copy program condition register to a general-purpose register Rd = psr
MSR motility a general-purpose register to a program status register psr[field] = Rm
MSR move an immediate value to a programme status register psr[field] = immediate

The c field controls the interrupt masks, Thumb land, and processor way. Example 3.26 shows how to enable IRQ interrupts past clearing the I mask. This operation involves using both the MRS and MSR instructions to read from and then write to the cpsr.

EXAMPLE iii.26

The MSR start copies the cpsr into register r1. The BIC didactics clears flake vii of r1. Register r1 is then copied back into the cpsr, which enables IRQ interrupts. Y'all can see from this instance that this lawmaking preserves all the other settings in the cpsr and simply modifies the I bit in the control field.

This example is in SVC fashion. In user way you tin read all cpsr bits, but you lot can only update the condition flag field f.

3.5.i COPROCESSOR INSTRUCTIONS

Coprocessor instructions are used to extend the instruction set. A coprocessor can either provide boosted computation adequacy or exist used to control the memory subsystem including caches and memory direction. The coprocessor instructions include data processing, register transfer, and retention transfer instructions. We will provide only a short overview since these instructions are coprocessor specific. Note that these instructions are only used by cores with a coprocessor.

CDP coprocessor data processing—perform an operation in a coprocessor
MRC MCR coprocessor register transfer—move data to/from coprocessor registers
LDC STC coprocessor retention transfer—load and store blocks of memory to/from a coprocessor

In the syntax of the coprocessor instructions, the cp field represents the coprocessor number between p0 and p15. The opcode fields draw the operation to take place on the coprocessor. The Cn, Cm, and Cd fields describe registers within the coprocessor. The coprocessor operations and registers depend on the specific coprocessor you lot are using. Coprocessor 15 (CP15) is reserved for system control purposes, such equally retention management, write buffer control, cache command, and identification registers.

Instance 3.27

This case shows a CP15 annals being copied into a general-purpose annals.

Here CP15 register-0 contains the processor identification number. This register is copied into the general-purpose annals r10.

3.5.2 COPROCESSOR 15 Didactics SYNTAX

CP15 configures the processor core and has a set of dedicated registers to store configuration information, as shown in Example 3.27. A value written into a annals sets a configuration attribute—for example, switching on the cache.

CP15 is called the organization control coprocessor. Both MRC and MCR instructions are used to read and write to CP15, where annals Rd is the core destination register, Cn is the principal register, Cm is the secondary register, and opcode2 is a secondary register modifier. You may occasionally hear secondary registers called "extended registers."

As an example, here is the instruction to motion the contents of CP15 control register c1 into register r1 of the processor core:

We use a autograph annotation for CP15 reference that makes referring to configuration registers easier to follow. The reference notation uses the following format:

The commencement term, CP15, defines it every bit coprocessor 15. The second term, later the separating colon, is the primary register. The master register X can have a value betwixt 0 and xv. The third term is the secondary or extended register. The secondary register Y can have a value between 0 and xv. The concluding term, opcode2, is an instruction modifier and can have a value between 0 and 7. Some operations may also utilize a nonzero value w of opcode1. Nosotros write these every bit CP15:w:cX:cY:Z.

Read total affiliate

URL:

https://www.sciencedirect.com/science/article/pii/B9781558608740500046

Avant-garde PIC18 Projects

Dogan Ibrahim , in Picture Microcontroller Projects in C (2d Edition), 2014

SSPxSTAT

This is the status register with the lower vi bits read but and the upper two bits read/write. Effigy 7.44 shows the bit definitions of this register. Only bits 0, 6, and 7 are related to operation in the SPI fashion. Bit 7 (SMP) allows the user to select the input data sample time. When SMP   =   0, input data are sampled at the middle of data output time, and when SMP   =   1, the sampling is done at the end. Bit 6 (CKE) allows the user to select the transmit clock edge. When CKE   =   0, transmit occurs on transition from the idle to active clock state, and when CKE   =   one, transmit occurs on transition from the agile to the idle clock state. Bit 0 (BF) is the buffer full status bit. When BF   =   1, receive is complete (i.due east. SSPxBUF is full), and when BF   =   0, receive is not complete (i.e. SSPxBUF is empty).

Effigy seven.44. SSPxSTAT Register Bit Configuration. Only the Bits when Operating in the SPI Master Way are Described.

Read full affiliate

URL:

https://www.sciencedirect.com/science/article/pii/B9780080999241000071