Classic Computer Magazine Archive COMPUTE! ISSUE 42 / NOVEMBER 1983 / PAGE 10

TI Free Memory Techniques

I would like to clarify and expand upon the ideas expressed by Howard Patlik in "More on TI Memory" (Readers' Feedback, August 1983). This two-line program for determining free memory on the TI-99/4A was offered:

1 A = A+8
2 GOSUB 1

If you RUN this program alone and PRINT the variable A, you will find the amount of available memory less the 37 bytes required by the program itself. (A equals 14536, so A plus 37 equals 14573 bytes of memory for programming.) When the program RUNs, the GOSUB in line 2 will execute 1817 times before a MEMORY FULL error is issued in line 1. Each time this GOSUB executes, 8 bytes of memory are consumed and thus 1817 times 8 is 14536. As many as 7 bytes may still be unused.

Of course, if this two-line routine is entered with a program already in memory (providing the variable A is not used within this program), you will find the amount of free memory less 37 bytes when you RUN and PRINT A.

There are some more considerations. String variables and graphic characters defined above CHR$(127) will require additional memory that this two-line routine will not pick up. The TI-99/4 has 256 more free bytes than the TI-99/4A, but if graphic characters above 127 are used, then both will use the same amount of memory.

Screen and BASIC overhead is 1792 bytes. And if all or only the graphics character 159 is used, then overhead is 2048 bytes (1792 + 8*(159–127)). The 16K TI-99/4A is, of course, actually 16,384 bytes. So, 16,384 minus 1792 is 14,592 bytes free. (There is a slight discrepancy from the two-line method of up to 19 bytes.)

Here is another way to find memory size using CALL PEEK. For TI BASIC, you need the Mini Memory or the Editor/Assembler cartridges. Type in CALL PEEK(-31974,A,B). Again the variables A and B should not be in the program. Then PRINT A*256 + B-1776. With no program present, this will give a size of 14577 bytes free.

To check this with TI Extended BASIC (Version 110), type PRINT A*256 + B-2455. The TI's response is 13886. Now type SIZE. The TI responds with 13886 BYTES FREE.

Another user of memory in TI BASIC is Terminal Emulator II. It takes about 512 bytes. It is also well-known that the disk controller uses console memory. Even after ENTERing CALL FILES(l) and the NEW command, it still uses 1052 bytes. Here's how to free up this memory. Type CALL LOAD(-31888,63,255) and NEW.

Again, in TI BASIC the Mini Memory or Editor/Assembler cartridge is needed, but in TI Extended BASIC, the 32K Expansion is needed. To restore disk drive(s) and disk controller, use the command BYE or FCTN QUIT.

Paul E. Schippnick