[Classic sharing] operations on counterpoint

Source: Internet
Author: User

# Define bit (x) (1 <(x ))
# Define bit0 (0x01)
# Define bit1 (0x02)
# Define bit2 (0x04)
# Define bit3 (0x08)
# Define bit4 (0x10)
# Define bit5 (0x20)
# Define bit6 (0x40)
# Define bit7 (0x80)
# Define bit8 (0x0100)
# Define bit9 (0x0200)
# Define bit10 (0x0400)
# Define bit11 (0x0800)
# Define bit12 (0x1000)
# Define bit13 (0x2000)
# Define bit14 (0X4000)
# Define bit15 (0x8000)
# Define bit16 (0x00000ul)
# Define bit17 (0x020000ul)
# Define bit18 (0x040000ul)
# Define bit19 (0x080000ul)
# Define bit20 (0x100000ul)
# Define bit21 (0x200000ul)
# Define bit22 (0x400000ul)
# Define bit23 (0x800000ul)
# Define bit24 (0x0000000ul)
# Define bit25 (0x02000000ul)
# Define bit26 (0x04000000ul)
# Define bit27 (0x08000000ul)
# Define bit28 (0x0000000ul)
# Define bit29 (0x20000000ul)
# Define bit30 (0x40000000ul)
# Define bit31 (0x80000000ul)

/* A is a register, and B is the bit to be operated */

# Define bit_set (A, B) (a) | = (1 <(B) // set
# Define bit_clear (A, B) (a) & = ~ (1 <(B) // clear the bit
# Define bit_flip (A, B) (a) ^ = (1 <(B) // bit flip
# Define bit_check (A, B) (a) & (1 <(B) // check

/* X is the target variable, and Y is the mask */

# Define bitmask_set (x, y) (x) | = (y ))
# Define bitmask_clear (x, y) (x) & = (~ (Y )))
# Define bitmask_flip (x, y) (x) ^ = (y ))
# Define bitmask_check (x, y) (x) & (y ))

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.