home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 116,262 of 117,927   
   Krishna Myneni to Krishna Myneni   
   Re: Forth systems where do/?do pushes th   
   04 Mar 24 22:57:09   
   
   From: krishna.myneni@ccreweb.org   
      
   On 3/4/24 22:54, Krishna Myneni wrote:   
   > On 3/4/24 11:24, Anton Ertl wrote:   
   >> Many years ago I have read here about Forth systems where DO and ?DO   
   >> push three items on the return stack: the two values from the data   
   >> stack (initial index and limit) like many other Forth systems, but in   
   >> addition they also push the address that LOOP/+LOOP later jumps to.   
   >>   
   >> I used to consider this to be inefficient, but it turns out that in an   
   >> efficient interpreter-based Forth system like, say gforth-fast from   
   >> 2022 it would actually be more efficient than compiling that address   
   >> with the (LOOP)/(+LOOP) and loading it from there.   
   >>   
   >> My question is: Which Forth systems have a DO/?DO that pushes the   
   >> address that LOOP/+LOOP then jumps to?   
   >>   
   >> - anton   
   >   
   > Yes, kForth uses this method. DO pushes three items onto the return   
   > stack, the two loop parameters, and the virtual instruction pointer.   
   >   
   > \ From ForthVM.cpp   
   >   
   > int CPP_do ()   
   > {   
   >    // stack: ( -- | generate opcodes for beginning of loop structure )   
   >   
   >    pCurrentOps->push_back(OP_PUSH);   
   >    pCurrentOps->push_back(OP_PUSH);   
   >    pCurrentOps->push_back(OP_PUSHIP);   
   >   
   >    dostack.push(pCurrentOps->size());   
   >    return 0;   
   > }   
   >   
      
   To be clear, DO compiles three VM instructions to push the items onto   
   the return stack.   
      
   --   
   Krishna   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca