Show the return stack

654 views Asked by At

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.

2

There are 2 answers

1
Lehs On BEST ANSWER

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 ;
0
Lars Brinkhoff On

There's no such word in ANS Forth.

As for Gforth, there is the word bt since late 2012.