Comments (6)
A negative value for ALLOT can currently overwrite parts of the original Dictionary.
from taliforth2.
I never realized you could give allot negative values.
I have a bunch of questions:
When you say ALLOT can overwrite parts of the original dictionary, are you talking about the words in forth-words.asc that are compiled into ram on startup?
I see some code checking against cp0, but that's where the transition between the RAM dictionary and the ROM dictionary takes place. Losing that first word with the link seems bad. Does it make any sense to have an empty word there, just to maintain the link, and have allot stop at that word (fixed offset beyond cp0) rather than at cp0?
Do you think adding something like the FENCE variable from fig-forth makes sense?
What is supposed to happen if you allot negative too far? You'll be in the middle of a previous word/variable and writing new stuff will trash things. I'm looking at the standard and it doesn't seem there is any safety on this word. Is the goal, then, to just have Tali attempt to survive and keep going the best it can with a possibly damaged dictionary?
from taliforth2.
Yeah, negative ALLOT threw me as well, but it's in the standard -- https://forth-standard.org/standard/core/ALLOT -- amusingly, though, it says "( MISSING TEST: NEGATIVE ALLOT )" as well. The ANSI Forth standard is rather rough around the edges in some places, which could partially be because a lot of people didn't like the whole idea of a standard version of the language. Also, since there is no traditional lexer and parser, nobody is forced to sit down and really map everything out.
I've handled those cases by a) seeing what Gforth does, because they give the impression they know what they are doing, and if that doesn't work, b) do what seems sane and document it.
The definition of ALLOT in Gforth is
: allot here + dup 1- usable-dictionary-end forthstart within -8 and throw dp ! ;
which I figure means: add the number given to HERE, see if it is still between the end of the "usable dictionary" and the beginning of the Forth area, and if not, throw an error.
In our case, I had thought about using a MARKER, say "Forth", as the last high-level word defined at boot. That way, ALLOT would only be allowed to go back to where the "Forth" mark lives in the Dictionary. That would be our version of "usable-dictionary-end", and for "forthstart" we'd use where the buffers for the command line history start. However, I haven't tested MARKER yet, and the one time I used it, it exploded in my face, but that was early days.
from taliforth2.
A bit of experimenting with Gforth gives the following behavior for negative ALLOT if the freed space is still above the original Compiler Pointer (cp0): Any word defined in that space will work as long as nothing new is added, but then if you do store something at the new CP, those words affected will crash. In other words, the Dictionary Pointer is not changed.
from taliforth2.
Interestingly, Gforth lets you free all kinds of space beyond the initial HERE address with no apparent ill effects to the Dictionary -- right off the bat you can do -1000 ALLOT and it won't phase Gforth the least. Huh.
from taliforth2.
So. My first instinct was to say, this is Forth, the users are supposed to be adults, and if they want to free memory all the way into the Dictionary, who are we to tell them not to?
However, the problem is that we're going to have people using Tali to test stuff on an emulator before the move to their own hardware. Since py65 (for example) does not protect the ROM parts of memory from overwriting, we could cause hard-to-explain differences between emulation and hardware. Also, I'd like the system to be stable enough to survive something like this at least in a minimal usable state (enough to run COLD maybe).
My suggestion therefore: We let the user crash and burn in the RAM area that is assigned to the Dictionary (up to CP0, which is $0300). If the user goes beyond that, we set the new CP to CP0 (which we already do), have DP point to the last word defined in ROM (DROP), and print an error. And document all of this.
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.