flat assembler
Message board for the users of flat assembler.

Index > Main > BT instruction?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 22 Jan 2007, 06:05
so anyone could create thread for "Speed testing code" and put it all together? Wink
Post 22 Jan 2007, 06:05
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 24 Jan 2007, 10:52
I mainly use BT for small code.. speed is hard to measure because it varies on processor.

I remember some time ago I did this test, and bt was much slower on my Pentium 4, but almost tied on my AMD Mobile Sempron 2800+.

But I can't remember if I did it right, but I did use maximum priority (even the mouse froze during the test).
Post 24 Jan 2007, 10:52
View user's profile Send private message Reply with quote
Plue



Joined: 15 Dec 2005
Posts: 151
Plue 24 Jan 2007, 16:10
> I mainly use BT for small code
But BT is larger than TEST?!?
Post 24 Jan 2007, 16:10
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 24 Jan 2007, 16:43
Plue wrote:
> I mainly use BT for small code
But BT is larger than TEST?!?


Nah, you need more than just a TEST instruction to perform the sam as BT [mem32], reg32 - BT is small here.

_________________
Image - carpe noctem
Post 24 Jan 2007, 16:43
View user's profile Send private message Visit poster's website Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 25 Jan 2007, 11:40
f0dder wrote:

Nah, you need more than just a TEST instruction to perform the sam as BT [mem32], reg32 - BT is small here.

You absolutely right. BTx instructions are useful when you need to test a bit at a position not know at compile-time and if you only have a few bits to test.

if bit position is know at compile time => use TEST or something

if you have lots of bits to test => try building a mask, maybe with some look up table and perform a TEST with that

BTW: BTx is almost as fast as TEST (except for the memory version) on my Athlon XP, but was way slower than TEST on a PII

_________________
MCD - the inevitable return of the Mad Computer Doggy

-||__/
.|+-~
.|| ||
Post 25 Jan 2007, 11:40
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 25 Jan 2007, 11:42
BTx instructions other than BT are also useful because the allow to test the bit and alter it at the same time.
Post 25 Jan 2007, 11:42
View user's profile Send private message Visit poster's website Reply with quote
16bitPM



Joined: 08 Jul 2011
Posts: 30
16bitPM 23 Oct 2022, 15:44
Tomasz Grysztar wrote:
BTx instructions other than BT are also useful because the allow to test the bit and alter it at the same time.


I would also say for bit and bit string manipulation, because BT effectively copies a bit to the carry flag, you can use it directly in arithmetic and shift operations. Other than that specific use case, BT reg,imm seems rather superfluous to me.
Post 23 Oct 2022, 15:44
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2595
Furs 24 Oct 2022, 13:15
16bitPM wrote:
Tomasz Grysztar wrote:
BTx instructions other than BT are also useful because the allow to test the bit and alter it at the same time.


I would also say for bit and bit string manipulation, because BT effectively copies a bit to the carry flag, you can use it directly in arithmetic and shift operations. Other than that specific use case, BT reg,imm seems rather superfluous to me.
Here's another one: in 64-bit mode, immediates are 32-bit sign extended, so if you want to test a bit in the upper 32-bit half of the 64-bit register, only BT can do that with an immediate.
Post 24 Oct 2022, 13:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20517
Location: In your JS exploiting you and your system
revolution 24 Oct 2022, 13:20
Furs wrote:
Here's another one: in 64-bit mode, immediates are 32-bit sign extended, so if you want to test a bit in the upper 32-bit half of the 64-bit register, only BT can do that with an immediate.
I don't understand what you mean.

This instruction is valid:
Code:
bt rax,rcx    
Are you confusing 32-bit immediate (+- 2GB) with 32-bit register length?
Post 24 Oct 2022, 13:20
View user's profile Send private message Visit poster's website Reply with quote
16bitPM



Joined: 08 Jul 2011
Posts: 30
16bitPM 24 Oct 2022, 14:20
revolution wrote:
Furs wrote:
Here's another one: in 64-bit mode, immediates are 32-bit sign extended, so if you want to test a bit in the upper 32-bit half of the 64-bit register, only BT can do that with an immediate.
I don't understand what you mean.

This instruction is valid:
Code:
bt rax,rcx    
Are you confusing 32-bit immediate (+- 2GB) with 32-bit register length?


No, he was replying on my comment on the specific case of BT with an immediate operand and a register.
Post 24 Oct 2022, 14:20
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2595
Furs 25 Oct 2022, 13:01
Yeah, basically you can't do:
Code:
test rax, 1 shl 42    
but you can do:
Code:
bt rax, 42    
Post 25 Oct 2022, 13:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.