0% found this document useful (0 votes)
167 views

Function of Condition Codes

Condition codes are used to store the results of arithmetic operations for later reference. There are four main condition codes: N indicates a negative result, Z indicates a zero result, V indicates an overflow, and C indicates a carry-out. Condition codes reduce the need for compare and test instructions, simplify conditional branches, enable multiway branches, and can be saved during subroutine calls along with registers. However, condition codes also increase complexity for both hardware and software, are irregular and require extra hardware, and require special synchronization in pipelined implementations.

Uploaded by

Tien Dung Hoang
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
167 views

Function of Condition Codes

Condition codes are used to store the results of arithmetic operations for later reference. There are four main condition codes: N indicates a negative result, Z indicates a zero result, V indicates an overflow, and C indicates a carry-out. Condition codes reduce the need for compare and test instructions, simplify conditional branches, enable multiway branches, and can be saved during subroutine calls along with registers. However, condition codes also increase complexity for both hardware and software, are irregular and require extra hardware, and require special synchronization in pipelined implementations.

Uploaded by

Tien Dung Hoang
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Function of Condition codes:

It is used to keep information regarding the results of arithmetic operations, so


we can look at them later. There are four condition codes:

 N: was the result negative?


 Z: was the result zero?
 V: was there an overflow (added two positive numbers and got negative, or
vice versa)?
 C: was there a carry-out?

For example, an arithmetic operation may produce a positive,


negative, zero, or overflow result. In addition to the result itself being
stored in a register or memory, a condition code is also set. The code
may subsequently be tested as part of a conditional branch operation.

Addvantages of condition codes:

1. Because condition codes are set by normal arithmetic and data


movement instructions, they should reduce the number of COMPARE
and TEST instructions needed.

2. Conditional instructions, such as BRANCH are simplified relative to


composite instructions, such as TEST AND BRANCH

3. Condition codes facilitate multiway branches. For example, a TEST


instruction can be followed by two branches, one on less than or equal
to zero and one on greater than zero,

4. Condition codes can be saved on the stack during subroutine calls


along with other register information.

Disadvantages of condition codes:

1. Condition codes add complexity, both to the hardware and software.


Condition code bits are often modified in different ways by different
instructions, making life more difficult for both the microprogrammer
and compiler writer.

2. Condition codes are irregular; they are typically not part of the main
data path, so they require extra hardware connections.
3. Often condition code machines must add special non-condition-code
instructions for special situa- tions anyway, such as bit checking, loop
control, and atomic semaphore operations.

4. In a pipelined implementation, condition codes require special


synchronization to avoid conflicts.

You might also like