Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
164 COMPUTE!<br />
164 COMPUTE!<br />
May.1982,I,,"e24<br />
May, Issue 24<br />
dynamically from BASIC via POKEs, etc. Note<br />
dynamically from BASIC via POKEs, etc. Note<br />
that Easykey. Easykey, as given here, reserves over 450 bytes<br />
for soft strings. Note also the addresses of the<br />
labels "STABLE" and "STRINGS." lGS." I Iff you assemble<br />
your ownn copy of Easykey, be sure and note the<br />
addresses of these two labels and convert them to<br />
decimal if you intend to use dynamic soft keys.<br />
decimal if you intend to use d )'namic soft keys.<br />
...if.if you control these seven<br />
pOinters, pointers, you control BASIC...<br />
Program 2. 2, thee BASK' BASIC program, is a sample<br />
which will allow )'UU you to redefine all 26 soft keys to<br />
any string )'o u like and th en save the res ulting<br />
any string you like and then save the resulting<br />
definitions in a disk file e for later use. Study the<br />
technique, and you )'ou should be able to produce an)' any<br />
kind of soft keys you might want. The program<br />
kind of soft ke)'s yo u might wa nt. The program<br />
fragmcnt (Program 3) will allow the reloading of<br />
predefin ed sets produced b)' the previous program.<br />
fragment (Program 3) will allow the reloading of<br />
predefined sets produced by the previous program.<br />
Inside Atari Afari BASIC: Part 4<br />
This month we will feature a short discussion of<br />
the various "tallies" "tables" used by b)' Atari BASK' IC and how<br />
to find them. thcm. Some of this material is well covered<br />
by b)' some of the articles in COMPUTE!'* COMPUTE!'.I First Book Bool< of<br />
Atari, Alm-;, so if you YO ll arc are too lOO impatient to wait for next<br />
month )'ou ca n run out and bu)' the book. Next<br />
month you can run out and buy the book. Next<br />
monthm we will begin to use the information we<br />
discover this month to "fool" BASIG IC into letting lelling us<br />
do things it was never designed for. We begin:<br />
do things it was ncver des igned for. Wc begin:<br />
When an Atari BASK; IC program is SAVEd to<br />
disk oro r cassette, there are only 14 bytes of zero<br />
page written wrillen out along with the main tables and<br />
program. TheseT 14 bytes consist of seven two-byte two-b),tc<br />
pointers {in (in the traditional low-byte, high-byte<br />
form) which tell BASIC where everything ever),thing is in the<br />
particular program being SAVEd (or later being<br />
LOADed). All the other important zero page locations<br />
(and there are arc over ovcr 50 of them) are arc regenerated<br />
and/orjecalculated and/Ol',recalcu lated by b)' BASIC anytime you )'ou<br />
type t)' NEWN E\'" or SAVE (or, for r some locations, RUN,<br />
,<br />
GOTO, GOTO. etc.). The implication is that, if you )'ou control<br />
thesc seven poilll.ers, )'ou control BASIC so let's<br />
these seven pointers, you control BASK! so let's<br />
examine e their names and functions. fUllctions. Table 1I givesg a<br />
summary thereof.<br />
e reof',<br />
TheT first thing you )'ou may note about this table is<br />
that some of the locations (indicated by asterisks)<br />
have duplicate labels. If you examine the mnemonic<br />
have duplicate labels. If you examine the mnemonic<br />
meanings, you will probabl)' probably see why: the pointer<br />
can mean different things in different contexts.<br />
can mean different things in different contexts.<br />
Forr example, the space pointed to b)' by location n $80<br />
(decimal 128) is used for different purposes, de<br />
(decimal 128) is used fo r different purposes, de<br />
pendingg on whether BASIC is currentlyy working<br />
on entering a new line (it uses OUTBUFF) or<br />
executing an expression within a program (whenn it<br />
uses ARGOPS).<br />
Youu might also note that I provided a list of<br />
more than seven pointers. The locations $8EE and<br />
$90 are not SA VEd and reLOADed because the),<br />
$90 are not SAVEd and reLOADed because they<br />
are always dependent onn the currcnt current state of the<br />
program (i.e., whether it is RUNning, whether it<br />
has executed a DIM statement, etc.). The), They are<br />
included here for completeness: aside from the<br />
zero page locations (and the $600 page locations<br />
with BASIC A + ), these pointers completely ), definee<br />
BASIC'S IC's usage of the Atari computer's memory r),<br />
space. So now let's go into detail about what each<br />
of these pointers is used for.<br />
Table I: BASIC's Critical Zero-Page Pointers<br />
Table 1: BASIC'S Critical Zero-Page Pointers<br />
Location .Mnemonic Which means:<br />
Hex<br />
80 80<br />
Decimal 128<br />
128*<br />
*<br />
Label,<br />
Label:<br />
LOMEN ARGOPS<br />
pointer to LOw MEMory limit<br />
A ARGument/OPeratorStack<br />
RCume ntlOPc 80 128* · OUTBUFF syntax OUTput BUFFer<br />
82<br />
84 86 88 8A 8C BC<br />
8E BE<br />
8E BE 130 132 134<br />
136* 136· 138 140 142<br />
142*<br />
2 ·<br />
VNTP VNTD<br />
VVTP STMTAB STMCUR<br />
STARP ENDSTAR RUNSTK<br />
Variable Name Table Pointer<br />
Variable Name Table Dummy end<br />
Variable Value Table Pointer<br />
STateMentTABIe TABle<br />
CURrentSTateMent pointerr<br />
STring/ARray Pointer<br />
END D STringl STring/ARray A space<br />
RUNtime STacK pointer<br />
90 144 TOPRSTK TOP of Run lime STacKspace<br />
90 144 TOPRSTK TOP of Runtime STacK space<br />
90 144*<br />
· MEMTOP pointer MEMorv ory TOP limit<br />
We already noted that ARGOPS is used in<br />
We already noted that ARGOPS is used in<br />
expression evaluation. ation. That is, whenever BASIC<br />
sees any an)' kind of expression n to be evaluated ated [e.g.,<br />
,<br />
3*A A + B or SIN(30) or 2"(LOG(4/EXP(Y*Z*3))-I/<br />
2' (LOG(4/EXP(Y*Z'3))- 11<br />
(Z"2.5 (Z' +ATN(Z)) + or even 1.25], it must put intermediate<br />
results and/or operatorso ono n a "stack."<br />
"<br />
ARGOPS points to a 256 byte area reserved for<br />
both the argument stack and the e operator stack.<br />
(What actually ), happens in Execute Executc Expression is<br />
extremely extremel), complex and far beyond be)'ond the scope of<br />
this article.) anicle.) Since expression evaluation and program<br />
entry cannot occur at allhe the same time, liln OUT-<br />
BUFF shares this same 256 byte space. When a<br />
B FF shares this sa me 256 b)'te spacc. When a<br />
program line is entered, , BASIC C checks it for syntax<br />
and converts it to internal tokens, pl ac in g these<br />
and converts it to internal tokens, placing these<br />
tokens temporarily y into this 256 byte buffer (before<br />
moving them into the appropriate place in the