Re: [Flashforth-devel] For-next loop - full 16bit count?
Brought to you by:
oh2aun
From: om1zz <om...@vo...> - 2015-05-26 12:00:23
|
Hopefully other people here will provide their points too, and if it comes to voting at the end my suggestion (which comes from the assumption the FF primitives shall represent the primitive behavoiur of the assembler in the specific number range domain, here the 16bit type) is: FOR n FOR blink_led NEXT n=65535 led blinks 65535x n=25 led blnks 25x n=1 led blinks 1x n=0 led blinks 65536x ?FOR n ?FOR blink_led NEXT n=65535 led blinks 65535x n=25 led blnks 25x n=1 led blinks 1x n=0 led does not blink Igor ______________________________________________________________ > Od: om1zz <om...@vo...> > Komu: <fla...@li...> > Datum: 26.05.2015 13:12 > Předmět: Re: [Flashforth-devel]For-next loop - full 16bit count? > >corrected: >uint16 joe; >uint32 count = 0; >... > >Your suggested scenario > >>Therefore it has work like this >>2 for ---> 2 1 0 (3 counts) >>0 for ---> 0 ( 1 counts) >>65535 for ---> 65535 65534 .. 0 (65536 counts) > >is quite a novel approach, indeed, but not sure if it would be easy to understand by people like me :) > >Igor > >______________________________________________________________ >> Od: "om1zz" <om...@vo...> >> Komu: <fla...@li...> >> Datum: 26.05.2015 12:28 >> Předmět: Re: [Flashforth-devel] For-next loop - full 16bit count? >> >>A loop with "decrement and skip if zero" construct in asm means condition evaluation and action around "next"- like this (an example code): >> >>uint16 joe; >>uint16 count = 0; >> >>joe = 2; >> >>for_loop: >> >>blink_a_led; >> >>count = count + 1; >> >>/ / decrement and skip if zero test >>joe = joe - 1; /// decrement >>if joe==0 goto out_of_loop // skip if zero >>// end of decrement and skip if zero test >> >>goto for_loop: // this will be skipped when zero >> >>out_of_loop: >> >>print count; >> >>end >> >>With joe=2 the count will be 2, with joe=0 the count will be 65536. >> >>Igor >> >>______________________________________________________________ >>> Od: Mikael Nordman <mik...@fl...> >>> Komu: <fla...@li...> >>> Datum: 26.05.2015 11:51 >>> Předmět: Re: [Flashforth-devel] For-next loop - full 16bit count? >>> >>>If you do a decrement and skip if zero, it means that one index will >>>not be counted (=0). >>>So you would not get the full 16-bit range. >>>2 for ---> 2 1 (2 counts) >>>1 for ---> 1 ( 1 counts) >>>0 for ---> 65535 65534 .. 1 (65535 counts) >>> >>>So my NEXT uses decrement and skip if carry >>> >>>Therefore it has work like this >>>2 for ---> 2 1 0 (3 counts) >>>0 for ---> 0 ( 1 counts) >>>65535 for ---> 65535 65534 .. 0 (65536 counts) >>> >>>BR Mike >>> >>> >>>On 26.05.2015 11:21, om1zz wrote: >>>> Some reasoning to mu suggestion below: >>>> 1. we talking here forth - a better macro assembler >>>> 2. with your scenario we move towards a primitive function with "more >>>> intelligence" than one would expected from a better assembler.. >>>> 3. imho for-next in forth is an equivalent of "decrement and skip if >>>> zero" construct, where (at least me since '82) observed the behaviour >>>> when putting zero in it loops for a lot of times around :) >>>> Igor >>>> >>>>>Hmm, the old FOR shall behave, I think: >>>>> >>>>>2 for ---> 1 0 (2 counts) >>>>>0 for ----> 65535 65534 .. 0 (65536 counts) >>>>> >>>>>new ?FOR >>>>> >>>>>2 ?for ---> 1 0 (2 counts) >>>>>0 ?for ---> skip (none count) >>>>> >>>>>So no change with 99,99999% of old code. >>>>>I. >>>>> >>>>>______________________________________________________________ >>>>>> Od: Mikael Nordman <mik...@fl...> >>>>>> Komu: <fla...@li...> >>>>>> Datum: 26.05.2015 06:38 >>>>>> Předmět: Re: [Flashforth-devel] For-next loop - full 16bit count? >>>>>> >>>>>>I did some experiments with this and have now two for..next loops >>>>>>: t for r@ u. next ; ok<#,ram> >>>>>>: tt for2 r@ u. next ; ok<#,ram> >>>>>>9 t 8 7 6 5 4 3 2 1 0 ok<#,ram> >>>>>>9 tt 9 8 7 6 5 4 3 2 1 0 ok<#,ram> >>>>>> >>>>>>The only problem is the naming of the words. >>>>>>The old FOR ideally should be called ?FOR >>>>>>and the new one FOR. >>>>>>But that introduces a problem with existing FF code... >>>>>> >>>>>>Mike >>>>>> >>>>>>On 24.05.2015 16:00, om1zz wrote: >>>>>>> Yea, I do understand the zero loop skip intention, but I consider >>>>>>> that a bug. >>>>>>> There is no way to do full 65536 loops with 16bit without doing 0 >>>>>>> for..next. >>>>>>> >>>>>>> As the web knowledge says - there are only incompatible for-next >>>>>>> loops and inefficient and lazy do-loops :) >>>>>>> >>>>>>> I would recommnd to change the behavior to full 16bit, entering 0 >>>>>>> should be the users responsibility (similar as divide by zero). >>>>>> >>> >>> >>>------------------------------------------------------------------------------ >>>One dashboard for servers and applications across Physical-Virtual-Cloud >>>Widest out-of-the-box monitoring support with 50+ applications >>>Performance metrics, stats and reports that give you Actionable Insights >>>Deep dive visibility with transaction tracing using APM Insight. >>>http://ad.doubleclick.net/ddm/clk/290420510;117567292;y >>>_______________________________________________ >>>Flashforth-devel mailing list >>>Fla...@li... >>>https://lists.sourceforge.net/lists/listinfo/flashforth-devel >>> >> > >------------------------------------------------------------------------------ >One dashboard for servers and applications across Physical-Virtual-Cloud >Widest out-of-the-box monitoring support with 50+ applications >Performance metrics, stats and reports that give you Actionable Insights >Deep dive visibility with transaction tracing using APM Insight. >http://ad.doubleclick.net/ddm/clk/290420510;117567292;y >_______________________________________________ >Flashforth-devel mailing list >Fla...@li... >https://lists.sourceforge.net/lists/listinfo/flashforth-devel > |