![Freescale Semiconductor KKL02Z32CAF4R Reference Manual Download Page 210](http://html1.mh-extra.com/html/freescale-semiconductor/kkl02z32caf4r/kkl02z32caf4r_reference-manual_2330635210.webp)
16.4.2.3 Decorated load unsigned bit field extract (UBFX)
This command extracts a bit field defined by LSB position (b) and the bit field width (w
+1) from the memory "container" defined by the access size associated with the load
instruction using a two-cycle read sequence.
The extracted bit field from the memory address is right-justified and zero-filled in the
operand returned to the core. Recall this is the only decorated operation that does not
perform a memory write, that is, UBFX only performs a read.
The data size is specified by the write operation and can be byte (8-bit), halfword (16-bit)
or word (32-bit). Note for the word sized operation, the maximum bit field width is 16
bits.
The use of a UBFX operation is recommended to extract a single bit from a peripheral.
For this case, the w field is simply set to 0, indicating a bit field width of 1.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10
9
8
7
6
5
4
3
2
1
0
ioubfxb
0 1 0 1
-
-
b b b
- w w w
mem_addr
ioubfxh
0 1 0 1
-
b b b b w w w w
mem_addr
0
ioubfxw
0 1 0 1 b b b b b w w w w
mem_addr
0 0
Figure 16-11. Decorated load address: unsigned bit field extract
See
, where addr[28] = 1 specifies the unsigned bit field extract operation,
addr[27:23] is "b", the LSB identifier, addr[22:19] is "w", the bit field width minus 1
identifier, and mem_addr[18:0] specifies the address offset into the peripheral space
based at 0x4000_0000. The "-" indicates an address bit "don't care". Note, unlike the
other decorated load operations, UBFX uses addr[19] as the least significant bit in the
"w" specifier and not as an address bit.
The decorated unsigned bit field extract read operation is defined in the following
pseudo-code as:
rdata = ioubfx<sz>(accessAddress) // unsigned bit field extract
tmp = mem[accessAddress & 0xE007FFFF, size] // memory read
mask = ((1 << (w+1)) - 1) << b // generate bit mask
rdata = (tmp & mask) >> b // read data returned to core
Like the BFI operation, when the starting bit position plus the field width exceeds the
container size, only part of the source bit field is extracted from the destination memory
location. Stated differently, if (b + w+1) > container_width, only the low-order
"container_width - b" bits are actually extracted. The cycle-by-cycle BME operations are
detailed in the following table.
Functional description
KL02 Sub-Family Reference Manual, Rev. 2.1, July 2013
210
Freescale Semiconductor, Inc.