[Solved] How to calculate parity of a 32bits number in assembly?


Many ways to do this, of course. If you decide to use the hardware parity flag, keep in mind that it only checks the low 8 bits. A solution using this approach might be to process your 32 bit input as four 8 bit values, and use XOR on the partial results:

p(31:0) = p(31:24) ^ p(23:16) ^ p(15:8) ^ p(7:0)

To get the 8 bit units, you can use SHR and to get the partial values you can XOR, use the SETP. This should be enough to get you started.

Another, possibly more efficient, option is to XOR the bytes and grab the parity of them:

p(31:0) = p(31:24 ^ 23:16 ^ 15:8 ^ 7:0)

7

solved How to calculate parity of a 32bits number in assembly?