This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:papc:chapter_6_7 [2025/10/22 06:24] – [Random Number Generator Instructions] ktokarz | en:multiasm:papc:chapter_6_7 [2025/10/23 12:56] (current) – [BMI1 and BMI2 Instructions] ktokarz | ||
|---|---|---|---|
| Line 283: | Line 283: | ||
| The **set// | The **set// | ||
| + | |||
| + | The **popcnt** instruction counts the number of bits equal to " | ||
| + | |||
| + | The **crc32** instruction implements the calculation of the cyclic redundancy check in hardware. The polynomial of the value 11EDC6F41h is fixed. | ||
| + | |||
| ===== Control transfer instructions ===== | ===== Control transfer instructions ===== | ||
| Before describing the instructions used for control transfer, we will discuss how the destination address can be calculated. The destination address is the address given to the processor to make a jump to. | Before describing the instructions used for control transfer, we will discuss how the destination address can be calculated. The destination address is the address given to the processor to make a jump to. | ||
| Line 524: | Line 529: | ||
| ===== BMI1 and BMI2 Instructions ===== | ===== BMI1 and BMI2 Instructions ===== | ||
| - | Bit Manipulation Instructions | + | The abbreviation BMI comes from Bit Manipulation Instructions. These instructions are designed for some specific manipulation of bits in the arguments, enabling programmers to use a single instruction instead of a few. |
| - | ANDN Bitwise | + | The **andn** instruction extends the group of logical instructions. It performs a bitwise |
| - | BEXTR Contiguous bitwise | + | There are additional shift and rotate instructions that do not affect flags, which allows for more predictable execution without dependency on flag changes from previous operations. |
| - | BLSI Extract | + | . These instructions are **rorx** - rotate right, **sarx** - shift arithmetic right, **shlx** - shift logic left, and **shrx** - shift logic right. |
| - | BLSMSK Set all lower bits below first set bit to 1. | + | Also, unsigned multiplication without affecting flags, **mulx**, was introduced. |
| - | BLSR Reset lowest set bit. | + | Other instructions manipulate bits as the group name stays. |
| - | BZHI Zero high bits starting from specified bit position. | + | |
| - | LZCNT Count the number leading zero bits. | + | The **lzcnt** instruction counts the number of zeros in an argument starting from the most significant bit. The **tzcnt** counts zeros starting from the least significant bit. For an argument that is not zero, **lzcnt** returns the number of zeros before the first 1 from the left, and **tzcnt** gives the number of zeros before the first 1 from the right. |
| - | MULX Unsigned multiply without affecting arithmetic flags. | + | The **bextr** instruction copies the number of bits from source to destination arguments starting at the chosen position. The third argument specifies the number of bits and the starting bit position. Bits 7:0 of the third operand specify the starting bit position, while bits 15:8 specify the maximum number of bits to extract, as shown in figure {{ref> |
| - | PDEP Parallel | + | |
| - | PEXT Parallel | + | <figure bextr_instr> |
| - | RORX Rotate right without affecting arithmetic flags. | + | {{ : |
| - | SARX Shift arithmetic right. | + | < |
| - | SHLX Shift logic left. | + | </ |
| - | SHRX Shift logic right. | + | |
| - | TZCNT Count the number trailing zero bits. | + | The **blsi** instruction extracts the single, |
| + | |||
| + | <figure blsi_instr> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | The **blsmsk** instruction sets all lower bits below a first bit set to 1. It is shown in figure {{ref> | ||
| + | |||
| + | <figure blsmsk_instr> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | The **blsr** instruction resets (clears the bit to zero value) the lowest set bit. It is shown in figure {{ref> | ||
| + | |||
| + | <figure blsr_instr> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | The **bzhi** instruction resets | ||
| + | |||
| + | <figure bzhi_instr> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | The **pdep** instruction performs a parallel | ||
| + | |||
| + | <figure pdep_instr> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | The **pext** instruction performs a parallel | ||
| + | |||
| + | <figure pext_instr> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||