flat assembler
Message board for the users of flat assembler.

Index > Main > setting specified bit

Author
Thread Post new topic Reply to topic
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder 23 Sep 2008, 13:47
im sure i asked that before, but google wont index this site and i cant find it using search.php.


i have 32 bits:

a rd 1


and i want to use all bits like bool variables.


bt [a],0 - bt [a],31 thats testing, bit will copy to CF

and now i want to set [a],0
how?
Post 23 Sep 2008, 13:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 23 Sep 2008, 14:22
Since you already know BT, read also about BTS/BTR/BTC.
Post 23 Sep 2008, 14:22
View user's profile Send private message Visit poster's website Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder 23 Sep 2008, 14:47
[content deleted]


Last edited by asmcoder on 14 Aug 2009, 14:56; edited 1 time in total
Post 23 Sep 2008, 14:47
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4042
Location: vpcmpistri
bitRAKE 23 Sep 2008, 15:25
All BT/BTC/BTS/BTR put the bit value in the carry flag - this is the "test". There is no single instruction to swap the carry flag and another bit. IIRC, there is a binary math trick to swap bits requiring two instructions, but no branch.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 23 Sep 2008, 15:25
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 23 Sep 2008, 16:57
no, that means complement.
com1=0
com0=1

and this subject is still aborded on the board many times.
Post 23 Sep 2008, 16:57
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 09 Oct 2008, 19:14
asmcoder,

How about good old or [a],1? Wink

btx family is good for bit manipulation at an arbitrary bit index (they support register operand as bit index), for fixed bit index test, and, or & xor are somewhat better (proper coding ensures that you won't access word[0xFFFF] in 16-bit RM Wink), though barely equivalent (btx, you see).

By the way, IA-32 (2003 A.D.) and Intel® 64 (April 2008, maybe 1st Wink) ASDMs in vol. 2 both insist that with btx you can index 16 bits using only 3 bits (32 bits' indices are correctly stated as 5 bits wide).
Post 09 Oct 2008, 19:14
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.