Let's write another tutorial (I'm just in the mood today) Anyway, this'll talk about the VAT, specifically, the symbol table of the calculator where programs, appvars, and protected programs are found. Ever wonder how Axe displays a list of all the Axe programs on your calculator? Well, read on!
1. What is the VAT? (By VAT, I actually mean program table, even though that's not really what VAT means)
The VAT is a chunk of user RAM that keeps track of every program/prot prog and appvar in your calc. If you notice, when you delete a program in archive, you still free up some RAM; that program's table entry is erased.
Every entry in the VAT is backwards (annoying), and structured in the following manner:
1 2 3 4 5
| ============================================== | -(n+6) -6 -5 -4 -3 -2 -1 0 | ============================================== | VarName N.Len Page DadrH DadrL Ver T2 T | ============================================== |
Now for an explanation of each part:
T: Sort of important but not really: the first five bits are used to identify which object type the variable is. We'll get into this later.
T2: Completely useless to us. Ignore.
Ver: Tells the OS whether or not it can be sent across certain OSs. Ignore.
DadrL: More important: Tells us the low byte of the address of this object.
DadrH: The high byte
Page: What flash page? If in RAM, it'll equal 0.
N. Len: How long is the name
And from here, we have the name of the object (backwards)
Now, the location of the VAT is always changing. Fortunately the calculator stores it for us at address $9830. The address of the end of the VAT is stored in $982E.
Here's a code example on how to set up a loop that goes through the VAT, one entry at a time...
1 2 3 4 5 6 7 8
| {e9830}^^r->E //set up While E>{e982E}^^r //While we're in the VAT For(F,0,14) //Copy backwards to L1. For some reason I couldn't get Copy()r to work... {E-F}->{F+L1} End ...stuff. Now you have your VAT entry sitting in L1...do what you want with it. E-{L1+6}-7->E //Increment the pointer "position" appropriately. Every entry is a different length, depending on the name length. End |
Now, you can use the value of {L1+3}
r+2 as a pointer to the object without even needing a GetCalc statement. This even works with file pointers as well, storing {L1+3}
r+2 to {
oY1}
r and {L1+5} to {
oY1+2} allows you to use Y1 normally as well.