@Klaus:
Quote:
1. Change the operator decode from a chain to a tree style.
VTL is currently decoding operators one at a time with the last possible operator being the default operator. One could order the operators by their ASCII value and start in the middle, then in the middle of both halves and so on. This also means, that there is not just one default operator but many depending on which side of the tree the operator is. Bringing it back to a single default operator would require additional compares and branches.
2. Add a statement separator to allow multiple statements in a line.
This would allow for tighter loops as you can go back to the same line number with the last statement (#=) in the line not having to comb through the program for a different line number. Also VTL would have to comb through less lines in overall tighter code to find the target of a #= statement.
I like your ideas, and I can cautiously state that I could try implementing both of these within the 1KB limit. I know that it might be a silly notion, but I really like the <1KB "feature", and would like to keep it for narcissistic reasons. Regarding
#= ... you may have noticed that a statement like
50 #=50 will not loop, because the interpreter only branches if
# actually changes.
Quote:
3. Store constants in the program as 16-bit binaries.
As you said before a lot of run time is devoted to converting the constants in the program over and over again. The unused bit 7 of the preceeding operator could be used to signal wether the following byte or bytes is a variable or are a binary constant.
This could provide a performance boost, but would require some extra effort during program (line) insertion, because a binary two-byte constant can be represented by one to five ASCII characters, requiring some adjustments to the remainder of the line, as well as slightly complicating the program listing feature. It is certainly doable, but its benefits could also be enjoyed by assigning the constants to variables at run-time initialization, as you did with your revised prime number generator program.
Quote:
4. Add a go to cache or other means to improve #= performance.
I am rather vague here as I have no idea how this could be achieved. The problem is, that VTL allows fuzzy line numbers even in variables (#=! for example) and the program continues with the next higher valid line number.
This would be awesome, and I feel (without actually knowing) that backwards branches are where the interpreter spends most of its time, especially in larger programs. I don't think that I have the talent to pull it off, though.
Quote:
5. Add operator(s) to replace a multiply in a go to statement
A simple compare 0 or >= 1 should outperform the currently required multiply. I call them the "then" or "else" operator and would even work on a bit map as the possible input is not limited to 0 or 1. A limitation of course would be, that the condition has to be evaluated on the left side of the operator and the line number must be on the right side of the operator. In a "then" statement the result would be identical to a multiply with 1 or 0 while "else" would reverse the result (like an xor 1 prior to the compare).
Another good point, although I would be concerned about breaking existing programs by doing something like making "true" as 65535 and using OR [edit: I mean AND] instead of *. I do think that I can play with my multiply and make it much faster if one of the multiplicands is a one or a zero, and that should help performance without sacrificing backwards-compatibility.
Quote:
6. Add shift operators.
Now this is just a very low priority issue as there is a performance gain over shifting by multiplying or dividing, but I think shifts will rarely be needed. It may just supplement the logical operators.
I'll have to think about that.
Quote:
7. Revisit some of the space saving changes.
The add routine as an example:
[ ... snip ... ]
Tuning for space takes a toll, sometimes a very big toll. Of course this is not a representative sample. The overall VTL code is still very fast. This is just a reminder, that code density is not everything.
You're correct, of course. I often suffer from a one-track mind.
Quote:
P.S.: I just ran my prime number program for 1000 primes on my emulator (~2MHz) and compared the performance. VTL02A = 72 seconds, VTL02B = 85 seconds
I don't have an easy way to prove it, but I think that the new space-skipping feature is the significant factor in the measured slow-down, not the other changes. It would take a bit of effort to prove it.
Thank you for your help.
@Mario:
Liked!
Mike B.
P.S. In light of Klaus' performance report, I'm going to in-line all instances of space-skipping, add six bytes to
mul: to improve performance for small multipliers, add one byte back to
plus:, and take a long hard look at
find: ... my gut tells me that speed improvements in these four areas will provide the highest overall performance benefits. I'll report back when I complete the experiment.