当前位置:网站首页>The significance of XOR in embedded C language

The significance of XOR in embedded C language

2022-07-07 15:38:00 sgmcy

Bitwise operations are divided into : And , or , Not

But why is there an XOR ?

And : All two are 1, It's just 1, Otherwise 0.

or : As long as one is 1, Namely 1, All two are 0, Output is 0

Not :0 change 1,1 change 0

In the past, in class , The teacher told us

The role of and , To make someone bit Used to clear

The role of or , To make someone bit Set up 1

But there is no function of XOR

Exclusive or : Same as 0, Different for 1

The most classic application of XOR , It is the clearing of registers . The classic one x86 Architecture , Frequently used register zeroing

First , Read the value of this register , Then let the value and the register XOR , You can clear the entire register

Especially in X86 In assembly language programming , You often see this XOR clear operation , That's why XOR is introduced

原网站

版权声明
本文为[sgmcy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130612547696.html