figForth Word - DO

  Some parts of this page/site are currently incomplete & will be updated asap
  Other parts will change continually so use “Refresh” in your browser !!
  There is extensive use of “Tooltips” text to support learning which do
not seem to render on a Smartphone


DO n1 n2 — (execute) addr n — (compile) P,C2,L0 Occurs in a colon-definition in form: DO … LOOP

DO … +LOOP At run time, DO begins a sequence with repetitive execution controlled by a loop limit n1 and an index with initial value n2. DO removes these from the stack. Upon reaching LOOP the index is incremented by one. Until the new index equals or exceeds the limit, execution loops back to just after DO; otherwise the loop parameters are discarded and execution continues ahead. Both n1 and n2 are determined at run-time and may be the result of other operations. Within a loop ‘I’ will copy the current value of the index to the stack. See I, LOOP, +LOOP, LEAVE. When compiling within the colon definition, DO compiles (DO), leaves the following address addr and n for later error checking

NFA:    00737C C2            DB   0C2H
        00737D 44            DB   "D"
        00737E CF            DB   'O'+80H
LFA:    00737F 6173          DW   THEN-7
CFA:    007381 3C28      DO: DW   DOCOL     ;   :
PFA:    007383 0B6B          DW   COMP      ;   COMPILE
        007385 3622          DW   XDO       ;   (DO)
        007387 0769          DW   HERE      ;   HERE
        007389 CB67          DW   THREE     ;   3
        00738B 1725          DW   SEMIS     ;   ;

The Meaning of the Dictionary Fields:

NFALFACFAPFA

    NFA:    00222F 84           DB   84H
            002230 28444F       DB   "(DO"
            002233 A9           DB   ')'+80H
    LFA:    002234 1F22         DW   XPLOO-10
    CFA:    002236 3822   XDO:  DW   $+2
    PFA:    002238 2AFBFF       LD   HL,(RPP)
            00223B 2B           DEC  HL
            00223C 2B           DEC  HL
            00223D 2B           DEC  HL
            00223E 2B           DEC  HL
            00223F 22FBFF       LD   (RPP),HL
            002242 D1           POP  DE
            002243 73           LD   (HL),E
            002244 23           INC  HL
            002245 72           LD   (HL),D
            002246 D1           POP  DE
            002247 23           INC  HL
            002248 73           LD   (HL),E
            002249 23           INC  HL
            00224A 72           LD   (HL),D
            00224B C3 E2 20     JP   NEXT

Updated: 30th August 2022 by David Husband
© 2021 David Husband, a.k.a. Baremetal Engineer Extraordinaire
All Rights Reserved – All Trademarks & Copyrights Acknowledged
All personal information is subject to the Data Protection Act 2018 & the UK GDPR
“ad auxilium aliis ad auxilium sibi”