flat assembler
Message board for the users of flat assembler.

Index > Main > Bit Testing

Author
Thread Post new topic Reply to topic
Steve



Joined: 10 Sep 2005
Posts: 10
Steve 23 Apr 2006, 18:53
Hi.

I need some help testing a bit in an 8-bit register. For example, how would I go about reading bit 4 of that specific register? I've looked at 'test' but I'm not really sure how to go to a specific position in the register and test the bit. How would I do this?

Thank you,

- Steve Smile
Post 23 Apr 2006, 18:53
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 23 Apr 2006, 20:44
test reg, 2^bit Razz

so, to test bit 4, you'd calculate 2^4 (two raised to the power of four). That's 16. Then, "test reg, 16". Now you can do something like "sete al" to set AL to the bitvalue.

There's also the "BT" (bit test) instruction - check out an x86 reference for more information.
Post 23 Apr 2006, 20:44
View user's profile Send private message Visit poster's website Reply with quote
Steve



Joined: 10 Sep 2005
Posts: 10
Steve 23 Apr 2006, 21:09
Thanks, f0dder. Very helpful as always. Smile
Post 23 Apr 2006, 21:09
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.