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,276 of 117,927    |
|    Ruvim to Anton Ertl    |
|    Re: Forth systems where do/?do pushes th    |
|    06 Mar 24 17:28:45    |
      From: ruvim.pinka@gmail.com              On 2024-03-04 21: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?                     In SP-Forth v3 and v4 (they generate native code), "DO" pushes three       items on the return stack, and among them the address that "LEAVE" then       jumps to. The address (actually, an offset) for "LOOP" is inlined.                     Code in SP-Forth/4              : foo 7 1 do i . loop ; see foo              579793 8945FC MOV FC [EBP] , EAX       579796 C745F807000000 MOV F8 [EBP] , # 7       57979D B801000000 MOV EAX , # 1       5797A2 8BD8 MOV EBX , EAX       5797A4 81C000000080 ADD EAX , # 80000000       5797AA 2B45F8 SUB EAX , F8 [EBP]       5797AD 8BD0 MOV EDX , EAX       5797AF 8B45FC MOV EAX , FC [EBP]       5797B2 68D7975700 PUSH , # 5797D7       5797B7 52 PUSH EDX       5797B8 53 PUSH EBX       5797B9 90 XCHG EAX, EAX       5797BA 90 XCHG EAX, EAX       5797BB 90 XCHG EAX, EAX       5797BC 8945FC MOV FC [EBP] , EAX       5797BF 8B0424 MOV EAX , [ESP]       5797C2 8D6DFC LEA EBP , FC [EBP]       5797C5 E81ECDFDFF CALL 5564E8 ( . )       5797CA FF0424 INC [ESP]       5797CD FF442404 INC 4 [ESP]       5797D1 71E9 JNO 5797BC       5797D3 8D64240C LEA ESP , C [ESP]       5797D7 C3 RET NEAR       END-CODE                     --       Ruvim              --- 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