XOR register,register (assembler)

前端 未结 3 735
轮回少年
轮回少年 2020-12-20 16:16

From time to time we have to analyze pieces of assembler code (IA32), and more than often i come across an instruction that looks like this:

xor ax, ax
         


        
3条回答
  •  佛祖请我去吃肉
    2020-12-20 16:50

    It's a common assembler idiom to set a register to 0.

    xor ax, ax corresponds to ax = ax ^ ax which, as you already notices, is effectively ax = 0.

    If I recall correctly the main advantage is that its code-size is smaller than mov ax, 0

提交回复
热议问题