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

Nested loop in temporary definition causes exception -60 (FREE). #7

Closed
mgcaret opened this issue Jan 6, 2020 · 3 comments
Closed

Comments

@mgcaret
Copy link
Owner

mgcaret commented Jan 6, 2020

3 0 do i . loop 
0 1 2  OK
3 0 do 3 0 do i . j . loop loop
 Exception #-60 
@mgcaret
Copy link
Owner Author

mgcaret commented Jan 6, 2020

Works fine from normal definition

: test 3 0 do 3 0 do i . j . loop loop ;
test
0 0 1 0 2 0 0 1 1 1 2 1 0 2 1 2 2 2  OK

Also works inside quotations:

: test1 [: 3 0 do 3 0 do i . j . loop loop ;] execute ;
 OK
test1
0 0 1 0 2 0 0 1 1 1 2 1 0 2 1 2 2 2  OK

@mgcaret
Copy link
Owner Author

mgcaret commented Jan 6, 2020

For some reason, the first LOOP is eating way more than its fair share of entries from the stack.

showstack
{ 0 : } OK
3 0 do 
Starting temp def... { 5 : 3 0 81FD7B 81FD7B 81FD84 } [OK]
3 0 do
{ 6 : 3 0 81FD7B 81FD7B 81FD84 81FD98 } [OK]
loop
{ 3 : 3 0 81FD7B } [OK]
loop
Ending temp def... { 4 : 3 0 2 4 } Exception #-60 
clear
{ 0 : } OK
3 0 do
Starting temp def... { 5 : 3 0 81FD7B 81FD7B 81FD84 } [OK]
3 0 do
{ 6 : 3 0 81FD7B 81FD7B 81FD84 81FD98 } [OK]
loop
{ 3 : 3 0 81FD7B } [OK]
[ 81FD7B 81FD84 ]
{ 5 : 3 0 81FD7B 81FD7B 81FD84 } [OK]
loop
Ending temp def... { 6 : 3 0 81FD7B 81FD7B 4 4 }{ 0 : } OK

@mgcaret
Copy link
Owner Author

mgcaret commented Jan 6, 2020

Ohh lookie here..

dosemi:   .dword DEPTH            ; ( -- u1 )
          .dword dCSDEPTH         ; ( u1 -- u1 c-addr1 ) verify stack depth is what it should be
          .dword FETCH            ; ( u1 c-addr1 -- u1 u2 )
          .dword ULTE             ; ( u1 u2 -- f ) is less than or equal to?
          .dword _IFFALSE         ; ( f -- )
          .dword tmpdone          ; true branch, finish up temp def
          .dword TWODROP    ; <<<<< WTF IS THIS DOING HERE? [comment not in source]
notmp:    EXIT

@mgcaret mgcaret closed this as completed in 4f41c94 Jan 6, 2020
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

No branches or pull requests

1 participant