Re: [Flashforth-devel] For-next loops - the New Design
Brought to you by:
oh2aun
From: om1zz <om...@vo...> - 2015-05-28 18:52:28
|
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 > |