Author Topic: Check a specific bit in a byte  (Read 16299 times)

Offline Kurdistan

  • Jr. Member
  • *
  • Posts: 2
  • 10+10=100
Check a specific bit in a byte
« on: February 26, 2010, 02:07:22 AM »
I have a byte which represents 8 different settings/modes which are enabled.
00000001b = A20 Enabled
00000011b = PM Enabled

I could cmp the byte with 1 to know if A20 is enabled.
I could cmp the byte with 3 if both A20 and PM is enabled.

What if i want to check if only PM is enabled?
So my question is, how can I cmp a single chosen bit in a byte?

Thanks
Currently developing a Web Server Operating System

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: Check a specific bit in a byte
« Reply #1 on: February 26, 2010, 02:11:08 AM »
You can use TEST to achieve what you want.

Offline Kurdistan

  • Jr. Member
  • *
  • Posts: 2
  • 10+10=100
Re: Check a specific bit in a byte
« Reply #2 on: February 26, 2010, 02:27:39 AM »
Nice, thanks. Also found BT which worked great too. (BT increase the output file with one extra byte compared to TEST).
« Last Edit: February 26, 2010, 02:30:46 AM by Kurdistan »
Currently developing a Web Server Operating System