question archive Explain how data testing instructions work in CCR
Subject:Computer SciencePrice:3.86 Bought12
Explain how data testing instructions work in CCR.
C
The data test instructions include Bit Test and Compare.
e.g.:
CMP.L D0,D1 evaluates [D1(0:31)] - [D0(0:31)] CMP.B TEMP1,D3 evaluates [D3(0:7)] - [(TEMP1)] CMP.L TEMP1,D3 evaluates [D3(0:31)] - [(TEMP1)] CMP.W (A3),D2 evaluates [D2(0:15)] - [M([A3))]
This instruction will test the bit number in the destination operand decided by the source operand. The result is saved to the Z flag.
BTST: Bit TeST tests a bit of an operand. If the test bit is zero, the Z-bit of the CCR is set, else the Z-bit is cleared. A bit test does not affect the value of the operand under test in any way. The location of the bit to be tested is specified by a constant, or as the contents of a data register. For example, BTST #3,(A0) tests bit 3 of the byte in memory pointed at by A0. BTST D0,(A0) tests the bit in the byte pointed at by A0 whose bit-number is in D0.
TST D3 has a similar effect to CMP #0,D3.