0

This question is about Parity Flag. I cannot figure out the difference between JP and JPE or JNP and JPO. Did it just another name for each one or it did have some differnce?

vio1etus
  • 21
  • 1
  • 6
  • @Hovercraft That question is very close, but it's asking about the sign/carry flags; the jump-if-parity varieties are never mentioned, except in a table. – Jonathon Reinhart Aug 21 '18 at 02:36

1 Answers1

4

For a given jump instruction (size), there are just two parity flag conditions it can test. As you guessed, they each have two names:

7B cb   JNP rel8  Jump short if not parity (PF=0).
7A cb   JP  rel8  Jump short if parity (PF=1).
7A cb   JPE rel8  Jump short if parity even (PF=1).
7B cb   JPO rel8  Jump short if parity odd (PF=0).

x86 Instruction Set Reference - Jcc (c9x.me)

You can see that JNP and JPO are the same exact instruction (7B), as are JP and JPE (7A).

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
  • 3
    Not sure why this obviously correct answer was down-voted. – Jonathon Reinhart Aug 21 '18 at 02:36
  • Thank you very much! You solved my probem. I just cannot figure that why a instruction have two name. I had learn that the reason JZ and JE were set is because it have different usage preference or different meaning for USERS. But JP and JPE have no reason to be set. Anyway, Thank you.@Jonathon Reinhart – vio1etus Aug 21 '18 at 03:11
  • @lovely: The same instruction has multiple names for convenience in notation and consistency with ancient CPUs like the [8080](https://en.wikipedia.org/wiki/Intel_8080) and [8085](https://en.wikipedia.org/wiki/Intel_8085), the 8088's direct ancestors. – wallyk Aug 21 '18 at 03:20
  • 1
    @JackZhang it's the same reason... the "JPE" reads "jump when parity is *even*", while the "JP" is "jump when parity is *set*" ... if you don't write tons of x86 assembly, you may find easier to recall "JPE" than recall if the PF is 1 or 0 when the low 8 bits of result had even parity (also if you expect the HW implementation to just `xor` the 8 bits and put the result into PF, you will actually guess it wrong, the PF=1 for even parity, so there's extra "1" being `xor`-ed into it). So in that aspect using `JPE` is sort of easier to remember. OTOH if you really just want to know if PF=1, `JP`.. – Ped7g Aug 21 '18 at 09:51
  • Similarly `JB` and `JC` and `JNAE` are all the same instruction, involving the carry flag. – Weather Vane Aug 21 '18 at 14:43