Re: Average of a [stack]

Liste des GroupesRevenir à cl forth 
Sujet : Re: Average of a [stack]
De : melahi_ahmed (at) *nospam* yahoo.fr (ahmed)
Groupes : comp.lang.forth
Date : 14. May 2025, 08:07:28
Autres entêtes
Organisation : novaBBS
Message-ID : <cf8d7d8be71f91146788d056b1eb7eab@www.novabbs.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Rocksolid Light
On Wed, 14 May 2025 5:51:35 +0000, anthk wrote:

On 2024-07-11, ahmed <melahi_ahmed@yahoo.fr> wrote:
Thanks for the explanation.
How can I get FOR and NEXT with MinForth? I have MF384.
>
Ahmed
>
In pforth (pfe), that's why I use to test code made for eforth:
>
: >MARK ( --A ) HERE 0 , ;
: AHEAD ( --A ) COMPILE branch >MARK ; IMMEDIATE
: AFT ( a --a A ) DROP [COMPILE] AHEAD [COMPILE] BEGIN SWAP ; IMMEDIATE
>
: FOR ( RUNTIME: N -- )
        COMPILE ABS  \ NO NEGATIVES
        COMPILE LIT 0 , COMPILE SWAP
        [COMPILE] ?DO ; IMMEDIATE
>
: NEXT
        COMPILE LIT -1 ,
        [COMPILE] +LOOP ; IMMEDIATE
Thanks.
I've already defined for and next in MinForth like this:
 : (0) 0 ;
 : (-1) -1 ;
 : for_ postpone (0) postpone swap postpone ?do ; immediate
 : _next postpone (-1) postpone +loop ; immediate
and here is an example of use:
 : go_ 10 for_ i . _next ;
 go_  10 9 8 7 6 5 4 3 2 1 0  ok
Ahmed
--

Date Sujet#  Auteur
11 Jul 24 o Re: Average of a [stack]12ahmed

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal