Author: Eiko Bleicher
Date: 05:31:56 01/09/04
Go up one level in this thread
>that I have code which looks like this: > >if(x) y += 20; > >Would it then be advantageous to rewrite the code like this? > >y += (!(!x))*20; > In assembly there might be another way, the conditional move. Should look something like this (untested): xor eax, eax ; eax = 0 mov ecx, x ; ecx = x mov edx, y ; y = edx test ecx, 0xFFFF ; test if x == 0 (maybe use some other value cmovnz eax,20 ; if x != 0 then eax = 20 add edx, eax ; y = y or y += 20, depending on x mov y, edx I don't know if this is worth avoiding the jump. I guess one has to test it, and different proecessors or compilers my give different results.
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.