Hardware Reference
In-Depth Information
new address. Long-branch instructions are used when large displacements between decision-
making steps are necessary.
The numeric range of long-branch offset values is $8000 (232,768) to $7FFF (32,767) from
the instruction immediately after the branch instruction. This permits branching from any lo-
cation in the standard 64-kB address map to any other location in the map. A summary of the
long-branch instructions is in Table 2.2.
Although there are many possibilities in writing a program loop, the following one is a
common format:
loop: .
.
.
Bcc (or LBcc) loop
where cc is one of the condition codes (CC, CS, EQ, MI, NE, PL, VC, VS, HI, HS, LO, LS, GE,
GT, LS, and LT). Usually, there will be a comparison or arithmetic instruction to set up the con-
dition code for use by the conditional branch instruction. Unsigned branch instructions treat
the numbers compared previously as nonnegative numbers. Signed branch instructions treat
the numbers compared previously as signed numbers.
2.6.3 Compare and Test Instructions
The HCS12 has a set of compare instructions that are dedicated to the setting of condition
flags. The compare and test instructions perform subtraction between a pair of registers or be-
tween a register and a memory location. The result is not stored, but condition codes are set by
the operation. In the HCS12, most instructions update condition code flags automatically, so it
is often unnecessary to include a separate test or compare instruction. Table 2.3 is a summary
of compare and test instructions.
Compare Instructions
Mnemonic
Function
Operation
cba
cmpa <opr>
cmpb <opr>
cpd <opr>
cps <opr>
cpx <opr>
cpy <opr>
Compare A to B
Compare A to memory
Compare B to memory
Compare D to memory
Compare SP to memory
Compare X to memory
Compare Y to memory
(A) − (B)
(A) − (M)
(B) − (M)
(D) − (M:M+1)
(SP) − (M:M+1)
(X) − (M:M+1)
(Y) − (M:M+1)
Test Instructions
Mnemonic
Function
Operation
tst <opr>
tsta
tstb
Test memory for zero or minus
Test A for zero or minus
Test B for zero or minus
(M) − $00
(A) − $00
(B) − $00
Note:
<opr> represents an immediate value or a memory location and can be specified by
using the immediate, direct, extended, and indexed addressing modes.
Table 2.3 Summary of compare and test instructions
 
 
Search WWH ::




Custom Search