Re: [Flashforth-devel] For-next loops - the New Design
Brought to you by:
oh2aun
From: Mikael N. <mik...@fl...> - 2015-05-28 13:44:05
|
Igor, I don't think your HW arguement really works. I had to introduce an extra "high level intelligence" branch and decrement to get the desired behavior. See my previous post for that. Also if you bother to take a look at the HW loops inside the PIC24/33 ( DO-LOOP and REPEAT ) these all loop N+1 times. Just because it is efficient in HW. But from a programmer point of view I think it is good to make the 0 FOR2 .. NEXT to loop $10000 times. 0 FOR .. NEXT will loop 0 times. I rely quite a bit on this in many places. Still I am not convinced that the FOR2 is needed that much, so it could be left out also. Most loops that I use are way smaller than $10000 times. In your special case you can do that $10000 time loop with BEGIN UNTIL BR Mike On 28.05.2015 16:11, om1zz wrote: > Peter, > > long time back (2009-10??) there was no do-loop implemented, and we > had discusions about that, afaik. > The reason was it was difficult to implement, heavy and therefore > slow. > > Instead of that, Mike did FOR, which is very fast, as it does just a > single instruction check when passing index to zero. > > That introduces the bug (my interpretation) which has not been > discovered till today (why?). > > Mike has written the do-loop recently (as the external .txt source) > for compatibility reasons (as I claimed long time back mainly because > my intention with floating point library which uses do-loop, and > others). > > Forth is a "better assembler" or "clever assembler" used today for > low level programming on hardware. > No high-level elements there. Just a simple puzzle. > > When working so close to the HW you must admit the hw-specific > behaviour of the forth. > > So - shooting a zero into a loop means it will underrun (within the > size of the basic cell, here 16bit) and loop over till zero (65536x). > That is normal, and this is how the MCU works (all of them, PIC, AVR, > ARM, MIPS, x86, etc). > > Pushing any "high-level intelligence" into the forth's primitive, > basic, fundamental words changes the forth into a Frankenstein.. :) > > Igor, > assistant to Mr. F. > |