Arm Learning & mdash; Summary of bit operations, arm learning Summary

Source: Internet
Author: User

Arm learning-Summary of bit operations and arm learning Summary

In the process of learning arm, the sensory register basically does not provide bitwise operations, but the overall operation,
The overall operation is to note that when assigning a value to a specific bit, it does not affect other places. It does not look simple,
In fact, the overall operation is skillful,
So let's summarize:


1. First, we must understand that the "|" symbol is used to set 1, and the "&" symbol is used to set 0.
2. Whether set to 1 or 0, the left side of "<" always appears in the form of 1. Set 0 and add the inverse symbol.

Combining the above two rules makes it easy:
For example, if we first write the 6th position 1 of a register (1 <6) to be used.
Then set 1 to use the "|" rule, so it is: reg | = (1 <6 );
What if the 6th position is 0:
In the same way, first write (1 <6) to be used.
If it is set to 0, "&" is used to add a rule that obtains the inverse symbol. So it is: reg & = ~ (1 <6 );

Now, it's hard to understand:
Reg & = ~ (1 <6) | (1 <7) | (1 <2 ));
What does this mean? When you see "& =", you will know that you want to set a position 0.
(1 <6) | (1 <7) | (1 <2) indicates that, 2, 6, and 7 are set to 1, and the reverse is displayed.
So the meaning of this sentence is to set 2, 6, and 7 to 0.

Let's return to the program:

If (dwDat & (1 <2 ))
What does this sentence mean?
It is to judge whether the second bits of swDat are 1, if the second bits are 1, the result is 1, and if is true.
This can be understood as a read operation ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.