On Mon, Mar 26, 2007 at 09:51:02PM -0700, Stefan O'Rear wrote:
> On Mon, Mar 26, 2007 at 09:31:41PM -0700, John Meacham wrote:
> > On Mon, Mar 26, 2007 at 09:23:13PM -0700, Stefan O'Rear wrote:
> > > On Mon, Mar 26, 2007 at 09:15:35PM -0700, John Meacham wrote:
> > > > actually, this is not true for the specific case of testing against zero
> > > > on x86 at least. there is a 'zero flag' that is set whenever the result
> > > > of an operation is zero. whereas for compares, you actually need to load
> > > > zero into a register and cmp against it.
> > > 
> > > Uh, you mean normal operations don't set the sign flag?  (I'm just an
> > > assembly programmer and am perfectly willing to defer to a compiler
> > > writer on such issues, but it seems like a strange assertion...)
> > 
> > They certainly do, but in this particular case, the 'decrement' (n - 1)
> > happens to set the zero flag if n is one so we get that comparison for
> > free. We don't have a flag which immediately tells us  whether n <= 0
> > however so we have to perform that comparison separately.
> 
> Not <=, no, but we do have <0 (SF) and =0 (ZF) ; if DEC has the
> dignity to clear OF we could use the single JLE instruction, otherwise
> we would need to JS then JZ to the same address.  Either way we would
> not need to explicitly CMP anything.  I think. 
> 
> (Actually if DEC sets OF properly then that will work just as well as
> clearing it.)

Ah yes, you are right, that does work. it must be something else that is
going on here.
        John

-- 
John Meacham - ⑆repetae.net⑆john⑈
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to