Closed izuk closed 5 months ago
I did an experiment.
: FOO 2>R 2R> ; ok
11 22 foo .s 0sp
That printed "11 22" in the original order. Then I tried TRACE.
11 22 trace foo
<< FOO +0 <10:2> 11 22 || 2>R >> ok
s
<< FOO +8 <10:0> || 2R> >> ok
s
<< FOO +16 <10:2> 11 22 || EXIT >> ok
So it behaves the same and puts "11 22" back on the stack.
THEN I defined:
: GOO >r >r 2R> ;
When I execute it normally it swaps the two values. When I execute it using TRACE it does NOT swap. So that is different.
What is the expected behavior for 2R> ?
According to the ANSI spec at https://forth-standard.org/standard/core/TwoRfrom
2>R should be equivalent to "R> R> SWAP".
So I believe that the pForth kernel version of 2>R and 2R> is correct and the TRACE version is incorrect.
2R@ is also backwards in TRACE
To test:
: T1 swap >r >r 2r@ 2r> ;
0sp 11 22 T1 .s
Should print "11 22 11 22". Then TRACE should do the same:
0SP 11 22 trace T1
Keep entering S until you reach EXIT.
@izuk - Thanks for the bug report. Does #163 look OK?
LGTM
See:
https://github.com/philburk/pforth/blob/6aa808ad3cd326dc7d76ea2b97cef2b100ee8abc/fth/trace.fth#L275
I think there should be a swap there.