15
15 – 29
ALU
TEST BIT, SET BIT, CLEAR BIT, TOGGLE BIT
(ADSP-217x, ADSP-218x, ADSP-21msp58/59 only)
Syntax: [ IF cond ] AR = TSTBIT n OF xop ;
AF SETBIT n OF xop
CLRBIT n OF xop
TGLBIT n OF xop
Permissible xops Permissible conds (see Table 15.9)
AX0 MR2 EQ LE AC
AX1 MR1 NE NEG NOT AC
AR MR0 GT POS MV
SR1 GE AV NOT MV
SR0 LT NOT AV NOT CE
Permissible n values (0=LSB)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Examples: AF=TSTBIT 5 OF AR;
AR=TGLBIT 13 OF AX0;
Description: Test the optional condition and if true, then perform the
specified bit operation. If the condition is not true then perform a no-
operation. Omitting the condition performs the operation unconditionally.
These operations cannot be used in multifunction instructions.
These operations are defined as follows:
TSTBIT is an AND operation with a 1 in the selected bit
SETBIT is an OR operation with a 1 in the selected bit
CLRBIT is an AND operation with a 0 in the selected bit
TGLBIT is an XOR operation with a 1 in the selected bit
The ASTAT status bits are affected by these instructions. The following
instructions could be used, for example, to test a bit and branch accordingly:
AF=TSTBIT 5 OF AR;
IF NE JUMP set; /*Jump to "set" if bit 5 of AR is
set*/
Status Generated:
ASTAT: 7 6 543210
SS MV AQ AS AC AV AN AZ
–– – – 0 0* *
(instruction continues on next page)