tst
Test
Sets the condition codes from the operand, as if comparing it with zero.
Sizes .b .w .l, .w by default
Used in
- The condition code registerM68K assembly
- Compare and branchM68K assembly
- Loops and dbraM68K assembly
- Arithmetic, logic and bitsM68K assembly
- Arrays, strings and (a0)+M68K assembly
- Length of a stringM68K assembly
- Reverse a string in placeM68K assembly
- A subroutine with its arguments in registersM68K assembly
- Move a square with the keyboardM68K assembly
- The snake gameM68K assembly
XNZVC –●●00
- ● depends on the result
- 0 always 0
- – not changed
Forms
68020 only
These forms require the 68020. Select opt p=68020 before any code or data.
Operands
<ea>- An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With
opt p=68020, an allowedd(An,Xn)ord(PC,Xn)mode also permits the corresponding 68020 indexed and memory indirect forms. See 68020 addressing. More #imm- An immediate value written after
#: a number, character or label, such as#10,#$FFor#'a'. It must fit the operation’s size: byte-128to255, word-32768to65535, or long-2147483648to4294967295; signed and unsigned spellings are accepted. More
The operand and X are unchanged.
On the 68020, tst also accepts an address register at word or long size, an immediate value, or PC-relative memory such as tst.w count(pc).
* --- Testing different values ---
move.l #$80, d0
tst.b d0 ; N flag set (bit 7 = 1)
move.l #$00, d1
tst.b d1 ; Z flag set
move.l #$7F, d2
tst.b d2 ; no flags (positive, nonzero)