Author: Dieter Buerssner
Date: 08:54:07 12/01/00
Go up one level in this thread
On November 30, 2000 at 19:50:46, Eugene Nalimov wrote:
>Second, there are better ways to add the value to the register only if register
>is negative. Let's look at the following C code:
>
> t = (x < 0) ? 255 : 0;
> x += t;
> x >>= 8;
>
>One some CPUs there are 'conditional move' instructions. Examples are IA-64,
>Alpha, PentiumPro and up (PII, PIII, PIV). So on PentiumPro and later CPU you
>can use
>
> xor edx, edx
> test eax, eax
> cmovl edx, 255
> add eax, edx
> shr eax, 8
Perhaps, I am totally confused. Otherwise, I would think, that the last line
should read
sar eax, 8 ; Use arithmetic shift
Also in the next example, that I snipped.
Is cmovl fast? My assembler knowledge is from 8086 days and was only updated
for 386 upcodes :-( From that I remember, that the conditional set.. upcodes
were rather slow. Also, using the carry flag, may not not be very "easy"
for a pipelined CPU.
Regards,
Dieter
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.