What is the meaning of XOR in x86 assembly?

前端 未结 11 1882
醉梦人生
醉梦人生 2020-12-13 08:50

I\'m getting into assembly and I keep running into xor, for example:

xor     ax, ax

Does it just clear the register\'s value?

11条回答
  •  自闭症患者
    2020-12-13 09:39

    When I started programming a long time ago there was no exclusive or on either the processor or in the compiler. When I got around to it I stuck to the descriptions:

    • or: true if a=1 or b=1 or both=1
    • xor: true if a=1 or b=1 but not both=1

    so:

    0 or 0 = 0
    0 or 1 = 1
    1 or 0 = 1
    1 or 1 = 1
    

    and

    0 xor 0 = 0
    0 xor 1 = 1
    1 xor 0 = 1
    1 xor 1 = 0
    

提交回复
热议问题