>>9518
> no stack commentsA valid point. They're not there because a lot of operations are similar (read-modify-store), so I managed to keep it all in my head. I can see how that would be difficult for people who do not possess my head though, or when my head has forgotten what it thought of.
> the cf that is compile-bracerunnerI'm pretty new wrt forth macros
di@ 0= if 1 [ ' cii compile-bracerunner ] then
which is run when the current instruction is '[', becomes
di@ 0= if \ if the current memory cell is 0, skip until matching closing brace
1 begin \ ctr=1 seed the counter with 1, since we begin on a '['
cii ci@ \ ctr instr go to the next instruction and read it
dup '[ = if \ check what the instruction is - probably be case of should be using case
swap 1+ swap \ ctr+1 instr '[' - increase the counter
else \
dup '] = if \
swap 1- swap \ ctr-1 instr ']' - decrease the counter
then \
then \
drop \ ctr instruction testing done, drop it from the stack
dup 0= until \ ctr loop until the counter reaches 0 = we have reached '['-']'-balance
then
The act of putting it in a macro like that is so that it can be done with both cii and cid as the word that changes
code position, depending on if we want to walk forwards or backwards in the code. A non-macro variant could be putting everything except cii that's inside the begin-until loop into a regular word and have the line in interpretchar look like
di@ 0= if 1 begin cii runtime-bracerunner until then
...but that's less fun, also I didn't think of it before. Actually, during development I initially planned on macrofying even more
so that the line would be something like
[ ' cii 1 ' 0= compiletime-evenmoreconvoluted-bracerunner ]
but I gave up that when I noticed how postponing stuff polluted the data stack.
I see now also that the instruction testing and counter modifying could have been written as
dup '[ = if \ ctr instr
drop 1+ \ ctr+1
else \ ctr instr
dup '] = if \ ctr instr
drop 1- \ ctr-1
else \ ctr instr
drop \ ctr
then \ ctr
then
> case, eraseI need to read more, instead of just plodding along with the words I already know.
> memory protectionIt does actually exist, although not in the access words di@/!, but in the words that change the pointer (dii/d) in which after increasing or decreasing the pointer value, the result is and-ed with the size of the array (dn) - 1, which is the same as doing the modulo action as long as the array size is kept to a power of two.
> more descriptive word namesb-but isn't it obvious that it means code/data - index - increase/decrease ...hm perhaps it isn't