Comments (4)
I'm trying to understand this bug, but I don't have a super clear picture of how do ... loop works.
It looks like your version copies a chunk of assembly directly into the dictionary (rather than jsr this and jsr that) to actually perform the work needed to make do and ?do work, and it looks like ?do has its own version of this assembly (which makes sense to me so far.)
Original Flawed Understanding
I believe the issue is that the current code uses an rts at the end of question_do_runtime (line 2363 in native_words.asm). In my current understanding, this rts will end the currently-being-compiled word because we never jsr'd into another word.
What should happen is a jump to some later point in this same dictionary definition where the word LOOP (or +LOOP) shows up, but that location isn't available yet, so some assembly-fu will be required to make it work. The reference to LDA/PHA and dummy bytes back up in the do_common code sounds like such assembly-fu. Perhaps a push-push-rts is used as a jump?
New Understanding
I've read your loops.txt from Tali1 (still referenced in the assembly for Tali2, and I believe still relevant.)
It looks like question_do_runtime is trying to do the right thing. The address of the top of the loop and the address of the end of the loop should be on the RETURN stack. I had originally missed the fact that these were held on the RETURN stack. You do two PLA instructions to remove the address of the top of the loop, and then use RTS to jump to the address of the end of the loop.
Conclusion
It looks like this will take some time in the simulator tracing step by step to figure out. It's quite mind-bending (in a good way) because some of the code is being run during compilation (when forward addresses are not known yet), but some of the code runs at runtime (where the forward addresses have already sneakily been filled in by the compile-time code run at the end of the loop). If/when I have some free time, I may check this out in the simulator, but I don't think I know enough yet to figure out the bug.
from taliforth2.
I believe the runtime for ?do was pulling off the return stack the very address it should be going to when it discovers the start/end values are equal. I've commented out the two PLA instructions and it seems to be working now. See #41 for my solution.
from taliforth2.
I can confirm the bug, and that it was already present in Tali Forth 1 (always depressing). Running your test snippet in Gforth produces the correct behavior. Will try to get to the fix later on, thx!
from taliforth2.
You fix, ah, seems to have fixed it. Thanks!
from taliforth2.
Related Issues (20)
- Suggestions for making Tali easier to port to new hardware HOT 7
- Move documentation to Sphinx / Read the Docs HOT 1
- fragmented or limited zero page space HOT 2
- Add support for files as an input source HOT 3
- Makefile and Building on Windows needs some work HOT 1
- Documentation Error in THRU (looks like it's my fault)
- User's output routine must leave char in A HOT 1
- Figure out which assembler to switch to HOT 22
- Create script to autoconvert Ophis code to new assembler HOT 1
- Rewrite Tali as-is with 64tass as new assembler HOT 2
- Oopsie in documentation folder HOT 1
- Make user-words.fs platform specific HOT 2
- Restructure repo for two asssemblers HOT 2
- Number Constants HOT 1
- Makefile needs to be updated for .PRG output (eg. 24K images) HOT 2
- The documentation needs to be updated for 64tass HOT 2
- bytes-vs-string issue in utils/console.py HOT 1
- All assembler mnemonics need to be marked NN HOT 1
- xt_words doesn't respect max line length correctly HOT 3
- Strange RTS behaviour HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from taliforth2.