flat assembler
Message board for the users of flat assembler.

Index > Main > Branch hint prefixes

Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 15 Jul 2010, 13:14
"Branch hint prefixes (2EH, 3EH) allow a program to give a hint to the processor about the most likely code path for a branch. Use these prefixes only with conditional branch instructions (Jcc)." (from Intel manual)

What does that mean?

_________________
Sorry if bad english.
Post 15 Jul 2010, 13:14
View user's profile Send private message 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 15 Jul 2010, 13:38
It means you can tell the CPU whether the branch is most likely to be taken or not. Rather than rely on the static prediction the CPU provides.

But, don't try to understand too deeply, they are mostly useless, and only have any effect on a very narrow range of one type of one manufacturer's CPU.
Post 15 Jul 2010, 13:38
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 15 Jul 2010, 14:14
hum.. if these prefixes can be used on many X86 CPU, it can be interrresting for big loops. for exemple, a functions that compute on many audio samples, will run inside the loop a lot of time, compared to a branch that will occur rarelly like the null terminating char.

using these prefixes can be interresting, i'll look it deeper one day.

what symbol can be used to declare the branch hint prefixes?

Code:

@@:
lodsd
cmp eax,0 
true jne @b
@@:
lodsd
cmp eax,0
false je @b
 
    


something like that.

true and false keywords just before the instruction.
yes or no?
Post 15 Jul 2010, 14:14
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 15 Jul 2010, 14:29
IIRC the override is only active when the branch has no history stored in the BTB. So you have to be executing a lot of "new" code the CPU has not seen before to make use of the hint. For loops and other normal things the static predictor + BTB will almost always get it right and no hint is needed.
Post 15 Jul 2010, 14:29
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 15 Jul 2010, 17:34
Branch hint prefixes are not of much use today as Intel abandoned NetBurst microarchitecture:

http://ref.x86asm.net/geek32.html#gen_note_branch_prefixes
Post 15 Jul 2010, 17:34
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 15 Jul 2010, 22:44
phew, one less thing to worry about.
Post 15 Jul 2010, 22:44
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.