flat assembler
Message board for the users of flat assembler.

Index > Main > lzcnt?

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Sep 2009, 13:09
What's the point of lzcnt when there is already bsr?

_________________
Post 24 Sep 2009, 13:09
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 24 Sep 2009, 13:49
They behave differently, when the value consists of all zeros.
BSR searches for the highest bit that is set to 1, and when there's no such bit found, it returns with ZF cleared, and destination not modified.
On the other hand, LZCNT counts the amount of zeros from the highest bit, and when the value consists of all zeros, it simply returns the amount equal to the size (in bits) of the source operand.
Post 24 Sep 2009, 13:49
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 24 Sep 2009, 13:54
Tomasz Grysztar wrote:
BSR searches for the highest bit that is set to 1, and when there's no such bit found, it returns with ZF cleared, and destination not modified.
Minor correction: Although what you say may be true in practice, the docs state that the dest is undefined in that situation. So it is probably best not to rely upon any unmodified behaviour.
Post 24 Sep 2009, 13:54
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 24 Sep 2009, 14:08
And don't forget that LZCNT is AMD-specific and AFAIK Intel is not going to implement it. Let me know if I'm wrong.
Post 24 Sep 2009, 14:08
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 27 Sep 2009, 01:41
MazeGen wrote:
And don't forget that LZCNT is AMD-specific and AFAIK Intel is not going to implement it. Let me know if I'm wrong.


Why, though? Patents? Pride? I can't see the harm in both implementing such instructions, but I don't know what goes on behind the scenes.
Post 27 Sep 2009, 01:41
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 27 Sep 2009, 12:16
I'm not sure. Competition and different roadmaps perhaps. And important players' opinion matters I think. If developers of Visual C++ tell Intel "hey, there's LZCNT which could be useful", they can force them to implement it.

BTW, there are Intel forums where you could ask. The Intel guys are pretty responsive.
Post 27 Sep 2009, 12:16
View user's profile Send private message Visit poster's website 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.