NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: Kurdistan on February 26, 2010, 02:07:22 AM

Title: Check a specific bit in a byte
Post by: Kurdistan 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
Title: Re: Check a specific bit in a byte
Post by: Keith Kanios on February 26, 2010, 02:11:08 AM
You can use TEST (http://pdos.csail.mit.edu/6.828/2008/readings/i386/TEST.htm) to achieve what you want.
Title: Re: Check a specific bit in a byte
Post by: Kurdistan 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).