6.1 Conditional Test Programs

This section introduces conditional test programs.

To branch a process based on the collating sequence of values, the CMP (compare) instruction is used in combination with the conditional branch instruction. You will use different branch instructions depending on whether the values to be compared are signed or not.
The table below shows how to select branch instructions:

Table 6.1: Conditional Branch Instruction

Next, check the CMP instruction specifications in the instruction table.




The CMP instruction can compare 8-, 16- and 32-bit data. The comparison targets, however, must be general-purpose registers, or immediate and a general-purpose register. Before executing the CMP instruction, store data in a general-purpose register.



The conditional branch instruction can also be used independent of the CMP instruction. To branch using the conditional branch instruction only, the status of each flag in the CCR changed by the previous instruction determines whether to branch or not.
The table below shows the conditions for the conditional branch instruction:

Table 6.2: Conditions for Conditional Branch Instruction