I've been trying to use the CMOV instructions in my program, but masm tells be that the instructions isnt allowed in the current cpu mode.

Do I need something like .mmx to use them?

Secondly, I've read that the danger of conditional jumpiong is that if it's mis predicted then something has to be completly reloaded and thats very expensive.

Well what happens if the cpu comes across an instruction like jmp dword ptr or worse again je dword ptr .

The second thing is just a curiosity for the moment, but the CMOV instructions would be of great help to me.

Thanks.
Posted on 2001-11-04 07:58:31 by Eóin
Use the ".686" directive to enable the cmovcc instruction.
Posted on 2001-11-04 08:31:52 by Dr. Manhattan
E?in,

You are no worse off with the CMOVxx family of instructions than you are with the normal conditional jumps in terms of mispredictions. As long as the logic of your algo requires some form of conditional code, you will have at least some situations where one branch is predicted better than the other.

Where you do have a win is in the reduction of jumps if you can structure the code that way. You can usually clock the difference by jump reduction if the rest of the code works OK.

Regards,

hutch@movsd.com
Posted on 2001-11-04 14:10:56 by hutch--
Hi !

I just want ot add that CMOVcc will not work on every CPU ! Normal pentiums (I) and AMD-K6 didn't support these functions.

You can check the CMOVcc-ability of a cpu using the CPUID-instruction !

Greetings, CALEB
Posted on 2001-11-04 16:58:40 by Caleb
and care, that even not all CPUs support the CPUID instruction.

Nice examples for determing the cpu caps can be found at the
AMD webpage.
Posted on 2001-11-05 08:54:14 by beaster
Btw, CMOVcc can give dramatic speed improvements if used correctly.
I had sorta been ignoring CMOVcc as it took quite some time before
I had a CPU that supported them. I was working on speeding up
an algorithm used in a bruteforcer. VC and my hand-optimized code
were about the same result. Just for fun, I ran my C code through
GCC with a lot of funky optimization switches... and almost lost my
jaw when I got a 3x speed improvement. The main algorithm was
pretty tight, and had a few conditional jumps. GCC had inlined and
unrolled it. Big deal, both me and VC had done that. But GCC had
also been smart enough to use CMOVcc instead of conditional jumps,
which VC for some reason hadn't, even though I had told it that it
would be OK to use PPro+ instructions...
Posted on 2001-11-07 04:16:31 by f0dder
Interesting.
Posted on 2001-11-07 08:52:09 by dxantos
Hi !

This time I only want to add a small asm file which may help you to recognize the abilities of your CPU. I'm sure that there have been released many versions of that, but it's always good to keep the differences of common CPUs in mind, also if they are all x86-compatible.

Until now only extended abilities of AMD-CPUs are recognized (except of SSE and MMX - they are defined in the standard feature-flags) ... but feel free to extend this !


Greetings CALEB
Posted on 2001-11-25 08:02:50 by Caleb