Author: James Swafford
Date: 16:33:17 11/29/00
Go up one level in this thread
On November 29, 2000 at 15:50:43, Bruce Moreland wrote: >They will produce the same values on signed ints. If you use unsigned values, a >/ 2 will be compiled by the Microsoft compiler I use as: > > shr eax, 1 > >If you use an signed value, you get: > > cdq > sub eax, edx > sar eax, 1 > >This is an attempt to avoid a divide, but it's a lot of evil stuff compared with >the first one. I bet "cdq" annoys the processor, but I don't know for sure, and >in any case that's three instructions compared with one. > cdq is an ugly one for sure. If I'm not mistaken, it involves a comparison, a conditional jump, and a mov if the flag indicates the number is negative. Pretty nasty. Seems to me it would be better to just use unsigned ints wherever possible. -- James
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.