Applesoft II Pointers & Tokens

By Val J. Golding

Applesoft & Applesoft II store in memory from the bottom up, unlike Integer BASIC, which is just the opposite, storing from the top down. Although pointers and characteristics of Applesoft I and II are similar, they are different. Therefore we will limit ourselves to APII in this discussion.

Programs store startirlg at decimal location 12289 upwards, at’Id variables are located starting at the high end of program storage. Where there is no program present, theh the variables will start at 12291. String variables, however, store downwards from the top of memory, 16384 for a 16K Apple.

Apples oft has a somewhat complex group of pointers; we’re not positive we have covered them all here. All pointers are given in decimal form. 103 & 104 are the start of memory pointer. They always point to 12289 where you can find the address of the second program statement. They are not affected by setting LOMEM:. 105 & 106 are the variable low pointer. They point to the next available location available for either more program or variables. 107 & 108 are the variable pointer. They point to the last location used by variables, plus one. 109 & 110 are the Current Memory pointer. They point to the highest location plus one, used by either program or variables. 111 & 112 are the low string pointer. They point to the next location available for string variable storage. 115 & 116 are the HIMEM: pointer. They always point to HlMEM: which is the first location available for string variable storage. Finally, we have the true program pointer, 175 & 176. These point to the highest location, plus one, used by the program. They are NOT affected by the setting 0f LOMEM:.

A program to display Applesoft II tokens is listed below. Unlike Integer BASIC, which uses the values 0 to 127 for its tokens, ASCII uses 128 to 255, while 0 to 127 are the ASCII character set.  The ASCII set is as given in the chart in the May Call-A.P.P.L.E.. ASCII tokens are shown in Figure 4 on Page 9

A BASIC statement in Applesoft II is composed of five bytes, exclusive of any tokens, and is illustrated below in figure. Here is a sample program line, along with the hex bytes it is composed of.

a. = Address of next Basic line.
b. = Line number.
c. = Token for “REM”.
d. = End of line delimiter.

 

 

—————-Figure 2————————————-

100 PRINT

110 REM ROUTINE TO DISPLAY APPLESOFT PROGRAM TOKENS BY VAL GOLDING AND BOB HUELSDONK

120 REM APPLE PUGETSOUND PROGRAM LIBRARY EXCHANGE 6708 39TH AVE SW SEATTLE, WA. 98136

180 D=1

200 HOME:A=1:B=128:C=12293

210 POKE C,B: LIST 100:VTAB(PEEK(37)-1)

220 IF D=1 THEN GOSUB 700

230 IF D=2 THEN GOSUB 520

240 VTAB (PEEK(37)):B=B+1:A=A+1

250 IF A=22 OR A=85 THEN 400

260 IF A=43 OR A=127 THEN 410

270 IF A=64 OR A=106 THEN 420

280 IF A=129 THEN 500

290 GOTO 210

400 POKE 32,13:VTAB1:GOTO 210

410 POKE 32,26:VTAB1:GOTO 210

420 CALL -676:POKE 32,0:HOME:GOTO 210

500 IF D=2 THEN GOTO 800

510 VTAB 6: PRINT ” FOR HEX”:PRINT”TOKENS, HIT”:PRINT “RETURN”:CALL-676:D=2:POKE 32,0:GOTO 200

520 X$=” “:H4=”0123456789ABCDEF”

540 X%=((B/256) – INT(B/256))*16:GOSUB 600

550 X%=((B/16) – INT(B/16))*16:GOSUB 600

560 PRINT X$:RETURN

600 X$=X$+MID$(H$,X%+1,1):RETURN

700 PRINT B:RETURN

800 VTAB 22:POKE 32,0:POKE C,186

810 END

—————END OF LISTING——————

Author: Bill Martens
A.P.P.L.E. Chairman of the Board and Club president -- Bill worked for the founder, Val J. Golding and A.P.P.L.E. from 1981 to 1982. In 1999, he began archiving the materials which were distributed and sold by A.P.P.L.E.. That project led to the group that remained of A.P.P.L.E. Bill was involved in the financial industry in Tokyo and has over 20 major office infrastructure projects to his name. In March 2001, he retired to write books and to spend more time pursuing personal interests. As the president of the users group, Bill is in charge of distribution of Call-A.P.P.L.E. magazine as well as the organization of this web site. Bill currently resides in Tokyo, Japan and Shelton, Wa splitting time between the places.