question archive Explain how data testing instructions work in CCR

Explain how data testing instructions work in CCR

Subject:Computer SciencePrice:3.86 Bought12

Explain how data testing instructions work in CCR.

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

C

The data test instructions include Bit Test and Compare.

  • CMP -- the Compare Instruction sets the CCR as if the first operand had been subtracted from the second. The N-, Z-, V-, and C-bits are all updated and the X-bit remains unaffected. The destination operand must be a data register and the source operand may be specified by any of the 68000's addressing modes.

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))]

 

  • BTST - TeST a Bit

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 -- the Test [against zero] Instruction reads the operand, compares it with zero, and sets the bits of the CCR accordingly. For example,
TST D3 has a similar effect to CMP #0,D3.