From: Wolfgang Kern on

"Robert Redelmeier" replied:

>> CMOVcc eax,[eax] ;may invoke a GP/PF fault regardles if condition is met
>> [snip] Sure, most of you already knew it anyway ... or not ? :)

> No, I did not. But it encourages me to use CMOV 'cuz I
> don't read memory that doesn't belong to me, and I'm glad
> of the errors/notification when I mistakenly try.
>
> The worst bugs are those that only happen on "condition".

Yes, I encountered the problem in my debugger/exception handler:

8c e8 MOV eax,gs
0f 00 e0 VERR ax
65 0f 44 05 00 00 00 00 CMOVz eax,gs:[0]
2e 0f 44 05 .. .. .. .. CMOVnz eax,cs:[def_0]
e8 .. .. .. .. CALL display_eax

So I had to go back to my previous spaghetti solution with Jz/Jmp.

__
wolfgang



From: Rosario on
In data Mon, 15 Oct 2007 21:09:46 +0200, Wolfgang Kern scrisse:

>While I tried to get rid of some jumps, I figured it out the hard way,
>and I think it may be of help for other coders around to know:
>
>CMOVcc eax,[eax] ;may invoke a GP/PF fault regardles if condition is met
>
>while any
>
>Jcc over_next
>mov eax,[eax] ;may only raise an exception if executed at all
>over_next:
>
>So finally we should see CMOVcc r,[mem] as a limit-restricted instruction.
>Sure, most of you already knew it anyway ... or not ? :)

never used that instruction in all my life and hope nobody use that

>__
>wolfgang
From: H. Peter Anvin on
Rosario wrote:
> In data Mon, 15 Oct 2007 21:09:46 +0200, Wolfgang Kern scrisse:
>
>> While I tried to get rid of some jumps, I figured it out the hard way,
>> and I think it may be of help for other coders around to know:
>>
>> CMOVcc eax,[eax] ;may invoke a GP/PF fault regardles if condition is met
>>
>> while any
>>
>> Jcc over_next
>> mov eax,[eax] ;may only raise an exception if executed at all
>> over_next:
>>
>> So finally we should see CMOVcc r,[mem] as a limit-restricted instruction.
>> Sure, most of you already knew it anyway ... or not ? :)
>
> never used that instruction in all my life and hope nobody use that
>

It's frequently used, especially in 64-bit mode (where it is part of the
architectural baseline.)

-hpa
From: Wolfgang Kern on

Rosario scrisse:

....
>> So finally we should see CMOVcc r,[mem] as a limit-restricted
instruction.
>> Sure, most of you already knew it anyway ... or not ? :)

> never used that instruction in all my life and hope nobody use that

You may wonder how often CMOVcc and SETcc occure in programs targeted
to +486 CPUs.
As this two can save on many branch-instruction, I started to rewrite all
my older code and gain ~20% speed in average without increasing its size.

__
wolfgang



From: alex on
yep