FF Instructions

Purpose:To locate the first bit in a bit field
Format:opcode startpos.rl, size.rb, base.vb, findpos.wl
Operation:
{extract field};
{search for bit set or clear from bit 0 to bit (size - 1)};
if { found }
findpos <- {startpos + bit position};
Z <- 0;
else
findpos <- startpos + size;
Z <- 1;
Condition
Codes:
N <- 0;
Z <- bit not found;
V <- 0;
C <- 0;
Exceptions: Reserved Operand
Opcodes:
EBFFCFind First Clear
EAFFSFind First Set
Description: A field specified by the start position, size and base operands is extracted. The field is tested for a bit in the state indicated by the instruction starting at bit 0 and extending to the highest bit in the field. If a bit in the indicated state is found, the find position operand is replaced by the position of the bit and the Z condition code is cleared.

If a bit in the indicated state is not found, the find position operand is replaced by the position (relative to the base) of the bit one bit higher than the highest bit in the field and the Z condition code is set.

If the size operand is zero, the find position operand is set to the start position operand and the Z condition code is set.

Notes:
1.
If the start position + size is GEQU 2**31, then find position might be set to a negative value that would not be usable in a subsequent field or BBxx instruction.
2.
A reserved operand fault occurs if the unsigned size operand is greater than 32 or the bit field is contained in a register and the position operand is outside the range 0 - 31.
3.
On a reserved operand fault, the destination is unaffected and the condition codes are unpredictable.
4.
If the base address is a register, the bit field may extend into the next register.
5.
The startpos operand may be negative.