Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRACE of words with 2>R and 2R> is wrong. #162

Closed
izuk opened this issue May 5, 2024 · 5 comments · Fixed by #163
Closed

TRACE of words with 2>R and 2R> is wrong. #162

izuk opened this issue May 5, 2024 · 5 comments · Fixed by #163
Assignees

Comments

@izuk
Copy link

izuk commented May 5, 2024

See:

['] 2>R OF trace.>r trace.>r ENDOF

I think there should be a swap there.

@philburk
Copy link
Owner

philburk commented May 11, 2024

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> ?

@philburk
Copy link
Owner

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.

@philburk
Copy link
Owner

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.

philburk added a commit that referenced this issue May 11, 2024
They needed a SWAP to match the kernel versions.

Fixes #162
@philburk
Copy link
Owner

@izuk - Thanks for the bug report. Does #163 look OK?

@izuk
Copy link
Author

izuk commented May 11, 2024

LGTM

philburk added a commit that referenced this issue May 12, 2024
They needed a SWAP to match the kernel versions.

Fixes #162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants