THE APPLE® GAZETTE
List Apple Integer Basic Programs One Page At A Time
The obvious way to examine an unfamiliar program is to type "LIST". In APPLE'S INTEGER BASIC, this often gives little or no useful information, because the whole program is listed at great speed, and the moving display can scarcely be read. If the listing could be stopped, this would be no problem; however, only the RESET key stops the listing. Pressing the RESET key is brutal and inelegant, and can cause loss of the program being listed.
This small program in Assembly Language provides a convenient way to list INTEGER BASIC programs without those two problems. It lists one screen-full of the BASIC program, then waits for any key to be pressed. If any key but CTRL-C is pressed, the next screen-full of the program is listed, and so on until the whole BASIC program has been displayed. At any time, CTRL-C can be entered, and the listing ceases, with one screen-full of the BASIC program still visible. This makes it simple to browse an INTEGER BASIC program either quickly or slowly, and stop after any screen-load ("page").
This program does not interfere with BASIC, and as listed here, it occupies a part of memory where it will not likely be damaged. Locations 700-762 ($2BC-$2FA) are approximately the final quarter of the 256-byte keyboard input buffer, and are used only if more than 188 characters are entered as a line of BASIC or in reponse to an INPUT instruction. Either of these is very unusual, and in practice, the program is not over-written.
Users with little experience in machine language can easily enter this program with the Mini-Assembler which is part of APPLE'S Monitor, as follows:
> CALL - 151 (enter the Machine-language monitor) *F666G (enter the Mini-Assembler) !2BC : LDACA (no need to type spaces or $) ! STAE2 (a space is needed after the !) ! LDACB (and so on ...)
For the "branch" instructions, BCC, BNE, BCS, and BPL, the actual address branched-to is needed. For example:
! CMP4D (the instruction on line 0027) ! BNE2E0 (it branches to SHOWME at $2E0)
APPLE suggests using the RESET key to exit the Mini-Assembler, but there is a gentler way:
!$FF69G (type it as shown, with no spaces)
The program can be saved on disk via:
*BSAVE LISTAPAGE, A700, L63
It can be saved onto tape via:
*2BC.2FAW (there will be only 1 "beep")
At any time, this program can be loaded into memory without disturbing any BASIC program already present. To load it from disk, type:
To load it from tape, a more complicated sequence is needed:
>CALL -151 (to Monitor again) *2BC.2FAR (press PLAY before pressing RETURN) *E003G (or CTRL-C)
In either case, the program is safely hiding in locations 700-762 inclusive, and it can be used in these ways:
To list a BASIC program from the beginning, just type "CALL 700" to see the first page. Press any key except CTRL-C to see more, or press CTRL-C to stop listing after any page.
The program has a second entry-point which is also useful. Type "CALL 708" to resume listing a program after the line most recently listed. For example, to list some lines starting with line 2000, type "LIST 1999", whether or not such a line exists, then type "CALL 708", and successive pages starting with line 2000 will be listed. "CALL 708" can also be used to resume a listing which had been begun by "CALL 700" and stopped by CTRL-C.
Experienced users of machine-language will have noticed that this program is relocatable. In other words, it does not contain any reference to its own absolute address. That in turn means that it can occupy any locations in memory that are not in use for other purposes, and function there without needing any changes. Other locations which can be used to contain this program include, from most convenient to least:
Page 3, locations 768-830 (or nearby) is easiest because neither the APPLE monitor nor BASIC makes use of this space, hence of course, it is the popular place for noise-making routines and various other uses which would conflict with this. 2048-2110. In issue CLR and LOMEM:2110 to prevent BASIC variables from over-writing the routine.
16322-16384. Issue NEW and HIMEM: 16322 to prevent a BASIC program from over-writing the routine. Those addresses interfere with High-Resolution graphics, and will be different in a machine with more or less than 16K of memory.
LINE# LOC CODE LINE 0003 0000 .OPT NOSYM 0004 0000 ; LIST INTEGER BASIC PROGRAM 0005 0000 ; ONE SCREEN-FULL AT A TIME: 0006 0000 ; 0007 0000 *=700 0008 02BC ; 0009 02BC ; **ENTER HERE TO LIST FROM START 0010 02BC ; 0011 02BC A5CA LDA $CA 0012 02BE 85E2 STA $E2 ;INIT POINTERS TO 0013 02C0 A5CB LDA $CB ;START OF PROGRAM 0014 02C2 85E3 STA $E3 0015 02C4 ; 0016 02C4 ; **ENTER HERE TO RESUME LISTING 0017 02C4 ; 0018 02C4 A54C LDA $4C 0019 02C6 85E6 STA $E6 ;LIST UNTIL 0020 02C8 A54D LDA $40 ;HIMEM: HIT 0021 02CA 85E7 STA $E7 0022 02CC 2C10C0 RESUME BIT $C010 ;RESET KEYBOARD 0023 02CF 2058FC JSR $FC58 ;CLEAR THE SCREEN 0024 02D2 ; 0025 02D2 ; SEE IF THERE IS MORE TO LIST. 0026 02D2 A5E3 ANYMOR LDA $E3 0027 02D4 C54D CMP $4D ;ALL DONE? 0028 02D6 9008 BCC SHOWME ;NO. 0029 02D8 D01B BNE EXIT ;YES. 0030 02DA A5E2 LDA $E2 ;MAYBE ... 0031 02DC C54C CMP $4C ;FOR SURE? 0032 02DE B015 BCS EXIT ;YES. 0033 02E0 206DE0 SHOWME JSR $E06D ;LIST ONE LINE 0034 02E3 ; 0035 02E3 ; SEE IF ROOM TO LIST ANOTHER LINE. 0036 02E3 A525 LDA $25 ;CURRENT LINE ON SCREEN 0037 02E5 18 CLC 0038 02E6 6904 ADC #4 ;LEAVE ROOM FOR 4 LINES 0039 02E8 C523 CMP $23 ;ROOM FOR ANOTHER LINE? 0040 02EA 90E6 BCC ANYMOR ;Y: GO TRY TO LIST MORE 0041 02EC ; 0042 02EC ; SCREEN IS FULL. WAIT FOR A KEY. 0043 02EC AD00C0 WAITKY LDA $C000 ;SEE WHICH KEY PRESSED. 0044 02EF 10FB BPL WAITKY ;NONE. KEEP ON WAITING. 0045 02F1 C983 CMP #$83 ;WAS IT CTRL-C? 0046 02F3 D0D7 BNE RESUME ;N: DO ANOTHER PAGE. 0047 02F5 2C10C0 EXIT BIT $C010 ;RESET KEYBOARD. 0048 02F8 4C03E0 JMP $E003 ;BACK TO BASIC. 0049 02FB .END
Other locations, such as the gap above the variables and below the program might be tried if none of the above appeals. Experiment at will in this fashion, and remember, "You can't hurt the computer by pressing keys".
This program provides a helpful alternative to the "LIST" command, filling an irritating gap in APPLE'S flexible and rapid INTEGER BASIC.