Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #134716

RTUCK

Newsgroups comp.lang.forth
From albert@spenarnc.xs4all.nl
Subject RTUCK
Message-ID <nnd$17c84e15$6375b90d@a7e18c8a20cb4588> (permalink)
Organization KPN B.V.
Date 2026-03-17 15:31 +0100

Show all headers | View raw


I recall the definition of coroutine call:

CO  :
Return to the caller, suspending interpretation of the current
definition, such that when the caller exits, this definition is
resumed

HEX: " temparily switch to HEX for the duration of the current
definition."

A typical use of HEX: is as follows

( print BYTE in hex )
 : B.  HEX: S>D <# # # #>   TYPE ;
 ( print SINGLE in hex )
     : 4?  1+ 4 MOD 0= IF &, HOLD THEN ; \ print &, at regular intervals.
 : H.  HEX: S>D <# 2 CELLS 1- 0 DO # I 4? LOOP # #>   TYPE ;
 (  print DOUBLE in hex )
 : DH. HEX: <# 4 CELLS 1- 0 DO # I 4? LOOP # #>   TYPE ;

HEX: is an example use of the use of CO (coroutine).
VARIABLE BASE-TEMP
: HEX:
    BASE @ BASE-TEMP !
    HEX CO
    BASE-TEMP @ BASE !
;
This is ugly so you are tempted to do

: HEX:
    BASE @ >R
    HEX CO
    R> BASE !
;
This doesn't work. The return address is in the way,
assuming there is a return address on the stack.
This also makes the code implementation dependant.
(Marcel Hendrix's  >S and S> however would work.)

: HEX:
    R>   BASE @ >R   >R
    HEX CO
    R> BASE !
;

I hate TUCK ( a b -- b a b )
but I like RTUCK
"save the top of the stack under the return address of a high
level word."

: HEX:
    BASE @ RTUCK
    HEX CO
    R> BASE !
;

Groetjes Albert
-- 
The Chinese government is satisfied with its military superiority over USA.
The next 5 year plan has as primary goal to advance life expectancy
over 80 years, like Western Europe.

Back to comp.lang.forth | Previous | NextNext in thread | Find similar


Thread

RTUCK albert@spenarnc.xs4all.nl - 2026-03-17 15:31 +0100
  Re: RTUCK Hans Bezemer <the.beez.speaks@gmail.com> - 2026-03-17 16:10 +0100
  Re: RTUCK dxf <dxforth@gmail.com> - 2026-03-18 04:36 +1100
    Re: RTUCK albert@spenarnc.xs4all.nl - 2026-03-18 12:47 +0100
      Re: RTUCK dxf <dxforth@gmail.com> - 2026-03-19 11:51 +1100
        Re: RTUCK dxf <dxforth@gmail.com> - 2026-03-19 14:50 +1100
          Re: RTUCK albert@spenarnc.xs4all.nl - 2026-03-19 12:16 +0100
      Re: RTUCK Hans Bezemer <the.beez.speaks@gmail.com> - 2026-03-19 18:52 +0100
        Re: RTUCK thresh3@fastmail.com (Lev) - 2026-03-19 13:38 -0500
          Re: RTUCK Paul Rubin <no.email@nospam.invalid> - 2026-03-19 16:16 -0700
            Re: RTUCK thresh3@fastmail.com (Lev) - 2026-03-19 23:17 +0000
            Re: RTUCK thresh3@fastmail.com (Lev) - 2026-03-19 20:18 -0500
          Re: RTUCK albert@spenarnc.xs4all.nl - 2026-03-20 12:34 +0100
        Re: RTUCK albert@spenarnc.xs4all.nl - 2026-03-20 12:14 +0100
  Re: RTUCK Paul Rubin <no.email@nospam.invalid> - 2026-03-21 02:31 -0700
    Re: RTUCK minforth <minforth@gmx.net> - 2026-03-21 11:43 +0100
    Re: RTUCK albert@spenarnc.xs4all.nl - 2026-03-21 12:59 +0100
      Re: RTUCK albert@spenarnc.xs4all.nl - 2026-03-22 13:27 +0100

csiph-web