- global variables are stored in text memory
Variables will be assigned to bytes in the text memory in order of appearance
in source code. Thus, these variables retain their values only while the
program is executing. They are also initialized to zero. Warning: No
check is performed to verify that variables do not overrun the text memory
size.
example:
#include "zslib.h"
int nEdges;
char prompt;
char* name;
- static variables are stored in the program string
All static variables are initialized to zero the first time the program is
executed. These variables retain their values permanently. Use them sparingly,
however, as they are more expensive to access.
example:
#include "zslib.h"
static int hiscore;
static char initials[3];
- extern variables reference variables defined in assembly code.
These are convenient for storage of look-up tables, grafx, and any other
permanent data. They can also be used in place of static variables when an initial
value is desired.
example:
extern char sin[];
...
#asm
sin:
.db $00, $01, $03, $08
#endasm
This could be used as a pseudo sin table.
- extern variables followed by an address reference predefined memory.
These should really only be used to reference constants defined by the TI-85 or
ZShell. Warning: The memory address is not checked for validity or
collision with global variables.
example:
extern int bytes_used (0x80cc); /* Defined in ti-85.h */
extern int* user_mem (0x8b1b);
...
puts("Memory used: ");
putn(bytes_used);