Domanda

In the wiki.

test arg1, arg2

I can see flags are changed based on these:

  1. SF <- MostSignificantBit(Temp)
  2. If Temp == 0 ZF <- 1 else ZF <- 0
  3. PF <- BitWiseXorNor(Temp[Max-1:0])
  4. CF <- 0
  5. OF <- 0

AF is undefined

So my question is :

What is BitWiseXorNor? and what is Max?

È stato utile?

Soluzione

PF is a parity flag that signifies bit parity in the low byte. So if the resulting number of bits is even, it's set. If the number of bits are odd, it's not set.

The wiki text is a bit confusing, but what the BitWiseXorNor function logically looks like is...

bool bwxnor(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7) {

    return ~(((((((b0 ^ b1) ^ b2) ^ b3) ^ b4) ^ b5) ^ b6) ^ b7)
}

Another way to think of PF is 1 - (sum(temp[0:7]) % 2).

Altri suggerimenti

BitWiseXorNor, one presumes, means - XOR together all bits of the argument, then invert. Max means the largest bit position. 7 for a byte, 15 for a word, 31 for dword, etc. So Temp[Max-1:0] means all bits of Temp except for the leftmost one.

XORring together all bits in a bit string produces 1 if there's an odd number of 1 bits in the input, 0 if even. This is the inverse of the value that the parity flag (PF) should receive. Inverting the result of the XOR operation gives you the valud of PF.

I could be wrong about Max. Maybe it means the bit count - 8 for byte, 16 for word, etc. I could deduce that from the datatype of Temp.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top