flat assembler
Message board for the users of flat assembler.
Index
> Main > checking registers for binary bit Goto page 1, 2 Next |
Author |
|
bitshifter 12 Apr 2010, 00:39
Code: test bx,0000000000000010b jnz bit_is_set Last edited by bitshifter on 12 Apr 2010, 00:54; edited 2 times in total |
|||
12 Apr 2010, 00:39 |
|
GhostXoPCorp 12 Apr 2010, 00:41
thanks a bunch
|
|||
12 Apr 2010, 00:41 |
|
GhostXoPCorp 12 Apr 2010, 00:46
well hold on
test bx, 00000000000000010 would check for 0 >>1 << 111011010101011 int he 16 digits? |
|||
12 Apr 2010, 00:46 |
|
bitshifter 12 Apr 2010, 00:49
Code: and bx,0000000000000010b jnz bit_is_set Is the same but trashes bx Where test preserves bx EDIT: fixed to 16 bits instead of 17 (copy and paste burns me again) Last edited by bitshifter on 12 Apr 2010, 00:54; edited 1 time in total |
|||
12 Apr 2010, 00:49 |
|
GhostXoPCorp 12 Apr 2010, 00:54
my wonder is how does that check for the second digit in 01111011010101011 to see if its a 1 or 0?
oh i see its suppose to be opposite |
|||
12 Apr 2010, 00:54 |
|
bitshifter 12 Apr 2010, 00:56
|
|||
12 Apr 2010, 00:56 |
|
GhostXoPCorp 12 Apr 2010, 01:07
so if i wanted to check the 3rd bit id do this
test bx, 0000000000000100b ? |
|||
12 Apr 2010, 01:07 |
|
bitshifter 12 Apr 2010, 01:10
yep
jnz bit_is_set jz bit_not_set |
|||
12 Apr 2010, 01:10 |
|
GhostXoPCorp 12 Apr 2010, 01:11
thanks alot
|
|||
12 Apr 2010, 01:11 |
|
bitshifter 12 Apr 2010, 01:15
You can also use this trick to test sign bit of integer/decimal
values to easily check if it is < 0 else if >= 0 |
|||
12 Apr 2010, 01:15 |
|
revolution 12 Apr 2010, 01:22
Also:
Code: bt bx,1 jc bit_is_set jnc bit_is_clear |
|||
12 Apr 2010, 01:22 |
|
bitshifter 12 Apr 2010, 01:28
Thanks revolution.
Its always nice to see alternate methods. |
|||
12 Apr 2010, 01:28 |
|
Tyler 13 Apr 2010, 06:35
Is there any way to compliment a single bit without changing the flags reg(no btc)?
|
|||
13 Apr 2010, 06:35 |
|
revolution 13 Apr 2010, 06:42
Tyler wrote: Is there any way to compliment a single bit without changing the flags reg(no btc)? Code: pushfd btc bx,1 popfd |
|||
13 Apr 2010, 06:42 |
|
Tyler 13 Apr 2010, 06:59
Yeah, i guess your right, didn't think of that.
|
|||
13 Apr 2010, 06:59 |
|
a115433 13 Apr 2010, 07:41
lahf is better than pushf/popf.
you dont have to save high flags, only basic ones responsible for arithmetics. and remember that in long mode you cant use conditional jumps, only movcc to accomplish it. |
|||
13 Apr 2010, 07:41 |
|
Tyler 13 Apr 2010, 08:10
Quote:
Really?! Do you mean you can't use conditional jumps at all in long mode? |
|||
13 Apr 2010, 08:10 |
|
a115433 13 Apr 2010, 09:09
Quote: Do you mean you can't use conditional jumps at all in long mode? instruction exist, and they work exactly as in 32bit mode. but you cant jump more than 2GB, and because ia32e has maximum 64bit addressing, this jump is useless, and even impossible in dynamic allocated memory. in 32 bit mode it cover exactly 4 gigs, so its ok, in ia32e mode, you have to use jmp. something like that: test rcx,rcx mov rax,is_zero movnz rax,not_zero ;will replace rax only if zf is not set jmp rax |
|||
13 Apr 2010, 09:09 |
|
revolution 13 Apr 2010, 09:15
Tyler: a115433 has a bee in his bonnet about how Long Mode can't support jumps further than 2GB. Of course LM supports all conditional and unconditional jumps, just not all the way to 64-bit.
OMG a 64-bit IP register and only 31-bit jumps!!!!!!! |
|||
13 Apr 2010, 09:15 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.