On Tue, Jan 18, 2011 at 08:24:06AM -0800, James Paige wrote:
> On Tue, Jan 18, 2011 at 08:33:28PM +1300, Ralph Versteegen wrote:
> > On 18 January 2011 05:29, James Paige <[email protected]> wrote:
> > > On Sun, Jan 16, 2011 at 07:31:35PM +1300, Ralph Versteegen wrote:
> > >> On 14 January 2011 08:54,  <[email protected]> wrote:
> > >> > james
> > >> > 2011-01-13 11:54:39 -0800 (Thu, 13 Jan 2011)
> > >> > 173
> > >> > Fix potential bitwise breakage in "hero is walking"
> > >> > when the hero is walking both horizontally and vertically
> > >> > at the same time. ("NPC is walking" did not have this problem)
> > >> > ---
> > >> > U   wip/yetmore.bas
> > >>
> > >> Actually, your new implementation is equivalent to the old one.
> > >
> > >
> > > -   IF (xgo(retvals(0)) OR ygo(retvals(0))) THEN
> > > +   IF xgo(retvals(0)) = 0 AND ygo(retvals(0)) = 0 THEN
> > > +    scriptret = 0
> > > +   ELSE
> > >     scriptret = 1
> > > -   ELSE
> > > -    scriptret = 0
> > >
> > > Switching AND for OR and inverting the sense of the THEN/ELSE made no
> > > difference, but adding the = 0 to both sides was the real fix.
> > 
> > But "(xgo(retvals(0)) OR ygo(retvals(0))) <> 0" is equivalent to
> > (aside from being faster but less clear) "xgo(retvals(0)) <> 0 OR
> > ygo(retvals(0)) <> 0"
> 
> I did it the way I did it because that was how "NPC is walking" was 
> implemented-- and it looked clearest to my eyes that way.
> 
> > > I don't know why I didn't use ANDALSO :P
> > 
> > Because ANDALSO compiles to more instructions, of course!
> 
> Ooh! I did not tknow that. Good to know I had a good reason ;)
> 
> > Actually, I just checked the assembly for the ANDALSO version and am
> > horrified to find that fbc is not only not performing any of the
> > obvious and easy optimisations which I had thought it would, but it
> > actually adds an unnecessary layer of indirection with a temporary
> > variable on the stack! Instead of emitting just 4 instructions for the
> > test (not counting reading from the arrays: twice test, je) as it
> > could, it emits... 15 instructions!!
> > 
> > fbc's optimisation certainly is terrible. I found a bug in the how it
> > does algebraic rearrangement a couple days ago, so if some calculation
> > is returning the wrong answer, be warned that it could actually be
> > fbc's fault.
> 
> Ouch. What was the algebraic rearrangement bug?

Oh, wait. I see it now. Bug 3153953 on FreeBasic's bug tracker.

---
James
_______________________________________________
Ohrrpgce mailing list
[email protected]
http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org

Reply via email to