bits [action] value first last [-size]
Perform bit manipulation on value and return the result.
The manipulation done depends on action. In all cases, a bit range is specified using 0-based (little endian) bit numbers first and last. If the -size flag is given, last is instead interpreted as the number of bits in the range.
- extract (default) - mask out and shift down the range.
- keep - mask out the range (like extract bit without shift).
- clear - set the range to 0.
- set - set the range to 1.
- remove - remove the range (and shift down the bits above it).
Some examples:
- Extract bits 1 to 2
bits 0b11101 1 2
The bit numbers can in fact be given in opposite order as well:
bits 0b11101 2 1
- Mask out bits 1 to 2
bits "keep" 0b11101 1 2
- Remove 2 bits from bit 2
bits "remove" 0b10111 2 2 -size
Simics Core