Understanding bset and bclr

user623990 picture user623990 · Dec 12, 2012 · Viewed 7.3k times · Source

I've run across an example my professor made which made me question my understanding of the bset and bclr assembly commands.

If I do this:

bset BITS,80

am I performing an AND or an OR operation between the two? My reference guide says that bset does this:

M <= M + mask

Is + an OR or an AND operator? bclr is the same command but performs the operation with the complement of the mask.

Answer

Ira Baxter picture Ira Baxter · Dec 12, 2012

Bit setting and clearing implies ORing and ANDing, bitwise, respectively. BSET should be doing OR, and BCLR should be doing effectively AND.

It may be that BCLR simply does AND with the bit vector you give it, or BCLR does AND with the complement of the bit vector (my guess), depending on how nice the designers of the instruction set are.