Search code examples
forthgforth

Show the return stack


Can you show the return stack in Forth?

.S shows the parameter stack. Is there a similar word showing the contents of the return stack?

I found SHOWSTACK on the web, but it does't work.


Solution

  • I think you could use this code if you are curious about the return stack:

    : RTEST RP@ DUP >R RP@ RDROP SWAP - ;
    
    RTEST CONSTANT RSTEP
    RP@ CONSTANT RBIAS
    
    : .RETURNSTACK \ --
      RP@ RBIAS 
      DO I @ U. RSTEP
      +LOOP CR ;