bfextu
Extract bit field unsigned
Copies a bit field into a data register as an unsigned number, filling the bits above it with 0s.
Select opt p=68020, or use opt bit with the 68000 or 68010, before any code or data
- ● set from the result
- 0 always 0
- – not changed
Forms
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 {offset:width}- A field of 1 to 32 bits, written immediately after the operand. Literal offsets range from 0 to 31, and literal widths from 1 to 32. Either may be a data register, as in
{d1:d2}. See the linked section for register values, negative memory offsets and wrapping. More Dn- A data register,
d0tod7. More
The field is placed in the register’s low bits, and all higher bits are cleared. For example, bfextu d0{24:8}, d1 copies the low byte of d0 into d1. This can extract a packed value such as the 5-bit red component of a colour.
N copies the field’s highest bit, even though the extracted value is unsigned. Z is set if the field is zero. V and C are cleared, and X is unchanged. bfexts sign-extends the extracted value instead.
Write the field as {offset:width} immediately after its operand. It selects 1 to 32 bits, counted from bit 31 of a data register or bit 7 of the byte at the memory address. The offset and width may each be a constant or a data register. See bit fields for their ranges, register values and wrapping rules.
opt p=68020
* --- The red, green and blue of a 16-bit colour ---
lea color, a0
bfextu (a0){0:5}, d0 ; the first 5 bits, red: d0 = 31
bfextu (a0){5:6}, d1 ; the next 6, green: d1 = 0
bfextu (a0){11:5}, d2 ; the last 5, blue: d2 = 12
bra END
color:
dc.w %1111100000001100
END: