This lesson will give you an introduction to the memory inside the TI-82. It will also teach you some interesting memory areas that will be useful when programming.
This lesson is necessary to understand the next lessons of the Programming Guide.
Memory Map |
TI-82 RAM |
Useful Areas in System RAM
The Z80 can access $FFFF addresses, which means 64K ($FFFF=16^4=65536 bytes=64 Kbytes). But as you might already know, the TI-82 ROM is 128K and the RAM is 32K. That's 160K together and therefor too much for the Z80.
The processor will never be able to access all of this at the same time.
The solution in the case of the TI-82 is as following: The RAM is *ALWAYS* available from addresses $8000 to $FFFF.
The other 32K that is addressable is split in two parts of 16K. The ROM is divided into 8 pages of 16K which are numbered from 0-7.
The addresses $0000-$3FFF always point to the first rom page (rom page 0) which contains the most used functions.
The addresses $4000-$7FFF can point to different rom pages. This means that the data at $4000 can be different from time to time.
Switching between ROM pages is done by sending commands to a cretain output port on the TI-82. But most of the time, you won't want to change the ROM page.
More info on ports can be found in Lesson 16
The ROM isn't that interesting to us, because we can't write programs or data in it, so lets take a closer look to the RAM:
As you possibly could expect, part of the RAM is used for system variables(The normal TI-OS needs to store it's data somewhere, doesn't it?). This includes 6 OP-variables of 11 bytes each (OP1-OP6) and a buffer to store what is on the text screen plus a shadow buffer, both $80 (128) bytes (TEXT_MEM and TEXT_MEM2).
The OP-vars are used to store temporary results when the normal TI-OS is executing calculations.
There are also 2 buffers of 768 bytes to store what is on the graph screen (GRAPH_MEM and APD_BUF).
All these memory areas are save to be used by assembly programmers to store their data (when you write a game, you need to save the score somewhere, don't you ?).
Next to all these memory areas in the system memory, you can also save data inside your own program (most programmers put all there data that needs to be saved even after the program has finished at the bottom of their program)
After the system part of the RAM, there is the user part. This is the place where all the programs, matrices, lists, Y-vars, ... are stored.
The end of this part is dynamic, which means it can change. This is because there is a Variable Allocation Table (VAT) which keeps track of where everything is stored.
This VAT starts at $FE6E, but it grows *BACKWARDS* so how more variables you have on your calculator, how less user space you have.
The memory between $FE6F and $FFFF is reserved for the stack. More about the stack in lesson 12
Useful Areas in System RAM
First, let's make a table of all the areas in the system RAM that can be used by the programmer to save his data without bringing the calculator in a possible unstable situation:
|Safe MEM locations
||Storing the information on the text screen
||Storing the image on the screen when the calc APD's (Automatic Power Down - after +/- 5 minutes of not using)
||Storing the information on the text screen (shadow - when you are in a menu or on the graph screen)
||Used for calculations. You might need to write certain information to an OP-var before calling a ROM function
||Used for writing the image that needs to appear on the LCD. A special function in the ROM will copy this information to the LCD.
I wrote the memory areas with the one that you should use first on top. Only start using another memory location if there is no place left in the previous one.
Normally, graph mem is not used to store your information (it's used for writing sprites to and such). TEXT_MEM, TEXT_MEM2 and APD_BUF are the most common areas to use.
Some other locations that you will need often are :
|Text Related Locations
||For changing the cursor position (normal text)
||For changing the cursor row position (normal text) : 0-7
(0,0) is top left
||For changing the cursor column position (normal text) : 0-15
||For changing the X coordinate of the menu cursor : 0-95
(0,0) is top left
||For changing the Y coordinate of the menu cursor : 0-63
Inside the system ram, there is also a table of bytes that is indexed by IY. Each bit of those bytes contains a setting. for example, if bit 3 of IY+$05 is set, the text you write will be displayed white on black.
If bit 3 of IY+$05 is reset, the text will be displayed black on white.
More info about the TI-82 RAM and ROM can be found in 82-RAM.TXT and 82-ROM.TXT by Dines Justesen and Matthias Lindqvist.
Previous lesson |