Re: [Flashforth-devel] For-next loops - the New Design
Brought to you by:
oh2aun
From: Herman A. <exp...@vn...> - 2015-05-28 21:58:56
|
Igor I think, we do not understand each other. Maybe I was not clear enough. The current for-next in FF is very good for general purpose, when there is no problem with missing loop, and the skip function of 0 for is beneficial. So, it needn't change. My hypothetical n mfor...mnext would be an optional loop type to solve the full 16bit problem. It would be as fast, as the original for-next. In this case the meaning of n is the maximal distance from the reference position, that you want to rich. If you substitute the for-next to mfor-mnext in your example, you will get the next results: 1 memtest 65535 2 memtest 131071 n memtest n*65536-1 Because it is a non-standad loop structure, I think use it from a loadable text file, as Craig said. BR Attila 2015.05.28. 20:52 keltezéssel, om1zz írta: > Attila > with properly working 0 FOR you can do for example: > > 2variable count \ just a counter to see the number of loops > > : memtest ( 64k_blocks -- ) > 0. count 2! \ reset the counter > \ the BIG memory access loop, max 4,294,967,296 bytes > for > 65535 \ this should be normally 0 > for > count 2@ 1. d+ count 2! \ here you do something with memory > next > next > cr count 2@ ud. ; > > 1 memtest > 65535 ok<#,ram> > 2 memtest > 131070 ok<#,ram> > 16 memtest > 1048560 ok<#,ram> > ok<#,ram> > ok<#,ram> > 64 memtest > 4194240 ok<#,ram> > > Now the count does not match as you miss a count every loop, but this is how the stuff works. > It could be done with do-loop (which works with zero), but I think it would be more elegant with FOR. > Igor > ______________________________________________________________ >> Od: Herman Attila <exp...@vn...> >> Komu: <fla...@li...> >> Datum: 28.05.2015 17:21 >> Předmět: Re: [Flashforth-devel] For-next loops - the New Design >> >> I think the best solution of the n for ... next cycle, witch run >> n-times, including n=0, as it is in the FF now. This principle >> incopatible to cover the for full 16-bit range. >> >> To rich the full 16bit range must be defined an other for-next like >> cycle, with different approach. In this case the goal is not to makes n >> count, but to cover a non-zero long range. The cycle must run n to 0, >> including n and 0. The 'next' decrements after testing for zero. We need >> only to find the appropriate word-names. >> Because it is mostly usable for memory addressing, maybe mfor-mnext. >> n mfor r@ u. mnext ---> n ... 0 >> 0 mfor r@ u. mnext ---> 0 >> 5 mfor r@ u. mnext ---> 5 4 3 2 1 0 >> 65535 mfor r@ u. mnext ---> 65535 65534 ... 1 0 >> >> BR >> Attila >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Flashforth-devel mailing list >> Fla...@li... >> https://lists.sourceforge.net/lists/listinfo/flashforth-devel >> |