Re: [Flashforth-devel] For-next loop - full 16bit count?
Brought to you by:
oh2aun
From: Mikael N. <mik...@fl...> - 2015-05-26 14:07:05
|
I added printing of the index to your pseudocode. So 2 for r@ u. next prints 2 1 And 0 for r@ u. next prints 0 65535 .... 1 So will also your pseudocode below, but I want 65535 for r@ u. next prints 65535 .... 0 This is what I have implemented in the FOR2 You can pull it from git. BR Mike uint16 index; uint16 count = 0; index = 2; for_loop: blink_a_led; count = count + 1; print index; <----------------NOTE / / decrement and skip if zero test index = index - 1; /// decrement if index==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; On 26.05.2015 13:28, om1zz wrote: > 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 > |