TinyBASIC: Variables, Memory, and Expansion

In my last blog post I shared that I have managed to integrate TinyBASIC into my monitor for the G80-S in a ‘mostly stable’ way. Now that has progressed from mostly stable to very stable. But further, the IN instruction has been revised to use variables. Which is quite handy, as it allows the programmer to not only write to I/O, but to also read from it, and make branches in his/her program as a result of those reads.

This is a big step, as it is the basis for other routines that can expand on the original TinyBASIC source code. Routines such as PEEK or POKE may need to use variables, and the ability to use variables to OUT to I/O is also important from a programmers viewpoint. And these routines just simply were not included in the original source, and I desire to have them available in my software. So as such, I’m further modifying TinyBASIC as I see fit.  And yes, when it is done I will release it into the wild.

Variables in TinyBASIC are straight forward once you understand them. To read from or write to a variable one simple needs to understand that they are nothing more than a predefined area of memory, and that they have a given structure.

This area of memory is defined as VARBGN in the TinyBASIC source. And in my personal example of code resides in 55 bytes of data starting from 0xFF00. Now, each variable is broken into two (2) bytes. However, they are not organized as you would assume, with the MSB being first, and the LSB being second (i.e. the way one would read the memory if layed out in from of him). No, TinyBASIC addresses variables just like the z80 addresses memory. I.e. if we refer to location FF88 in memory it will be listed as 88FF. Likewise, if we refer to a variable (for the sake of examples let say it is listed as 01h) in memory, it will be addressed like this:  01h 00h.  Strange, but ok.

Further, the first address of the variables is not ‘A’. I believe that it is ‘@‘ which I also believe is a pointer. But I have not confirmed this. One step at a time…

Now, this means that if we want to use variables it is as simple as figuring out which variable we want to use, and reading from or writing to that area of memory. Simple right!

As a result I have rewritten the IN instruction so that it now operates as a tool for loading a given variable for use by the program. It can be used in the following ways:

IN hh V
IN hh,V
IN hh=V
IN hhV

Where ‘hh’ is the port to write to in Hexadecimal, and V is the Variable ranging from ‘A’ to ‘Z’.

I’m still working on patching the OUT instruction to use variables. Sometimes the best way to solve a problem is to step back and let your eyes rest. And that is where I am at currently. I needed to step back until my eyes are fresh. But as of right now it can output a byte to a port.

The rest of the functions are still a work in progress. I have added a CLS function that can be used either direct or within code. I have also added a QUIT function which serves to exit TinyBASIC. So it is coming along.

Overall, my work on expanding TinyBASIC to be more usable, while maintaining a small foorprint, is progressing at a pleasing rate. And while this project centered around my G80-S computer, need is the mother of invention.  And as a result I will release the source once I decide that it is complete enough for release.

But for now, I leave you curious…

Leave a Reply

Your email address will not be published. Required fields are marked *