Apple II Redbook (Redbook) Reference Manual 30th Anniversary

User Manual: manual pdf -FilePursuit

Open the PDF directly: View PDF PDF.
Page Count: 158

DownloadApple II Redbook (Redbook) Reference Manual 30th Anniversary
Open PDF In BrowserView PDF
This recreation of the 1978 Apple ][ Redbook is courtesy of Gerry Doire.
gerrydoire@yahoo.ca for any comments or suggestions.
Any donations for better software and hardware, what I have is old and slow,
can be made to marketplace@seaside.ns.ca, Thanks!

iDonate
Current Donators to this project are:
Dan Chisarick

APPLE II
Reference Manual
January 1978

APPLE Computer Inc.
10260 Brandley Dr.
Cupertino, CA
95014

APPLE Reference Manual
TABLE OF CONTENTS

A. GETTING STARTED WITH YOUR
APPLE II

1

13. Additional BASIC Program
Examples

1. Unpacking

1

a. Rod’s Color Pattern (4K)

55

2. Warranty Registration Card

1

b. Pong (4K)

56

3. Check for Shipping Damage

2

c. Color Sketch (4K)

57

4. Power Up

2

d. Mastermind (8K)

59

5. APPLE II Speaks Several Languages

2

e. Biorhythm (4K)

61

6. APPLE Integer BASIC

3

f. Dragon Maze (4K)

63

C. APPLE II FIRMWARE

67

7. Running Your First

55

and Second Programs

3

1. System Monitor Commands

68

8. Running 16K Startrek

3

2. Control and Editing Characters

72

9. Loading a Program Tape

4

3. Special Controls and Features

74

10. Breakout and Color Demos Tapes

6

4. Annotated Monitor and

11. Breakout and Color

Dis-assembler Listing

76

Demos Program Listings

12

5. Binary Floating Point Package

94

12. How to Play Startrek

14

6. Sweet 16 Interpreter Listing

96

13. Loading HIRES Demo Tape

15

7. 6502 Op Codes

B. APPLE II INTEGER BASIC

17

D. APPLE II HARDWARE

100
106
107

19

1. Getting Started with Your
APPLE II Board

3. BASIC Functions

22

2. APPLE II Switching Power Supply

112

4. BASIC Statements

23

3. Interfacing with the Home TV

114

5. Special Control and Editing

28

4. Simple Serial Output

6. Table A- Graphics Colors

29

7. Special Controls and Features

30

8. BASIC Error Messages

32

9. Simplified Memory Map

33

10. Data Read/Save Subroutines

34

5. Interfacing the APPLE Signals, Loading, Pin
Connections
6. Memory Options, Expansion, Map,
Address

11. Simple Tone Subroutines

43

7. System Timing

140

8. Schematics

141

1. BASIC Commands

18

2. BASIC Operators

12. High Resolution Graphics
Subroutines and Listings

46

110

122

133

GETTING STARTED WITH YOUR APPLE II
Unpacking
Don't throw away the packing material. Save it for the unlikely
event that you may need to return your Apple II for warrantee repair.
If you bought an Apple II Board only, see hardware section in this
manual on how to get started. You should have received the following:
1. Apple II system including mother printed circuit board
with specified amount of RAM memory and 8K of ROM memory,
switching power supply, keyboard, and case assembly.
2.

Accessories Box including the following:
a. This manual including warranty card.
b. Pair of Game Paddles
c. A.C. Power Cord
d. Cassette tape with "Breakout"on one side
and "Color Demos" on the other side.
e. Cassette recorder interface cable (miniature
phone jack type)

3. If you purchased a 16K or larger system, your accessory
box should also contain:
a. 16K Startrek game cassette with High Resolution
Graphics Demo ("HIRES") on the flipside.
b. Applesoft Floating Point Basic Language Cassette
with an example program on the other side.
c. Applesoft reference manual
4. In addition other items such as a vinyl carrying case
or hobby board peripherial may have been included if
specifically ordered as "extras".
Notify your dealer or Apple Computer, Inc. immediately if you are
missing any items.
Warranty Registration Card
Fill this card out immediately and completely and mail to Apple in
order to register for one year warranty and to be placed on
owners club mailing list. Your Apple II's serial number is located
on the bottom near the rear edge. You model number is:
A2SØØMMX
MM is the amount of memory you purchased. For Example:
A2SØØØ8X
is an 8K Byte Apple II system.

1

Check for Damage
Inspect the outside case of your Apple for shipping damage. Gently
lift up on the top rear of the lid of the case to release the lid
snaps and remove the lid. Inspect the inside. Nothing should be
loose and rattling around. Gently press down on each integrated
circuit to make sure that each is still firmly seated in its
socket. Plug in your game paddles into the Apple II board at the
socket marked "GAME I/O" at location J14. See hardware section of
this manual for additional detail. The white dot on the connector
should be face forward. Be careful as this connector is fragile.
Replace the lid and press on the back top of it to re-snap it into
place.
Power Up
First, make sure that the power ON/OFF switch on the rear power
supply panel on your Apple II is in the "OFF" position. Connect
the A.C. power cord to the Apple and to a 3 wire 12Ø volt A.C.
outlet. Make sure that you connect the third wire to ground if
you have only a two conductor house wiring system. This ground
is for your safety if there is an internal failure in the Apple
power supply, minimizes the chance of static damage to the Apple,
and minimizes RFI problems.
Connect a cable from the video output jack on the back of the Apple
to a TV set with a direct video input jack. This type of set is
commonly called a "Monitor". If your set does not have a direct
video input, it is possible to modify your existing set. Write for
Apple's Application note on this. Optionally you may connect the
Apple to the antenna terminals of your TV if you use a modulator.
See additional details in the hardware section of this manual under
"Interfacing with the Home TV".
Now turn on the power switch on the back of the Apple. The indicator
light (it's not a switch) on the keyboard should now be ON. If
not, check A.C. connections. Press and release the "Reset" button
on the keyboard. The following should happen: the Apple's internal
speaker should beep, an asterisk ("*") prompt character should appear
at the lower left hand corner of your TV, and a flashing white square
should appear just to the right of the asterisk. The rest of the
TV screen will be made up of radom text characters (typically question marks).
If the Apple beeps and garbage appears but you cannot see an "*" and the
cursor, the horizontal or vertical height settings on the TV need to be
adjusted. Now depress and release the "ESC" key, then hold down the
"SHIFT" key while depressing and releasing the P key. This should
clear your TV screen to all black. Now depress and release the "RESET"
key again. The "*" prompt character and the cursor should return to
the lower left of your TV screen.

2

Apple Speaks Several Languages
The prompt character indicates which
in. The current prompt character, an
you are in the "Monitor" language, a
for advanced programmers. Details of
"Firmware" section of this manual.

language your Apple is currently
asterisk ("*"),indicates that
powerful machine level language
this language are in the

Apple Integer BASIC
Apple also contains a high level English oriented language called
Integer BASIC, permanently in its ROM memory. To switch to this
language hold down the "CTRL" key while depressing and releasing the
"B" key. This is called a control-B function and is similiar to
the use of the shift key in that it indicates a different function
to the Apple. Control key functions are not displayed on your
TV screen but the Apple still gets the message. Now depress and
release the "RETURN" key to tell Apple that you have finished typing
a line on the keyboard. A right facing arrow (">") called a caret
will now appear as the prompt character to indicate that Apple is
now in its Interger BASIC language mode.
Running Your First and Second Program
Read through the next three sections that include:
1.

Loading a BASIC program Tape

2.

Breakout Game Tape

3.

Color Demo Tape

Then load and run each program tape. Additional information on
Apple II's interger BASIC is in the next section of this manual.
Running 16K Startrek
If you have 16K Bytes or larger memory in your Apple, you will also
receive a "STARTREK" game tape. Load this program just as you did
the previous two, but before you "RUN" it, type in "HIMEM: 16384"
to set exactly where in memory this program is to run.

3

LOADING A PROGRAM TAPE

INTRODUCTION
This section describes a procedure for loading BASIC programs
successfully into the Apple II. The process of loading a program is divided
into three section; System Checkout, Loading a Tape and What to do when
you have Loading Problems. They are discussed below.
When loading a tape, the Apple II needs a signal of about 2 l/2 to 5
volts peak-to-peak. Commonly, this signal is obtained from the "Monitor"
or "earphone" output jack on the tape recorder. Inside most tape recorders,
this signal is derived from the tape recorder's speaker. One can take
advantage of this fact when setting the volume levels. Using an Apple
Computer pre-recorded tape, and with all cables disconnected, play the tape
and adjust the volume to a loud but un-distorted level. You will find that
this volume setting will be quite close to the optimum setting.
Some tape recorders (mostly those intended for use with hi-fi sets)
do not have an "earphone" or high-level "monitor" output. These machines
have outputs labeled"line output" for connection to the power amplifier.
The signal levels at these outputs are too low for the Apple II in most cases.
Cassette tape recorders in the $4Ø - $5Ø range generally have ALC
(Automatic Level Control) for recording from the microphone input. This feature
is useful since the user doesn't have to set any volume controls to obtain
a good recording. If you are using a recorder which must be adjusted, it
will have a level meter or a little light to warn of excessive recording levels.
Set the recording level to just below the level meter's maximum, or to just a
dim indication on the level lamp. Listen to the recorded tape after you've
saved a program to ensure that the recording is "loud and clear".
Apple Computer has found that an occasional tape recorder will not function
properly when both Input and Output cables are plugged in at the same time.
This problem has been traced to a ground loop in the tape recorder itself which
prevents making a good recording when saving a program. The easiest solution
is to unplug the "monitor" output when recording. This ground loop does not
influence the system when loading a pre-recorded tape.

4

Tape recorder head alignment is the most common source of tape recorder
problems. If the playback head is skewed, then high frequency information
on pre-recorded tapes is lost and all sorts of errors will result. To confirm
that head alignment is the problem, write a short program in BASIC. >10 END
is sufficient. Then save this program. And then rewind and load the program.
If you can accomplish this easily but cannot load pre-recorded tapes, then
head alignment problems are indicated.
Apple Computer pre-recorded tapes are made on the highest quality professional
duplicating machines, and these tapes may be used by the service technician to
align the tape recorder's heads. The frequency response of the tape recorder
should be fairly good; the 6 KHz tone should be not more than 3 db down from
a 1 KHz tone, and a 9 KHz tone should be no more than 9 db down. Note that
recordings you have made yourself with mis-aligned heads may not not play
properly with the heads properly aligned. If you made a recording with a
skewed record head, then the tiny magnetic fields on the tape will be skewed as
well, thus playing back properly only when the skew on the tape exactly matches
the skew of the tape recorder's heads. If you have saved valuable programs with
a skewed tape recorder, then borrow another tape recorder, load the programs with
the old tape recorder into the Apple, then save them on the borrowed machine.
Then have your tape recorder properly aligned.
Listening to the tape can help solve other problems as well. Flaws in the
tape, excessive speed variations, and distortion can be detected this way.
Saving a program several times in a row is good insurance against tape flaws.
One thing to listen for is a good clean tone lasting for at least 3 1/2 seconds
is needed by the computer to "set up" for proper loading. The Apple puts out
this tone for anout 1Ø seconds when saving a program, so you normally have
6 1/2 seconds of leeway. If the playback volume is too high, you may pick up tape
noise before getting to the set-up tone. Try a lower playback volume.
SYSTEM CHECKOUT
A quick check of the Apple II computer system will help you spot any
problems that might be due to improperly placed or missing connections between
the Apple II, the cassette interface, the Video display, and the game
paddles. This checkout procedure takes just a few seconds to perform and
is a good way of insuring that everything is properly connected before the
power is turned on.

5

1.

POWER TO APPLE - check that the AC power cord is plugged
into an appropriate wall socket, which includes a "true"
ground and is connected to the Apple II.

2.

CASSETTE INTERFACE - check that at least one cassette
cable double ended with miniature phone tip jacks is
connected between the Apple II cassette Input port and
the tape recorder's MONITOR plug socket.

3.

VIDEO DISPLAY INTERFACE a)
for a video monitor - check that a cable connects
the monitor to the Apple's video output port.
b)
for a standard television - check that an adapter
(RF modulator) is plugged into the Apple II (either
in the video output (K 14) or the video auxiliary
socket (J148), and that a cable runs between the
television and the Adapter's output socket.

4.

GAME PADDLE INTERFACE - if paddles are to be used, check
that they are connected into the Game I/O connector (J14)
on the right-hand side of the Apple II mainboard.

5.

POWER ON - flip on the power switch in back of the Apple II,
the "power" indicator on the keyboard will light. Also
make sure the video monitor (or TV set) is turned on.

After the Apple II system has been powered up and the video display
presents a random matrix of question marks or other text characters the
following procedure can be followed to load a BASIC program tape:
1.

Hit the RESET key.
An asterick, "*",should appear on the lefthand side
of the screen below the random text pattern. A flashing
white cursor will appear to the right of the asterick.

2.

Hold down the CTRL key, depress and release the B key,
then depress the "RETURN" key and release the "CTRL" key.
A right facing arrow should appear on the lefthand side
of the screen with a flashing cursor next to it. If it
doesn't, repeat steps 1 and 2.

3.

Type in the word "LOAD" on the keyboard. You should see
the word in between the right facing arrow and the
flashing cursor. Do not depress the "RETURN" key yet.

4.

Insert the program cassette into the tape recorder and
rewind it.

5.

If not already set, adjust the Volume control to 5Ø-7Ø%
maximum. If present, adjust the Tone control to 8Ø-1ØØ%
maximum.

6

6.

Start the tape recorder in "PLAY" mode and now depress
the "RETURN" key on the Apple II.

7.

The cursor will disappear and Apple II will beep in a
few seconds when it finds the beginning of the program.
If an error message is flashed on the screen, proceed
through the steps listed in the Tape Problem section
of this paper.

8.

A second beep will sound and the flashing cursor will
reappear after the program has been successfully loaded

9.

into the computer.
Stop the tape recorder. You may want to rewind the program
tape at this time.

10. Type in the word "RUN" and depress the "RETURN" key.
The steps in loading a program have been completed and if everying has
gone satisfactorily the program will be operating now.
LOADING PROBLEMS
Occasionally, while attempting to load a BASIC program Apple II
beeps and a memory full error is written on the screen. At this time
you might wonder what is wrong with the computer, with the program tape,
or with the cassette recorder. Stop. This is the time when you need
to take a moment and checkout the system rather than haphazardly attempting
to resolve the loading problem. Thoughtful action taken here will
speed in a program's entry. If you were able to successfully turn on the
computer, reset it, and place it into BASIC then the Apple II is probably
operating correctly. Before describing a procedure for resolving this
loading problem, a discussion of what a memory full error is in order.
The memory full error displayed upon loading a program indicates that
not enough (RAM) memory workspace is available to contain the incoming data.
How does the computer know this? Information contained in the beginning of
the program tape declares the record length of the program. The computer
reads this data first and checks it with the amount of free memory. If
adequate workspace is available program loading continues. If not, the
computer beeps to indicate a problem, displays a memory full error statement,
stops the loading procedure, and returns command of the system to the keyboard.
Several reasons emerge as the cause of this problem.

7

Memory Size too Small
Attempting to load a 16K program into a 4K Apple II will generate this
kind of error message. It is called loading too large of a program. The
solution is straight forward: only load appropriately sized programs into
suitably sized systems.
Another possible reason for an error message is that the memory pointers
which indicate the bounds of available memory have been preset to a smaller
capacity. This could have happened through previous usage of the "HIMEN:"
and "LOMEN:" statements. The solution is to reset the pointers by BC (CTRL B)
command. Hold the CTRL key down, depress and release the B key, then depress
the RETURN key and release the CTRL key. This will reset the system to maximum capacity.

Cassette Recorder Inadjustment
If the Volume and Tone controls on the cassette recorder are not
properly set a memory full error can occur. The solution is to adjust
the Volume to 5Ø-7Ø% maximum and the Tone (if it exists) to 8Ø-1ØØ%
maximum.*
A second common recorder problem is skewed head azimuth. When
the tape head is not exactly perpendicular to the edges of the magnetic
tape some of the high frequency data on tape can be skipped. This causes
missing bits in the data sent to the computer. Since the first data read
is record length an error here could cause a memory full error to be
generated because the length of the record is inaccurate. The solution:
adjust tape head azimuth. It is recommended that a competent technician
at a local stereo shop perform this operation.
Often times new cassette recorders will not need this adjustment.

*Apple Computer Inc. has tested many types of cassette recorders and so far
the Panasonic RQ-3Ø9 DS (less than $4Ø.ØØ) has an excellent track record
for program loading.

Tape Problems
A memory full error can result from unintentional noise existing in
a program tape. This can be the result of a program tape starting on its
header which sometimes causes a glitch going from a nonmagnetic to magnetic
recording surface and is interpreted by the computer as the record length.
Or, the program tape can be defective due to false erasure, imperfections
in the tape, or physical damage. The solution is to take a moment and
listen to the tape. If any imperfections are heard then replacement of the
tape is called for. Listening to the tape assures that you know what a
"good" program tape sounds like. If you have any questions about this please
contact your local dealer or Apple for assistance.

If noise or a glitch is heard at the beginning of a tape advance the
tape to the start of the program and re-Load the tape.
Dealing with the Loading Problem
With the understanding of what a memory full error is an efficient way
of dealing with program tape loading problems is to perform the following
procedure:
l.

Check the program tape for its memory requirements.
Be sure that you have a large enough system.

2.

Before loading a program reset the memory pointers
with the Bc (control B) command.

3.

In special cases have the tape head azimuth
checked and adjusted.

4.

Check the program tape by listening to it.
a) Replace it if it is defective, or
b) start it at the beginning of the program.

5. Then re-LOAD the program tape into the Apple II.
In most cases if the preceeding is followed a good tape load will result.
UNSOLVED PROBLEMS
If you are having any unsolved loading problems, contact your
nearest local dealer or Apple Computer Inc.

9

BREAKOUT GAME TAPE

PROGRAM DESCRIPTION
Breakout is a color graphics game for the Apple II computer. The object of
the game is to "knock-out' all 16Ø colored bricks from the playing field by
hitting them with the bouncing ball. You direct the ball by hitting it with
a paddle on the left side of the screen. You control the paddle with one of
the Apple's Game Paddle controllers. But watch out: you can only miss the
ball five times:
There are eight columns of bricks. As you penetrate through the wall the
point value of the bricks increases. A perfect game is 72Ø points; after
five balls have been played the computer will display your score and a
rating such as "Very Good". "Terrible!", etc. After ten hits of the ball,
its speed with double, making the game more difficult. If you break through
to the back wall, the ball will rebound back and forth, racking up points.
Breakout is a challenging game that tests your concentration, dexterity,
and skill.
REQUIREMENTS
This program will fit into a 4K or greater system.
BASIC is the programming language used.
PLAYING BREAKOUT
1.
2.
3.
4.

Load Breakout game following instructions in the "Loading
a BASIC Program from Tape" section of this manual.
Enter your name and depress RETURN key.
If you want standard BREAKOUT colors type in Y or Yes
and hit RETURN. The game will then begin.
If the answer to the previous questions was N or No
then the available colors will be displayed. The
player will be asked to choose colors, represented by a
number from Ø to 15, for background, even bricks, odd
bricks, paddle and ball colors. After these have been
chosen the game will begin.

10

5.

At the end of the game you will be asked if they
want to play again. A Y or Yes response will start
another game. A N or No will exit from the program.

NOTE: A game paddle (15Øk ohm potentiometer) must be connected
to PDL (Ø) of the Game I/O connector for this game.

COLOR DEMO TAPE

PROGRAM DESCRIPTION
COLOR DEMO demonstrates some of the Apple II video graphics
capabilities. In it are ten examples: Lines, Cross, Weaving,
Tunnel, Circle, Spiral, Tones, Spring, Hyperbola, and Color Bars.
These examples produce various combinations of visual patterns
in fifteen colors on a monitor or television screen. For example,
Spiral combines colorgraphics with tones to produce some amusing
patterns. Tones illustrates various sounds that you can produce
with the two inch Apple speaker. These examples also demonstrate
how the paddle inputs (PDL(X)) can be used to control the audio
and visual displays. Ideas from this program can be incorporated
into other programs with a little modification.
REQUIREMENTS
4K or greater Apple II system, color monitor or television,
and paddles are needed to use this program. BASIC is the programming language used.

11

BREAKOUT GAME
PROGRAM LISTING
PROGRAM LISTING

5 GOTO 15
10 Q=( PDL (0)-20)/6: IF Q<0 THEN
Q=0: IF Q>=34 THEN Q=34: COLOR=
D: VLIN Q,Q+5 AT 0: COLOR=A:
IF P>Q THEN 175: IF Q THEN
VLIN 0,Q-1 AT 0:P=Q:RETURN
15 DIM A$(15),B$(10):A=1:B=13:
C=9:D=6:E=15: TEXT : CALL 936: VTAB 4: TAB 10: PRINT
“*** BREAKOUT ***”:PRINT
20 PRINT “ OBJECT IS TO DESTROY
ALL BRICKS”: PRINT : INPUT
“HI, WHAT’S YOUR NAME? ”,A$
25 PRINT “STANDARD COLORS ”;A$
;: INPUT “Y/N? ”,B$: GR: CALL
-936: IF B$(1,1)#”N” THEN 40
: FOR I=0 TO 39: COLOR=I/2*
(I(32): VLIN 0,39 AT I
30 NEXT I: POKE 34,20: PRINT :
PRINT : PRINT : FOR I=0 TO
15: VTAB 21+I MOD 2: TAB I+
I+1: PRINT I;: NEXT I: POKE
34,22: YTAB 24: PRINT : PRINT
“BACKGROUND”;
35 GOSUB 95:A=E: PRINT “EVEN BRICK”
;:GOSUB 95:B=E: PRINT “ODD BRIC
K”;: GOSUB 95:C=E: PRINT “PADDLE
”;: GOSUB 95:D=E: PRINT “BALL”
;:GOSUB 95
40 POKE 34,20: COLOR=A: FOR I=
0 TO 39: VLIN 0,39 AT I: NEXT
I: FOR I=20 TO 34 STEP 2: TAB
I+1: PRINT I/2-9;: COLOR=8:
VLIN 0,39 AT I: COLOR=C: FOR
J=I MOD 4 TO 39 STEP 4

45 VLIN J,J+1 AT I: NEXT J, I: TAB
5: PRINT “SCORE =0”:PRINT
: PRINT : POKE 34,21:S=0:P=
S:L=S:X=10:Y=10:L=6
50 COLOR=A: PLOT X,Y/3:X=19:Y=
RND (120):V=-1:W= RND (5)2:L=L-1: IF L<1 THEN 120: TAB
6: IF L>1 THEN PRINT L;”BALLS L
EFT”
55 IF L=1 THEN PRINT “LAST BALL, ”
;A$: PRINT : FOR I=1 TO 100
: GOSUB 10: NEXT I:M=1:N=0
60 J=Y+W: IF J>=0 AND J<120 THEN
65:W=-W:J=Y: FOR I-1 TO 6:K=
PEEK (-16336): NEXT I
65 I-X+V: IF I<0 THEN 180: GOSUB
170: COLOR=A:K=J/3: IF I>39
THEN 75: IF SCRN(I,K)=A THEN
85: IF I THEN 100:N=N+1:V=(
N>5)+1:W=(K-P)*2-5:M=1
70 Z= PEEK (-16336)-PEEK (-16336
)+ PEEK (-16336)- PEEK (-16336
)+ PEEK (-16336)- PEEK (-16336
)+ PEEK (-16336): GOTO 85
75 FOR I=1 TO 6:M= PEEK (-16336
): NEXT I:I=X:M=0
80 V=-V
85 PLOT X,Y/3: COLOR=E: PLOT I,
K:X=I:Y=J: GOTO 60
90 PRINT “INVALID, REENTER”;
95 INPUT “ COLOR (0, TO 15)”,E:
IF E<0 OR E>15 THEN 90: RETURN

12

100 IF M THEN V= ABS (V): VLIN
K/2*2,K/2*2+1 AT I:S=S+I/29: VTAB 21: TAB 13: PRING S
105 Q= PEEK (-16336)- PEEK (-16336
)+ PEEK (-16336)- PEEK (-16336
)+ PEEK (-16336)- PEEK (-16336
)+ PEEK (-16336)- PEEK (-16336
)+ PEEK (-16336)- PEEK (-16336
)
110 IF S<720 THEN 80
115 PRINT “CONGRATULATONS, ”;A$
;” YOU WIN!”: GOTO 165
120 PRINT “YOUR SCORE OF ”;S;” IS “
;: GOTO 125+(S/100)*5
125 PRINT ”TERRIBLE!”: GOTO 165
130
135
140
145

PRINT
PRINT
PRINT
PRINT

“LOUSY.”: GOTO 165
“POOR.”: GOTO 165
“GOOD.”: GOTO 165
“VERY GOOD.”: GOTO 165

155 PRINT “EXCELLENT.”: GOTO 165
160 PRINT “NEARLY PERFECT.”
165 PRINT “ANOTHER GAME ”;A$;” (Y/N)
“;: INPUT A$: IF A$(1,1)=”Y”
THEN 25: TEXT : CALL -936:
VTAB 10: TAB 10: PRINT “GAME OV
ER”: END
170 Q=( PDL (0)-20)/6: IF Q<0 THEN
Q=0: IF Q>=34 THEN Q=34: COLOR=
D: VLIN Q,Q+5 AT 0: COLOR=A:
IF P>Q THEN 175: IF Q THEN
VLIN 0,Q-1 AT 0:P=Q: RETURN
175 IF P=Q THEN RETURN : IF Q*34
THEN VLIN Q+6,39 AT 0:P=Q:
RETURN
180 FOR I=1 TO 80:Q= PEEK (-16336
): NEXT I: GOTO 50

-.-.-.-.-.-.-.-.-.THIS IS A
COMPUTER.

APPLE

APPLE
SHORT

II

STARTREK

DESCRIPTION

-.-.-.-.-.-.-.-.-.-.-

VERSION
OF

HOW

TO

PLAY

STARTREK

ON

THE

THE UNIVERSE IS MADE UP OF 64 QUADRANTS IN AN 8 BY 8 MATRIX.
THE QUADRANT IN WHICH YOU THE ENTERPRISE ' ARE, IS IN WHITE,
AND A BLOW UP OF THAT QUADRANT IS FOUND IN THE LOWER LEFT
CORNER. YOUR SPACE SHIP STATUS IS FOUND IN A TABLE TO
THE RIGHT SIDE OF THE QUADRANT BLOW UP.
THIS IS A SEARCH AND DESTROY MISSION. THE OBJECT IS TO LONG-RANGE
SENSE FOR INFORMATION AS TO WHERE KLINGONS (K) ARE MOVE TO THAT QUADRANT,
AND DESTROY.
NUMBERS DISPLAYED FOR EACH QUADRANT DENOTE:
* OF STARS IN THE ONES PLACE
* OF BASES IN THE TENS PLACE
* OF KLINGONS IN THE HUNDREDS PLACE
AT ANY TIME DURING THE GAME, FOR INSTANCE BEFORE ONE TOTALLY
RUNS OUT OF ENERGY, OR NEEDS TO REGENERATE ALL SYSTEMS, ONE MOVES TO A
QUADRANT WHICH INCLUDES A BASE, IONS NEXT TO THAT BASE (B) AT WHICH TIME
THE BASE SELF-DESTRUCTS AND THE ENTERPRISE (E) HAS ALL SYSTEMS 'GO'
AGAIN.
TO PLAY:
1. THE COMMANDS CAN BE OBTAINED BY TYPING A '0' (ZERO) AND RETURN.
THEY ARE:
1. PROPULSION
2. REGENERATE
4. PHASERS
3. LONG RANGE SENSORS
5. PHOTON TORPEDOES
6. GALAXY RECORD
8. PROBE
7. COMPUTER
10.DAMAGE REPORT
9. SHIELD ENERGY
11.LOAD PHOTON TORPEDOES
2. THE COMANDS ARE INVOKED BY TYPING 1HE NUMBER REFERING TO THEM
FOLLOWED BY A 'RETURN'.
A. IF RESPONSE IS 1 THE COMPUTER WILL ASK WARP OR ION AND
EXPECTS 'W' IF ONE WANTS TO TRAVEL IN THE GALAXY
BETWEEN QUADRANTS AND AN 'I' IF ONE WANTS ONLY
INTERNAL QUADRANT TRAVEL.
DURATION OF WARP FACTOR IS THE NUMBER OF SPACES OR
QUADRANTS THE ENTERPRISE WILL MOVE.
COURSE IS COMPASS READING IN DEGREES FOR THE DESIRED DESTINATION.
B. A 2 REGENERATES THE ENERGY AT 1HE EXPENSE OF TIME.
C. A 3 GIVES THE CONTENTS OF THE IMMEDIATE. ADJACENT QUADRANTS.
THE GALAXY IS WRAP-AROUND IN ALL DIRECTIONS.
D. 4 FIRES PHASERS AT THE EXPENSE OF AVAILABLE ENERGY.

E. 5

INITIATES A SET OF QUESTIONS FOR TORPEDO FIRING.
THEY CAN BE FIRED AUTOMATICALLY IF THEY HAVE
BEEN LOCKED ON TARGET WHILE IN THE COMPUTER
MODE, OR MAY BE FIRED MANUALLY IF THE TRAGECTORY ANGLE
IS KNOWN.
F. 6, 8 AND 10 ALL GIVE INFORMATION ABOUT THE STATUS OF THE SHIP
AND ITS ENVIRONMENT.
G. 9 SETS THE SHIELD ENERGY/AVAILABLE ENERGY RATIO.
H. 11 ASKS FOR INFORMATION ON LOADING AND UNLOADING OF
PHOTON TORPEDOES AT THE ESPENSE OF AVAILABLE ENERGY.
THE ANSWER SHOULD BE A SIGNED NUMBER. FOR EXAMPLE
+5 OR -2.
I. 7 ENTERS A COMPUTER WHICH WILL RESPOND TO THE FOLLOWING
INSTRUCTIONS:
1. COMPUTE COURSE 2. LOCK PHASERS
3. LOCK PHOTON TORPEDOES
5. COMPUTE TREJECTORY
4. LOCK COURSE
6.STATUS
7. RETURN TO COMAND MODE
IN THE FIRST FIVE ONE WILL HAVE TO GIVE COORDINATES.
COORDINATES ARE GIVEN IN MATHMATICAL NOTATION WITH
THE EXCEPTION THAT THE 'Y' VALUE IS GIVEN FIRST.
AN EXAMPLE WOULD BE 'Y,X'
COURSE

OR

TRAJECTORY:

---------

0

270 --------------------------- 90

180

-.-.-.-.-.-.-.-

THIS

EXPLANATION WAS WRITTEN BY
NOT RESPONSIBLE FOR
ERRORS

14

ELWOOD

-.-.-.-.-.-.-.-.-

LOADING THE HI-RES DEMO TAPE

PROCEDURE
l.

Power up system - turn the AC power switch in the back
of the Apple II on. You should see a random matrix of
question marks and other text characters. If you don't,
consult the operator's manual for system checkout procedures.

2.

Hit the RESET key. On the left hand side of the screen
you should see an asterisk and a flashing cursor next to
it below the text matrix.

3.

Insert the HI-RES demo tape into the cassette and rewind
it. Check Volume (5Ø-7Ø%) and Tone (8Ø-1ØØ%) settings.

4.

Type in "CØØ.FFFR" on the Apple II keyboard. This is the
address range of the high resolution machine language subprogram. It extends from $CØØ to $FFF. The R tells the
computer to read in the data. Do not depress the "RETURN"
key yet.

5.

Start the tape recorder in playback mode and depress the
"RETURN" key. The flashing cursor disappears.

6.

A beep will sound after the program has been read in.
STOP the tape recorder. Do not rewind the program tape yet.

7.

Hold down the "CTRL" key, depress and release the B key,
then depress the "RETURN" key and release the "CTRL" key.
You should see a right facing arrow and a flashing cursor.
The Bc command places the Apple into BASIC initializing
the memory pointers.

8.

Type in "LOAD", restart the tape recorder in playback mode
and hit the "RETURN" key. The flashing cursor disappears.
This begins the loading of the BASIC subprogram of the
HI-RES demo tape.

9. A beep will sound to indicate the program is being loaded.

15

l0. A second beep will sound, and the right facing arrow
will reappear with the flashing cursor. STOP the
tape recorder. Rewind the tape.
ll.

Type in "HIMEM:8l92" and hit the "RETURN" key. This
sets up memory for high resolution graphics.

l2. Type in "RUN" and hit the "RETURN" key. The screen
should clear and momentarily a HI-RES demo menu table
should appear. The loading sequence is now completed.
SUMMARY OF HI-RES DEMO TAPE LOADING

l.

RESET

2.

Type in CØØ.FFFR

3.

Start tape recorder, hit RETURN

4.

Asterick or flashing cursor reappear
Bc (CTRL B) into BASIC

5.

Type in "LOAD", hit RETURN

6.

BASIC prompt (7) and flashing cursor
reappear. Type in "HIMEN:8192", hit
RETURN

7. Type in "RUN", hit RETURN
8.

STOP tape recorder, rewind tape.

16

APPLE II INTEGER BASIC
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

BASIC Commands
BASIC Operators
BASIC Functions
BASIC Statements
Special Control and Editing
Table A — Graphics Colors
Special Controls and Features
BASIC Error Messages
Simpfilied Memory Map
Data Read Save Subroutines
Simple Tone Subroutires
High Resolution Graphics
Additional BASIC Program Examples

BASIC COMMANDS
Commands are executed immediately; they do not require line numbers.Most Statements
(see Basic Statements Section) may also be used as commands. Remember to press
Return key after each command so that Apple knows that you have finished that
line. Multiple commands (as opposed to statements) on same line separated by
a " : " are NOT allowed.
COMMAND NAME
AUTO num

Sets automatic line numbering mode. Starts at line
number num and increments line numbers by 10. To
exit AUTO mode, type a control X*, then type the
letters "MAN" and press the return key.

AUTO num1, num2

Same as above execpt increments line numbers by
number num2.

CLR

Clears current BASIC variables; undimensions arrays.
Program is unchanged.

CON

Continues program execution after a stop from a
control C*. Does not change variables.

DEL num1,

Deletes line number num1.

DEL num1, num2

Deletes program from line number num1 through line
number num2.

DSP var

Sets debug mode that will display variable var every
time that it is changed along with the line number
that caused the change. (NOTE: RUN command clears
DSP mode so that DSP command is effective only if
program is continued by a CON or GOTO command.)

HIMEM expr

Sets highest memory location for use by BASIC at
location specified by expression expr in decimal.
HIMEM: may not be increased without destroying program.
HIMEM: is automatically set at maximum RAM memory when
BASIC is entered by a control B*.

GOTO expr

Causes immediate jump to line number specified by
expression expr.

GR

Sets mixed color graphics display mode. Clears screen
to black. Resets scrolling window. Displays 4Øx4Ø
squares in 15 colors on top of screen and 4 lines of text
at bottom.

LIST
LIST num1
LIST num1, num2

Lists entire program on screen.
Lists program line number num1.
Lists program line number num1 through line number
num2.

18

LOAD expr.

Reads (Loads) a BASIC program from cassette tape.
Start tape recorder before hitting return key. Two
beeps and a " > " indicate a good load. "ERR" or "MEM"
FULL ERR" message indicates a bad tape or poor recorder
performance.

LOMEM: expr

Similar to HIMEM: except sets lowest memory location
available to BASIC. Automatically set at 2Ø48 when
BASIC is entered with a control B*. Moving LOMEM:
destroys current variable values.

MAN

Clears AUTO line numbering mode to all manual line
numbering after a control C* or control X*.

NEW

Clears (Scratches) current BASIC program.

NO DSP var

Clears DSP mode for variable var.

NO TRACE

Clears TRACE mode.

RUN

Clears variables to zero, undimensions all arrays and
executes program starting at lowest statement line
number.

RUN expr

Clears variables and executes program starting at line
number specified by expression expr.

SAVE

Stores (saves) a BASIC program on a cassette tape.
Start tape recorder in record mode prior to hitting
return key.

TEXT

Sets all text mode. Screen is formated to display
alpha-numeric characters on 24 lines of 4Ø characters
each. TEXT resets scrolling window to maximum.

TRACE

Sets debug mode that displays line number of each
statement as it is executed.
Control characters such as control X or control C are
typed by holding down the CTRL key while typing the
specified letter. This is similiar to how one holds
down the shift key to type capital letters. Control
characters are NOT displayed on the screen but are
accepted by the computer. For example, type several
control G's. We will also use a superscript C to indicate
a control character as in Xc.

19

BASIC Operators
Symbol

Sample Statement

Prefix Operators
( )
lØ X= 4*(5 + X)

Explanation
Expressions within parenthesis ( )
are always evaluated first.

+

2Ø X= 1+4*5

Optional; +l times following expression.

-

3Ø ALPHA =
-(BETA +2)

Negation of following expression.

NOT

4Ø IF A NOT B THEN
2ØØ

Logical Negation of following expression;
Ø if expression is true (non-zero), l
if expression is false (zero).

Arithmetic Operators
6Ø Y = X 3
*

/

Exponentiate as in X3 . NOTE:
shifted letter N.

is

7Ø LET DOTS=A*B*N2

Multiplication. NOTE: Implied multiplication such as (2 + 3)(4) is not
allowed thus N2 in example is a variable
not N * 2.

8Ø PRINT GAMMA/S

Divide

9Ø X = 12 MOD 7
lØØ X = X MOD(Y+2)

Modulo: Remainder after division of
first expression by second expression.

+

llØ P = L + G

Add

-

l2Ø XY4 = H-D

Substract

=

l3Ø
l4Ø
l5Ø
l55

Assignment operator; assigns a value to
a variable. LET is optional

MOD

HEIGHT=15
LET SIZE=7*5
A(8) = 2
ALPHA$ = "PLEASE"

20

Relational and Logical Operators
The numeric values used in logical evaluation are "true" if non-zero,
"false" if zero.

Symbol

Sample Statement

Explanation

=

l6Ø
IF D = E
THEN 5ØØ

Expression "equals" expression.

=

l7Ø

IF A$(l,l)=
"Y" THEN 5VV

String variable "equal'string variable.

l8Ø
IF ALPHA #X*Y
THEN 5ØØ

Expression "does not equal" expression.

#

l9Ø
IF A$ # "NO"
THEN 5ØØ

String variable "does not equal" string
variable. NOTE: If strings are not
the same length, they are considered
un-equal. < > not allowed with strings.

>

2ØØ
IF A>B
THEN GO TO 5Ø

Expression "is greater than" expression.

<

2lØ
IF A+l=

22Ø
IF A>=B
THEN 1ØØ

Expression "is greater than or equal to"
expression.

<=

23Ø
IF A+l<=B-6
THEN 2ØØ

Expression "is less than or equal to"
expression.

AND

24Ø
IF A>B AND
C

21

BASIC FUNCTIONS
Functions return a numeric result. They may be used as expressions or as part
of expressions. PRINT is used for examples only, other statements may
be used. Expressions following function name must be enclosed between two
parenthesis signs.
FUNCTION NAME
ABS (expr)

300 PRINT ABS(X)

ASC (str$)

310
320
330
335

LEN (str$)

Gives absolute value of the expression expr.

PRINT
PRINT
PRINT
PRINT

ASC("BACK") Gives decimal ASCII value of designated
ASC(3$)
string variable str. If more than one
ASC(B$(4,4))character is in designated string or
ASC(B$(Y)) sub-string, it gives decimal ASCII
value of first character.
340 PRINT LEN(B$)
Gives current length of designated
string variable str$;i.e., number of
characters.

PDL (expr)

350 PRINT PDL(X)

Gives number between Ø and 255 corresponding
ponding to paddle position on game paddle
number designated by expression expr and must
be legal paddle (Ø,1,2,or 3) or else 255 is
returned.

PEEK (expr)

360 PRINT PEEK(X)

Gives the decimal value of number stored
of decimal memory location specified by
expression expr. For MEMORY locations
above 32676, use negative number; i.e.,
HEX location FFFØ is -16

RND (expr)

370 PRINT RND(X)

Gives random number between V and
(expression expr -1) if expression expr
is positive; if minus, it gives random
number between Ø and (expression expr +1).

SCRN(expr1,
expr2)

380 PRINT SCRN (X1,Y1)Gives color (number between Ø and 15) of
screen at horizontal location designated
by expression exprl and vertical
location designated by expression expr2
Range of expression exprl is Ø to 39. Range
of expression expr2 is Ø to 39 if in standar
mixed colorgraphics display mode as set by
GR command or Ø to 47 if in all color mode
set by POKE -163Ø4 ,Ø: POKE - 163Ø2,Ø'.

SGN (expr)

39Ø PRINT SGN(X)

Gives sign (not sine) of expression expr
i.e., -1 if expression expr is negative,zero
zero and +1 if expr is positive.

22

BASIC STATEMENTS
Each BASIC statement must have a line number between Ø and 32767. Variable
names must start with an alpha character and may be any number of alphanumeric characters up to 1ØØ.
Variable names may not contain buried any
of the following words: AND, AT, MOD, OR, STEP, or THEN. Variable names may
not begin with the letters END, LET, or REM. String variables names must end
with a $ (dollar sign). Multiple statements may appear under the same line number
if separated by a : (colon) as long as the total number of characters in the line
(including spaces) is less than approximately 15Ø characters
Most statements may also be used as commands. BASIC statements are executed
by RUN or GOTO commands.
NAME
CALL expr

1Ø CALL-936

Causes execution of a machine level
language subroutine at decimal memory
location specified by expression expr
Locations above 32767 are specified using
negative numbers; i.e., location in
example 1Ø is hexidecimal number $FC53

COLOR=expr

3Ø COLOR=12

In standard resolution color (GR)
graphics mode, this command sets screen
TV color to value in expression expr
in the range Ø to 15 as described in
Table A. Actually expression expr may be
in the range Ø to 255 without error message
since it is implemented as if it were
expression expr MOD 16.

DIM varl (expr1)
str$ (expr2)
var2 (expr3)

5Ø DIM A(2Ø),B(1Ø)
6Ø DIM B$(3Ø)
7Ø DIM C (2)
Illegal:
8Ø DIM A(3Ø)
Legal:
85 DIM C(1ØØØ)

The DIM statement causes APPLE II to
reserve memory for the specified variables.
For number arrays
APPLE reserves
approximately 2 times expr bytes of memory
limited by available memory. For string
arrays -str$- (expr) must be in the range of
1 to 255. Last defined variable may b'e
redimensioned at any time; thus, example
in line is illegal but 85 is allowed.

DSPvar

Legal:
9Ø DSP AX: DSP L
Illegal:
1ØØ DSP AX,B
1Ø2 DSP AB$
1Ø4 DSP A(5)
Legal:
1Ø5 A=A(5): DSP A

Sets debug mode that DSP variable var each
time it changes and the line number where the
change occured.

23

NAME

DESCRIPTION

EXAMPLE

END

11Ø END

Stops program execution. Sends carriage
return and "> " BASIC prompt) to screen.

FOR var=
exp'21 TOexpr2
STEPexpr3

11Ø
12Ø
13Ø
15Ø

Begins FOR...NEXT loop, initializes
variable var to value of expression expr1
then increments it by amount in expression
expr3 each time the corresponding "NEXT"
statement is encountered, until value of
expression expr2 is reached. If STEP expr3
is omitted, a STEP of +1 is assumed. Negative
numbers are allowed.

GOSUB expr

14Ø GOSUB 5ØØ

Causes branch to BASIC subroutine starting
at legal line number specified by expression
expr
Subroutines may be nested up to
16 levels.

GOTO expr

16Ø GOTO 2ØØ
17Ø GOTO ALPHA+1ØØ

Causes immediate jump to legal line
number specified by expression expr.

GR

18Ø GR
19Ø GR: POKE -163Ø2,Ø

Sets mixed standard resolution color
graphics mode. Initializes COLOR = Ø
(Black) for top 4Øx4Ø of screen and sets
scrolling window to lines 21 through 24
by 4Ø characters for four lines of text
at bottom of screen. Example 19Ø sets
all color mode (4Øx48 field) with no text
at bottom of screen.

2ØØ HLIN Ø,39 AT 2Ø
21Ø HLIN Z,Z+6 AT I

In standard resolution color graphics mode,
this command draws a horizontal line of a
predefined color (set by COLOR=) starting
at horizontal position defined by expression
exprl and ending at position expr2 at
vertical position defined by expression
expr3 .expr1 and expr2 must be in the range
of Ø to 39 and expr1 < = expr2 . expr3
be in the range of Ø to 39 (or Ø to 47 if not
in mixed mode).

HLIN expr1,
expr2ATexpr3

Note:

FOR L=Ø to 39
FOR X=Y1 TO Y3
FOR 1=39 TO 1
GOSUB 1ØØ *J2

HLIN Ø, 19 AT Ø is a horizontal line at the top of the screen
extending from left corner to center of screen and HLIN 2Ø,39 AT
39 is a horizontal line at the bottom of the screen extending from
center to right corner.

24

22Ø IF A> B THEN
PRINT A
23Ø IF X=Ø THEN C=1
24Ø IF A#1Ø THEN
GOSUB 2ØØ
25Ø IF A$(1,1)# "Y"
THEN 1ØØ
Illegal:
26Ø IF L> 5 THEN 5Ø:
ELSE 6Ø
Legal:
27Ø IF L> 5 THEN 5Ø
GO TO 6Ø

IF expression
THEN statement

INPUT varl,
var2, str$

If expression is true (non-zero) then
execute statement;
if false do not
execute statement.
If statement
is an expression, then a GOTO expr
type of statement is assumed to be implied.
The "ELSE" in example 26Ø is illegal but
may be implemented as shown in example 27Ø.

28Ø INPUT X,Y,Z(3)
29Ø INPUT "AMT",
DLLR
3ØØ INPUT "Y or N?", A$

Enters data into memory from I/O
device. If number input is expected,
APPLE wil output "?"; if string input is
expected no "?" will be outputed. Multiple
numeric inputs to same statement may be
separated by a comma or a carriage return.
String inputs must be separated by a
carriage return only. One pair of " " may
be used immediately after INPUT to output
prompting text enclosed within the quotation
marks to the screen.

IN# expr

31Ø IN# 6
32Ø IN# Y+2
33Ø IN# 0

Transfers source of data for subsequent
INPUT statements to peripheral I/O slot
(1-7) as specified as by expression expr.
Slot Ø is not addressable from BASIC.
IN#Ø (Example 33Ø) is used to return data
source from peripherial I/O to keyboard
connector.

LET

34Ø LET X=5

Assignment operator.

LIST num1,
num2

35Ø IF X>6 THEN

Causes program from line number num1
through line number num2 to be displayed
on screen.

NEXT varl,
var2

36Ø NEXT I
37Ø NEXT J,K

Increments corresponding "FOR" variable
and loops back to statement following
"FOR" until variable exceeds limit.

NO DSP var

38Ø NO DSP I

Turns-off DSP debug mode for variable

NO TRACE

39Ø NO TRACE

Turns-off TRACE debug mode

25

"LET" is optional

PLOT expr1, expr2

4ØØ PLOT 15, 25
4ØØ PLT XV,YV

In standard resolution color
graphics, this command plots a small
square of a predefined color (set
by COLOR=) at horizontal location
specified by expression expr1 in
range Ø to 39 and vertical location
specified by expression expr2 in range
Ø to 39 (or Ø to 47 if in all graphics
mode) NOTE: PLOT Ø Ø is upper left
and PLOT 39, 39 (or PLOT 39, 47) is
lower right corner.

POKE expr1, expr2

42Ø POKE 2Ø, 4Ø
430 POKE 7*256,
XMOD25E

Stores decimal number defined by
expression expr2 in range of Ø
255 at decimal memory location
specified by expression expr1
Locations above 32767 are specified
by negative numbers.

POP

44Ø POP

"POPS" nested GOSUB return stack
address by one.

PRINT var1, var, str$

45Ø
46Ø
47Ø
48Ø
49Ø
492
494

PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT

Ll
Li, X2
"AMT=";DX
A$;B$;
"HELLO"
2+3

Outputs data specified by variable
var or string variable str$ starting
at current cursor location. If there
is not trailing "," or ";" (Ex 45Ø)
a carriage return will be generated.
Commas (Ex. 46Ø) outputs data in 5
left justified columns. Semi-colon
(Ex. 47Ø) inhibits print of any spaces.
Text imbedded in " " will be printed
and may appear multiple times.

PR# expr

500 PR# 7

Like IN#, transfers output to I/O
slot defined by expression expr PR#
Ø is video output not I/O slot Ø.

REM

5l0 REM REMARK

No action. All characters after REM
are treated as a remark until terminated
by a carriage return.

RETURN

52Ø RETURN
53Ø IFX= 5 THEN
RETURN

Causes branch to statement following
last GOSUB; i.e., RETURN ends a
subroutine. Do not confuse "RETURN"
statement with Return key on keyboard.

26

TAB expr

53Ø TAB 24
54Ø TAB 1+24
55Ø IF A#B THEN
TAB 2Ø

Moves cursor to absolute horizontal
position specified by expression
expr in the range of 1 to 4Ø. Position
is left to right

TEXT

55Ø TEXT
56Ø TEXT: CALL-936

Sets all text mode. Resets
scrolling window to 24 lines by 4Ø
characters. Example 56Ø also clears
screen and homes cursor to upper left
corner

TRACE

570 TRACE
580 IFN >32ØØØ

Sets debug mode that displays each
line number as it is executed.
THEN TRACE

VLIN exprl, expr2
AT expr3

59Ø VLIN Ø, 39AT15
6ØØ VLIN Z,Z+6ATY

Similar to HLIN except draws vertical
line starting at expr1 and ending at
expr2 at horizontal position expr3.

VTAB expr

61Ø VTAB 18
62Ø VTAB Z+2

Similar to TAB. Moves cursor to
absolute vertical position specified
by expression expr in the range l to
24. VTAB l is top line on screen;
VTAB24 is bottom.

27

SPECIAL CONTROL AND EDITING CHARACTERS
"Control" characters are indicated by a super-scripted "C" such as Gc. They
are obtained by holding down the CTRL key while typing the letter.
Control characters are NOT displayed on the TV screen. B and C must be
followed by a carriage return. Screen editing characters are indicated by a
sub-scripted "E" such as DE. They are obtained by pressing and releasing the
ESC key then typing specified letter. Edit characters send information only
to display screen and does not send data to memory. For example, Uc moves to
cursor to right and copies text while AE moves cursor to right but does not
copy text.
CHARACTER

DESCRIPTION OF ACTION

RESET key

Immediately interrupts any program execution and resets
computer. Also sets all text mode with scrolling window
at maximum. Control is transfered to System Monitor and
Apple prompts with a "*" (asterisk) and a bell. Hitting
RESET key does NOT destroy existing BASIC or machine
language program.

Control B

If in System Monitor (as indicated by a "*"), a control
B and a carriage return will transfer control to BASIC,
scratching (killing) any existing BASIC program and set
HIMEM: to maximum installed user memory and LOMEM:
to 2048.

Control C

If in BASIC, halts program and displays line number
where stop occurred*. Program may be continued with a
CON command. If in System Monitor, (as indicated by "*"),
control C and a carraige return will enter BASIC without
killing current program.

Control G

Sounds bell (beeps speaker)
Backspaces cursor and deletes any overwritten characters
from computer but not from screen. Apply supplied
keyboards have special key "÷" on right side of keyboard
that provides this functions without using control button.

Control H

Control 3

Issues line feed only

Control V

Compliment to HC. Forward spaces cursor and copies over
written characters. Apple keyboards have H-0 key on
right side which also performs this function.

Control X

Immediately deletes current line.
*

If BASIC program is expecting keyboard input, you will have
to hit carriage return key after typing control C.

28

CHARACTER

DESCRIPTION OF ACTION

A

Move cursor to right

B
C
D
E
F
@

E

Move cursor to left

E

Move cursor down

E

Move cursor up

E

Clear text from cursor to end of line

E

Clear text from cursor to end of page

E

Home cursor to top of page, clear text to end
of page.

E

Table A:

APPLE II COLORS AS SET BY COLOR =

Note:

Colors may vary depending on TV tint (hue) setting and may also
be changes by adjusting trimmer capacitor C3 on APPLE II P.C. Board.
0
1
2
3
4
5
6
7

=
=
=
=
=
=
=
=

Black
Magnenta
Bark Blue
Light Purple
Dark Green
Grey
Medium Blue
Light Blue

8
9
10
11
12
13
14
15

29

=
=
=
=
=
=
=
=

Brown
Orange
Grey
Pink
Green
Yellow
Blue/Green
White

Special Controls and Features
Hex

BASIC Example

Description

Display Mode Controls
CO5Ø
CO51
CO52
CO53
CO54

lØ
2Ø
3Ø
4Ø
5Ø

POKE
POKE
POKE
POKE
POKE

-l63Ø4,Ø
-l63Ø3,Ø
-l63Ø2,Ø
-l63Ø1,Ø
-l63ØØ,Ø

CO55
CO56
CO57

6Ø
7Ø
8Ø

POKE -l6299,Ø
POKE -l6298,Ø
POKE -l6297,Ø

Set color graphics mode
Set text mode
Clear mixed graphics
Set mixed graphics (4 lines text)
Clear display Page. 2 (BASIC commands
use Page l only)
Set display to Page 2 (alternate)
Clear HIRES graphics mode
Set HIRES graphics mode

TEXT Mode Controls
ØØ2Ø

9Ø POKE 32,L1

Set left side of scrolling window
to location specified by Ll in
range of Ø to 39.

ØØ21

1ØØ POKE 33,W1

Set window width to amount specified
by WI. Ll+W1<4Ø. Wl>Ø

ØØ22

11Ø POKE 34,11

Set window top to line specified
by Tl in range of Ø to 23

ØØ23

12Ø POKE 35,B1

Set window bottom to line specified
by Bl in the range of Ø to 23. B1>T1

ØØ24

13Ø CH=PEEK(36)
14Ø POKE 36,CH
15Ø TAB(CH+l)

ØØ25

16Ø CV=PEEK (37)
17Ø POKE 37,CV
18Ø VTAB(CV+l)

Read/set cusor horizontal position
in the range of Ø to 39. If using
TAB, you must add "1" to cusor positior
read value; Ex. 14Ø and 15Ø perform
identical function.

ØØ32

19Ø POKE 5Ø,l27
2ØØ POKE 5Ø,255

Set inverse flag if 127 (Ex. l9Ø)
Set normal flag if 255(Ex. 2ØØ)

FC58

21Ø CALL -936

(@E) Home cusor, clear screen

FC42

22Ø CALL -958

(FE) Clear from cusor to end of page

Similar to above. Read/set cusor vertical
position in the range Ø to 23.

30

Hex

BASIC Example

Description

FC9C

23Ø CALL -868

(EE) Clear from cusor to end of line

FC66

24Ø CALL -922

(JC) Line feed

FC7Ø

25Ø CALL -9l2

Scroll up text one line

Miscellaneous
CØ3Ø

36Ø X=PEEK(-l6336)
365 POKE -l6336,Ø

Toggle speaker

CØØØ

37Ø X=PEEK(-16384

Read keyboard; if X>127 then key was
pressed.

CØlØ

38Ø POKE -l6368,Ø

Clear keyboard strobe - always after
reading keyboard.

CØ6l

39Ø X=PEEK(16287)

Read PDL(Ø) push button switch. If
X>l27 then switch is "on".

CØ62

4ØØ X=PEEK(-l6286)

Read PDL(l) push button switch.

CØ63

4lØ X=PEEK(-l6285

Read PDL(2) push button switch.

CØ58

42Ø POKE -l6296,Ø

Clear Game I/O ANØ output

CØ59

43Ø POKE -l6295,Ø

Set Game I/O ANØ output

CØ5A

44Ø POKE -l6294,Ø

Clear Game I/O ANl output

CØ5B

45Ø POKE -l6293,Ø

Set Game I/O ANl output

CØ5C

46Ø POKE -l6292,Ø

Clear Game I/O AN2 output

CØ5D

47Ø POKE -l629l,Ø

Set Game I/O AN2 output

CØ5E

48Ø POKE -l629Ø,Ø

Clear Game I/O AN3 output

CØ5F

49Ø POKE -l6289,Ø

Set Game I/O AN3 output

31

APPLE II BASIC ERROR MESSAGES

*** SYNTAX ERR

Results from a syntactic or typing error.

*** > 32767 ERR

A value entered or calculated was less than
-32767 or greater than 32767.

*** > 255 ERR

A value restricted to the range Ø to 255 was
outside that range.

*** BAD BRANCH ERR

Results from an attempt to branch to a nonexistant line number.

*** BAD RETURN ERR

Results from an attempt to execute more RETURNs
than previously executed GOSUBs.

*** BAD NEXT ERR

Results from an attempt to execute a NEXT statement for which there was not a corresponding
FOR statement.

*** 16 GOSUBS ERR

Results from more than l6 nested GOSUBs.

*** 16 FORS ERR

Results from more than l6 nested FOR loops.

*** NO END ERR

The last statement executed was not an END.

*** MEM FULL ERR

The memory needed for the program has exceeded
the memory size allotted.

*** TOO LONG ERR

Results from more than l2 nested parentheses or
more than l28 characters in input line.

*** DIM ERR

Results from an attempt to DIMension a string
array which has been previously dimensioned.

*** RANGE ERR

An array was larger than the DIMensioned
value or smaller than l or HLIN,VLIN,
PLOT, TAB, or VTAB arguments are out of
range.

*** STR OVFL ERR

The number of characters assigned to a string
exceeded the DIMensioned value for that string.

*** STRING ERR

Results from an attempt to execute an illegal
string operation.

RETYPE LINE

Results from illegal data being typed in response
to an INPUT statement. This message also requests
that the illegal item be retyped.

32

Simplified Memory Map

FFFF

64K

Monitor and BASIC Routines in ROM

EØØØ

56K

Future enhancement or user supplied
PROMS

DØØØ

52K

C6ØØ

48K

XX

XX
(HIMEM:)

Peripheral I/O

User specified RAM memory size

User Workspace

7FF

(LOMEM:)
2K

4ØØ

1K

Ø

Ø

Screen Memory

Internal Workspace

33

READ/SAVE DATA SUBROUTINE

INTRODUCTION
Valuable data can be generated on the Apple II computer and sometimes
it is useful to have a software routine that will allow making a permanent
record of this information. This paper discusses a simple subroutine that
serves this purpose.
Before discussing the Read/Save routines a rudimentary knowledge of
how variables are mapped into memory is needed.
Numeric variables are mapped into memory with four attributes. Appearing
in order sequentually are the Variable Name, the Display Byte, the Next Variable
Address, and the Data of the Variable. Diagramatically this is represented as:
YN

DSP

NVA

DATA(0)
h
l

l

DATA(l)
h2

VARIABLE NAME - up to 100 characters
represented in memory as ASCII equivalents with the high order bit set.
DSP (DISPLAY) BYTE - set to 0l when
DSP set in BASIC initiates a process
that displays this variable with the
line number every time it is changed
within a program.
NVA (NEXT VARIABLE ADDRESS) - two
bytes (first low order, the second
high order) indicating the memory
location of the next variable.
DATA - hexadecimal equivalent of
numeric information, represented
in pairs of bytes, low order byte
first.

34

,

DATA(N)
hn+l

String variables are formatted a bit differently than numeric ones.
These variables have one extra attribute - a string terminator which designates the end of a string. A string variable is formatted as follows:
VN
l

DSP

NVA

DATA(Ø)

DATA(l)....

hl

DATA(n)

h2

ST

hn+l

VARIABLE NAME - up to lØØ characters
represented in memory as ASCII equivalents with the high order bit set.
DSP (DISPLAY) BYTE - set to Øl when
DSP set in BASIC, initiates a process
that displays this variable with the
line number every time it is changed
within a program.
NVA (NEXT VARIABLE ADDRESS) - two
bytes (first low order, the second
high order) indicating the memory
location of the next variable.
DATA - ASCII equivalents with high
order bit set.
STRING TERMINATOR (ST) - none high
order bit set character indicating
END of string.
There are two parts of any BASIC program represented in memory. One is
the location of the variables used for the program, and the other is the actual
BASIC program statements. As it turns out, the mapping of these within memory
is a straightforward process. Program statements are placed into memory starting
at the top of RAM memory* unless manually shifted by the "HIMEM:." command, and
are pushed down as each new (numerically larger) line numbered statement is
entered into the system. Figure la illustrates this process diagramatically.
Variables on the other hand are mapped into memory starting at the lowest position
of RAM memory - hex $8ØØ (2Ø48) unless manually shifted by the"LOMEM:" command.
They are laid down from there (see Figure lb) and continue until all the variables
have been mapped into memory or until they collide with the program statements.
In the event of the latter case a memory full error will be generated

*Top of RAM memory is a function of the amount of memory.
l6384 will be the value of "HIMEM:" for a l6K system.
35

The computer keeps track of the amount of memory used for the variable
table and program statements. By placing the end memory location of each into
$CC-CD(2Ø4-2Ø5) and $CA-CB(2Ø3-2Ø4), respectively. These are the BASIC
memory program pointers and their values can be found by using the statements
in Figure 2. CM defined in Figure 1 as the location of the end of the variable
tape is equal to the number resulting from statement a of Figure 2. PP, the
program pointer, is equal to the value resulting from statement 2b. These
statements(Figure 2) can then be used on any Apple II computer to find the
limits of the program and variable table.
FINDING THE VARIABLE TABLE FROM BASIC
First, power up the Apple II, reset it, and use the CTRL B (control B)
command to place the system into BASIC initializing the memory pointers. Using
the statements from Figure 2 it is found that for a 16K Apple II CM is equal to
2Ø48 and PP is equal to 16384. These also happen to be the values of OMEN and
HIMEN: But this is expected because upon using the Bc command both memory
pointers are initialized indicating no program statements and no variables.
To illustrate what a variable table looks like in Apple II memory suppose
we want to assign the numeric variable A ($C1 is the ASCII equivalent of a with
the high order bit set) the value of -1 (FF FF in hex) and then examine the
memory contents. The steps in this process are outlined in example I. Variable A
is defined as equal to -1 (step 1). Then for convenience another variable - B is defined as equal to Ø (step 2). Now that the variable table has been defined
use of statement 2a indicates that CM is equal to 2Ø6Ø (step 3). LOMEN has not
been readjusted so it is equal to 2Ø48. Therefore the variable table resides in
memory from 2Ø48 ($8ØØ hex) to 2Ø6Ø ($88C). Depressing the "RESET" key places
the Apple II into the monitor mode (step 4).
We are now ready to examine the memory contents of the variable table.
Since the variable table resides from $8ØØ hex to $8ØC hex typing in "8ØØ.8ØC"
and then depressing the "RETURN" key (step 5) will list the memory contents of
this range. Figure 3 lists the contents with each memory location labelled.
Examining these contents we see that Cl is equal to the variable name and is the
memory equivalent of "A" and that FF FF is the equivalent of -1. From this, since
the variable name is at the beginning of the table and the data is at the end, the
variable table representation of A extends from $8ØØ to $8O5. We have then found

36

the memory range of where the variable A is mapped into memory.
The reason forthis will become clear in the next section.
READ/SAVE ROUTINE
The READ/SAVE subroutine has three parts. The first section (lines Ø-1Ø)
defines variable A and transfers control to the main program. Lines 2Ø through
26 represents the Write data to tape routine and lines 3Ø-38 represent the Read
data from tape subroutine. Both READ and SAVE routines are executable by the
BASIC "GOSUB X" (where X is 2Ø for write and 3Ø is for read) command. And as
listed these routines can be directly incorporated into almost any BASIC program
for read and saving a variable table. The limitation of these routines is that
the whole part of a variable table is processed so it is necessary to maintain
exactly the dimension statements for the variables used.
The variables used in this subroutine are defined as follows:
A =

record length, must be the first variable defined

CM=

the value obtained from statement a of figure 2

LW=

is equal to the value of "LOMEM:"
Nominally 2Ø48

SAVING A DATA TABLE
The first step in a hard copy routine is to place the desired data onto
tape. This is accomplished by determining the length of the variable table and
setting A equal to it. Next within the main program when it is time to write the
data a GOSUB2Ø statement will execute the write to tape process. Record length,
variable A, is written to tape first (line 22) followed by the desired data
(line 24). When this process is completed control is returned to the main program.
READING A DATA TABLE
The second step is to read the data from tape. When it is time a GOSUB3Ø
statement will initiate the read process. First, the record length is read in
and checked to see if enough memory is available (line 32-34). If exactly the
same dimension statements are used it is almost guaranteed that there will be
enough memory available. After this the variable table is read in (line 34) and
control is then returned to the main program (line 36). If not enough memory
is available then an error is generated and control is returned to the main program (line 38)

37

EXAMPLE OF READ/SAVE USAGE
The Read/Save routines may be incorporated directly into a main program.
To illustrate this a test program is listed in example 2. This program dimensions
a variable array of twenty by one, fills the array with numbers, writes the data
table to tape, and then reads the data from tape listing the data on the video
display. To get a feeling for how to use these routines enter this program and
explore how the Read/Save routines work.
CONCLUSION
Reading and Saving data in the format of a variable table is a relatively
straight forward process with the Read/Save subroutine listed in figure 4. This
routine will increase the flexibility of the Apple II by providing a permanent
record of the data generated within a program. This program can be reprocessed.
The Read/Save routines are a valuable addition to any data processing program.

38

Varl

Var2 ....... Varn

Unused
Memory

CM End of
Variable
Table

LOMEN:
$8ØØ

Pl

P3 ... Pn-2

P2

Pn-l

HIMEM
Max System
Size

PP beginning
of
Program

a

b
Variable Data

BASIC Program

Figure 1

a) PRINT PEEK(2Ø4) + PEEK(2Ø5)*256

PP

b) PRINT PEEK(2Ø2) + PEEK(2Ø3)*256

CM

Figure 2

8ØØ
Cl

8Ø1
ØØ

VAR
NAM

DSP

8Ø2 8Ø3
Ø8
Ø6
L
H
NVA

8Ø4 8Ø5
FF
FF
L
H
DATA

8Ø6
C2

8Ø7
ØØ

VAR
NAM

DSP

8Ø8 8Ø9
OC
Ø8
L
H
NVA

Figure 3
$8ØØ.8ØC rewritten with labelling

39

Pn

8ØA
ØØ

8ØB
ØØ

DATA

8ØC
ØØ

FIGURE 4b

READ/SAVE PROGRAM

COMMENTS

Ø

A=Ø

This must be the first statement in the
program. It is initially Ø, but if data
is to be saved, it will equal the length
of the data base.

1Ø

GOTO 1ØØ

This statement moves command to the main
program.

2Ø

PRINT "REWIND TAPE THEN
START TAPE RECORDER":
INPUT "THEN HIT RETURN",
B$

Lines 20-26 are the write data to tape
subroutine.

22

A=CM-LM: POKE 6Ø,4:
POKE 6l,8: POKE 62,5:
POKE 63,8: CALL -3Ø7

24

POKE
POKE
POKE
POKE
CALL

26

PRINT "DATA TABLE SAVED":
RETURN

Returning control to main program.

3Ø

PRINT "REWIND THE TAPE
THEN START TAPE RECORDER":
INPUT "AND HIT RETURN",
B$

Lines 30-38 are the READ data from tape
subroutine.

32

POKE 6Ø,4: POKE 6l,8:
POKE 62,5: POKE 63,8:
CALL -259

34

IF AHM THEN 38: CM=P:
POKE 6Ø, LM MOD 256:
POKE 6l, LM/256: POKE 52,
CM MOD 256: POKE 63, CM/256:
CALL -259

36

PRINT "DATA READ IN":
RETURN

38

PRINT "***TOO MUCH DATA
BASE***": RETURN

6Ø,LM MOD 256:
61, LM/256:
62, CM MOD 256:
63, CM/256:
-3Ø7

Writing data table to tape

Checking the record length (A) for memory
requirements if everything is satisfactory
the data is READ in.

Returning control to main program.

NOTE: CM, LM and A must be defined within the main program.
40

l

>A=l
>

Define variable A=-l, then hit RETURN

2

B=Ø
>

Define variable B=Ø, then hit RETURN

3

>PRINT PEEK (2Ø4) + PEEK
(2Ø5) * 256

Use statement 2a to find the end of
the VARIABLE TABLE

computer responds with=
2Ø6Ø
4

>
*

Hit the RESET key, Apple moves into
Monitor mode.

5

*8ØØ.8ØC

Type in VARIABLE TABLE RANGE and HIT
the RETURN KEY.

Computer responds with:
Ø8ØØ- Cl ØØ 86 Ø8 FF FF C2 ØØ
Ø8Ø8

ØC Ø8 ØØ ØØ ØØ

Example l

41

Example 2

>LIST
0 A=0
10 GOTO 100
20 REM WRITE DATA TO TAPE ROUTINE
22 A=CM-LM: POKE 60,4: POKE 61
,8: POKE 62,5: POKE 63,8: CALL
-307
24 POKE 60,LM MOD 256: POKE 61
,LM/256: POKE 62,CM MOD 256
: POKE 63, CM/256: CALL -307

110 PRINT “20 NUMBERS GENERATED”

26 RETURN
30 REM READ DATA SUBROUTINE
32 POKE 60,4: POKE 61,8: POKE
62,5: POKE 63,8: CALL -259
34 IF A<0 THEN 38:P=LM+A: IF P>
HM THEN 38: CM=P: POKE 60,LM MOD
256: POKE 61,LM/256: POKE 62
,CM MOD 256: POKE 63,CM/256
: CALL - 259
36 RETURN
38 PRINT “*** TOO MUCH DATA BASE **
*”:END
100 DIM A$(1),X(20)
105 FOR I=1 TO 20:X(I)=I: NEXT
I
108 LM=2048:CM=2106:A=58:HM=16383

140 PRINT “NOW WE ARE GOING TO CLEAR
THE X(20) TABLE AND READ THE DA
TA FROM TAPE”
150 FOR I=1 TO 20:X(I): NEXT I
160 PRINT “NOW START TAPE RECORDER”
:INPUT “AND THEN HIT RETURN”
,A$
165 PRINT “A ”,A
170 GOSUB 30
180 PRINT “ALL THE DATA READ IN”

120 PRINT “NOW WE ARE GOING TO SAVE
THE DATA”: PRINT “WHEN YOU ARE R
EADY START THE RECORDER IN RECOR
D MORE”: INPUT “AND HIT RETURN”
,A$
130 CALL -936: PRINT “NOW WRITING DA
TA TO TAPE”: GOSUB 20
135 PRINT “NOW THE DATA IS SAVE”

190 FOR I-1 TO 20: PRINT “X(”;I;
“)=”;X(I): NEXT I
195 PRINT “THIS IS THE END”
200 END

42

A SIMPLE TONE SUBROUTINE

INTRODUCTION
Computers can perform marvelous feats of mathematical computation
at well beyond the speed capable of most human minds. They are fast,
cold and accurate; man on the other hand is slower, has emotion, and makes
errors. These differences create problems when the two interact with one
another. So to reduce this problem humanizing of the computer is needed.
Humanizing means incorporating within the computer procedures that aid in
a program's usage. One such technique is the addition of a tone subroutine.
This paper discusses the incorporation and usage of a tone subroutine within
the Apple II computer.
Tone Generation
To generate tones in a computer three things are needed: a speaker,
a circuit to drive the speaker, and a means of triggering the circuit. As it
happens the Apple II computer was designed with a two-inch speaker and an
efficient speaker driving circuit. Control of the speaker is accomplished
through software.
Toggling the speaker is a simple process, a mere PEEK - 16336 ($CØ3Ø)
in BASIC statement will perform this operation. This does not, however,
produce tones, it only emits clicks. Generation of tones is the goal, so
describing frequency and duration is needed, This is accomplished by toggling
the speaker at regular intervals for a fixed period of time. Figure 1 lists
a machine language routine that satisfies these requirements.
Machine Language Program
This machine language program resides in page Ø of memory from $92 (2)
to $14 (2Ø). $ØØ (ØØ) is used to store the relative period (P) between
toggling of the speaker and $Ø1 (Ø1) is used as the memory location for the
value of relative duration (Ø). Both P and D can range in value from $ØØ (Ø)
to $FF (255). After the values for frequency and duration are placed into
memory a CALL2 statement from BASIC will activate this routine. The speaker
is toggled with the machine language statement residing at $Ø2 and then a

43

delay in time equal to the value in $ØØ occurs. This process is repeated until
the tone has lasted a relative period of time equal to the duration (value in $Øl)
and then this program is exited (statement $l4).
Basic Program
The purpose of the machine language routine is to generate tones controllable
from BASIC as the program dictates. Figure 2 lists the appropriate statement that
will deposit the machine language routine into memory. They are in the form of
a subroutine and can be activated by a GOSUB 32ØØØ statement. It is only necessary
to use this statement once at the beginning of a program. After that the machine
language program will remain in memory unless a later part of the main program
modifies the first 2Ø locations of page Ø.
After the GOSUB 32ØØØ has placed the machine language program into memory
it may be activated by the statement in Figure 3. This statement is also in the
form of a GOSUB because it can be used repetitively in a program. Once the frequency
and duration have been defined by setting P and D equal to a value between
Ø and 255 a GOSUB 25 statement is used to initiate the generation of a tone. The
values of P and D are placed into $ØØ and $Øl and the CALL2 command activates the
machine language program that toggles the speaker. After the tone has ended
control is returned to the main program.
The statements in Figures 2 and 3 can be directly incorporated into BASIC
programs to provide for the generation of tones. Once added to a program an
infinite variety of tone combinations can be produced. For example, tones can
be used to prompt, indicate an error in entering or answering questions, and
supplement video displays on the Apple II computer system.
Since the computer operates at a faster rate than man does, prompting can
be used to indicate when the computer expects data to be entered. Tones can be
generated at just about any time for any reason in a program. The programmer's
imagination can guide the placement of these tones.
CONCLUSION
The incorporation of tones through the routines discussed in this paper
will aid in the humanizing of software used in the Apple computer. These routines
can also help in transforming a dull program into a lively one. They are relatively
easy to use and are a valuable addition to any program.

44

000000000002000500060008000A000C000D000F00110014-

FF
FF
AD
88
D0
C6
F0
CA
D0
A6
4C
60

30 C0
04
01
08
F6
00
02 00

???
???
LDA
DEY
BNE
DEC
BEQ
DEX
BNE
LDX
JMP
RTS

$C030
$000C
$01
$0014
$0005
$00
$0002

FIGURE 1. Machine Language Program
adapted from a program by P. Lutas.

32000 POKE 2,173: POKE 3,48: POKE
4,192: POKE 5,136: POKE 6,208
: POKE 7,4: P0KE 8,198: POKE
9,1: POKE 10,240
32005 POKE 11,8: POKE 12,202: POKE
13,208: POKE 14,246: POKE 15
,166: POKE 16,0: POKE 17,76
: POKE 18,2: POKE 19,0: POKE
20,96: RETURN

FIGURE 2. BASIC "POKES"

25 POKE 0,P: POKE 1,D: CALL 2:
RETURN

FIGURE 3.

GOSUB

45

High-Resolution Operating Subroutines

These subroutines were created to make programming for
High-Resolution Graphics easier, for both BASIC and machine.
language programs. These subroutines occupy 757 bytes of memory
and are available on either cassette tape or Read- Only Memory
(ROM). This note describes use and care of these subroutines.

There are seven subroutines in this package. With these,
a programmer can initialize High-Resolution mode, clear the screen,
plot a point, draw a line, or draw and animate a predefined shape.
on the screen. There are also some other general-purpose
subroutines to shorten and simplify programming.

BASIC programs can access these subroutines by use of ,the
CALL statement, and can pass information by using the POKE state ment. There are special entry points for most of the subroutines
that will perform the same functions as the original subroutines
without modifying any BASIC pointers or registers. For machine
language programming, a JSR to the appropriate subroutine address
will perform the same function as a BASIC CALL.

In the following subroutine descriptions, all addresses
given will be in decimal. The hexadecimal substitutes will
be preceded by a dollar sign ($).

All entry points given are

for the cassette tape subroutines, which load into addresses
CØØ to FFF (hex). Equivalent addresses for the ROM subroutines
will be in italic type face.

46

High-Resolution Operating Subroutines

INIT Initiates High-Resolution Graphics mode.
From BASIC: CALL 3072 (or CALL -12288)
From machine language: JSR $C00 (or JSR $D000)

This subroutine sets High-Resolution Graphics mode with a
280 x 160 matrix of dots in the top portion of the screen and
four lines of text in the bottom portion of the screen. INIT
also clears the screen.

CLEAR

Clears the screen.

From BASIC: CALL 3886 (or CALL -12274)
From machine language: JSR SCOE (or JSR $L000E)

This subroutine clears the High-Resolution screen without
resetting the High-Resblution Graphics mode.

PLOT

Plots a point on the screen.

From BASIC: CALL 3780 (or CALL -21589)
From machine language: JSR $C7C (or JSR $L107C)

This subroutine plots a single point on the screen. The
X and Y coodinates of the point are passed in locations 800,
801, and 802 from BASIC, or in the A, X, and Y registers from
machine language. The Y (vertical) coordinate can be from 0

47

ROD'S COLOR PATTERN

PROGRAM DESCRIPTION
ROD'S COLOR PATTERN is a simple but eloquent program. It generates a
continuous flow of colored mosaic-like patterns in a 4Ø high by 4Ø wide
block matrix. Many of the patterns generated by this program are pleasing
to the eye and will dazzle the mind for minutes at a time.
REQUIREMENTS
4K or greater Apple II system with a color video display.
BASIC is the programming language used.
PROGRAM LISTING

100
105
110
115
120
130
135

GR
FOR Q=3 TO 50
FOR I=1 TO 19
FOR J=0 TO 19
K=I+J
COLOR=J+3/(I+3)+IxW/12
PLOT I,K: PLOT K,I: PLOT 40
-I,40-K
136 PLOT 40-K,40-I: PLOT K,40-I:
PLOT 40-I,K: PLOT I,40-K: PLOT
40-K,I
140 NEXT J,I
145 NEXT W: GOTO 105

55

COLOR SKETCH

PROGRAM DESCRIPTION
Color Sketch is a little program that transforms the Apple II into an
artist's easel, the screen into a sketch pad. The user as an artist
has a 4Ø high by 4Ø wide (16ØØ blocks) sketching pad to fill with a
rainbow of fifteen colors. Placement of colors is determined by
controlling paddle inputs; one for the horizontal and the other for
the vertical. Colors are selected by depressing a letter from A through
P on the keyboard.
An enormous number of distinct pictures can be drawn on the sketch pad
and this program will provide many hours of visual entertainment.
REQUIREMENTS
This program will fit into a 4K system in the BASIC mode.

57

MASTERMIND PROGRAM

PROGRAM DESCRIPTION
MASTERMIND is a game of strategy that matches your wits against Apple's.
The object of the game is to choose correctly which 5 colored bars have
been secretly chosen by the computer. Eight different colors are possible
for each bar - Red (R), Yellow (Y), Violet (V), Orange (0), White (W), and
Black (B). A color may be used more than once. Guesses for a turn are
made by selecting a color for each of the five hidden bars. After hitting
the RETURN key Apple will indicate the correctness of the turn. Each white
square to the right of your turn indicates a correctly colored and positioned
bar. Each grey square acknowledges a correctly colored but improperly positioned bar. No squares indicate you're way off.
Test your skill and challenge the Apple II to a game of MASTERMIND.
REQUIREMENTS
8K or greater Apple II computer system.
BASIC is the programming language.

59

PROGRAM DESCRIPTION
This program plots three Biorhythm functions: Physical (P), Emotional (E),
and Mental (M) or intellectual. All three functions are plotted in the
color graphics display mode.
Biorhythm theory states that aspects of the mind run in cycles. A brief
description of the three cycles follows:
Physical
The Physical Biorhythm takes 23 days to complete and is an indirect indicator
of the physical state of the individual. It covers physical well-being, basic
bodily functions, strength, coordination, and resistance to disease.
Emotional
The Emotional Biorhythm takes 28 days to complete. It indirectly indicates
the level of sensitivity, mental health, mood, and creativity.
Mental
The mental cycle takes 33 days to complete and indirectly indicates the level
of alertness, logic and analytic functions of the individual, and mental receptivity.
Biorhythms
Biorhythms are thought to affect behavior. When they cross a "baseline" the
functions change phase - become unstable - and this causes Critical Days. These
days are, according to the theory, our weakest and most vulnerable times. Accidents, catching colds, and bodily harm may occur on physically critical days.
Depression, quarrels, and frustration are most likely on emotionally critical
days. Finally, slowness of the mind, resistance to new situations and unclear
thinking are likely on mentally critical days.
REQUIREMENTS
This program fits into a 4K or greater system.
BASIC is the programming language used.

61

DRAGON MAZE PROGRAM

PROGRAM DESCRIPTION
DRAGON MAZE is a game that will test your skill and memory. A mazeis
constructed on the video screen. You watch carefully as it is completed.
After it is finished the maze is hidden as if the lights were turned out.
The object of the game is to get out of the maze before the dragon eats
you.

A reddish-brown square indicates your position and a purple square

represents the dragon's.* You move by hitting a letter on the keyboard;
U for up, D for down, R for right, and L for left. As you advance so
does the dragon.

The scent of humans drives the dragon crazy; when he is

enraged he breaks through walls to get at you.
for the weak at heart.

DRAGON MAZE is not a game

Try it if you dare to attempt out-smarting the

dragon.
REQUIREMENTS
8K or greater Apple II computer system.
BASIC is the programming language.

*

Color tints may vary depending upon video monitor or television adjustments.

63

DRAGON MAZE cont.

7110 DX=-1:DY=0: GOTO 7020
7150 IF SY=1 THEN 7005: IF T(SX+
13*(SY-1)))0 THEN 7160: IF
M(SX+13*(SY-1)-13)/10 THEN
7005
7160 DX=0:DY=-1: GOTO 7020
8000 GOSUB 5000: GOSUB 5000: GOSUB
5000: GOSUB 5000: PRINT “THE DRA
GON GOT YOU!”
1999 END

65

APPLE II FIRMWARE
1. System Monitor Commands
2. Control and Editing Characters
3. Special Controls and Features
4. Annotated Monitor and Dis-assembler Listing
5. Binary Floating Point Package
6. Sweet 16 Interpreter Listing
7. 6502 Op Codes

67

System Monitor Commands
Apple II contains a powerful machine level monitor for use by the advanced
programmer. To enter the monitor either press RESET button on keyboard or
CALL-l5l (Hex FF65) from Basic. Apple II will respond with an "*" (asterisk)
prompt character on the TV display. This action will not kill current BASIC
program which may be re-entered by a Cc (control C). NOTE: "adrs" is a
four digit hexidecimal number and "data" is a two digit hexidecimal number.
Remember to press "return" button at the end of each line.
Command Format

Example

Description

Examine Memory
adrs

*CØF2

Examines (displays) single memory
location of (adrs)

adrsl.adrs2

*lØ24.lØ48

Examines (displays) range of memory
from (adrsl) thru (adrs2)

(return)

*(return)

Examines (displays) next 8 memory
locations.

.adrs2

*.4Ø96

Examines (displays) memory from current
location through location (adrs2)

adrs:data
data data

*A256:EF 2Ø 43

Deposits data into memory starting at
location (adrs).

:data data
data

*:FØ A2 l2

Deposits data into memory starting
after (adrs) last used for deposits.

*1ØØØ

ØØ22

11Ø POKE 34,11

Set window top to line specified
by Tl in range of Ø to 23

ØØ23

12Ø POKE 35,B1

Set window bottom to line specified
by Bl in the range of Ø to 23. B1>T1

ØØ24

13Ø CH=PEEK(36)
14Ø POKE 36,CH
15Ø TAB(CH+1)

Read/set cusor horizontal position
in the range of Ø to 39. If using
TAB, you must add "1" to cusor position
read value; Ex. l4Ø and l5Ø perform
identical function.

ØØ25

16Ø CV=PEEK(37)
17Ø POKE 37,CV
18Ø VTAB(CV+l)

Similar to above. Read/set cusor
vertical position in the range Ø to
23.

ØØ32

19Ø POKE 5Ø,127
2ØØ POKE 5Ø,255

Set inverse flag if 127 (Ex. l9Ø)
Set normal flag if 255(Ex. 2ØØ)

FC58

21Ø CALL -936

(@E) Home cusor, clear screen

FC42

22Ø CALL -958

(FE) Clear from cusor to end of page

74

Hex

BASIC Example

Description

FC9C

23Ø CALL -868

FC66

24Ø CALL -922

(JC) Line feed

FC7Ø

25Ø CALL -9l2

Scroll up text one line

(EE) Clear from cusor to end of line

Miscellaneous
CØ3Ø

36Ø X=PEEK(-l6336)
365 POKE -l6336,Ø

Toggle speaker

CØØØ

37Ø X=PEEK(-16384

Read keyboard; if X>127 then key was
pressed.

CØlØ

38Ø POKE -l6368,Ø

Clear keyboard strobe - always after
reading keyboard.

CØ6l

39Ø X=PEEK(16287)

Read PDL(Ø) push button switch. If
X>l27 then switch is "on".

CØ62

4ØØ X=PEEK(-l6286)

Read PDL(l) push button switch.

CØ63

4lØ X=PEEK(-l6285

Read PDL(2) push button switch.

CØ58

42Ø POKE -l6296,Ø

Clear Game I/O ANØ output

CØ59

43Ø POKE -l6295,Ø

Set Game I/O ANØ output

CØ5A

44Ø POKE -l6294,Ø

Clear Game I/O ANl output

CØ5B

45Ø POKE -l6293,Ø

Set Game I/O ANl output

CØ5C

46Ø POKE -l6292,Ø

Clear Game I/O AN2 output

CØ5D

47Ø POKE -l629l,Ø

Set Game I/O AN2 output

CØ5E

48Ø POKE -l629Ø,Ø

Clear Game I/O AN3 output

CØ5F

49Ø POKE -l6289,Ø

Set Game I/O AN3 output

75

***************************
*
*
*
APPLE II
*
*
SYSTEM MONITOR
*
*
*
*
COPYRIGHT 1977 BY
*
*
APPLE COMPUTER, INC. *
*
*
*
ALL RIGHTS RESERVED
*
*
*
*
S. WOZNIAK
*
*
A. BAUM
*
*
*
***************************
TITLE
"APPLE II SYSTEM MONITOR"
LOC0
EPZ
$00
LOC1
EPZ
$01
WNDLFT
EPZ
$20
WNDWDTH EPZ
$21
WNDTOP
EPZ
$22
WNDBTM
EPZ
$23
CH
EPZ
$24
CV
EPZ
$25
GBASL
EPZ
$26
GBASH
EPZ
$27
BASL
EPZ
$28
BASH
EPZ
$29
BAS2L
EPZ
$2A
BAS2H
EPZ
$2B
H2
EPZ
$2C
LMNEM
EPZ
$2C
RTNL
EPZ
$2C
V2
EPZ
$2D
RMNEM
EPZ
$2D
RTNH
EPZ
$2D
MASK
EPZ
$2E
CHKSUM
EPZ
$2E
FORMAT
EPZ
$2E
LASTIN
EPZ
$2F
LENGTH
EPZ
$2F
SIGN
EPZ
$2F
COLOR
EPZ
$30
MODE
EPZ
$31
INVFLG
EPZ
$32
PROMPT
EPZ
$33
YSAV
EPZ
$34
YSAV1
EPZ
$35
CSWL
EPZ
$36
CSWH
EPZ
$37
KSWL
EPZ
$38
KSWH
EPZ
$39
PCL
EPZ
$3A
PCH
EPZ
$3B
XQT
EPZ
$3C
A1L
EPZ
$3C
A1H
EPZ
$3D
A2L
EPZ
$3E
A2H
EPZ
$3F
A3L
EPZ
$40
A3H
EPZ
$41
A4L
EPZ
$42
A4H
EPZ
$43
A5L
EPZ
$44
A5H
EPZ
$45

76

ACC
XREG
YREG
STATUS
SPNT
RNDL
RNDH
ACL
ACH
XTNDL
XTNDH
AUXL
AUXH
PICK
IN
USRADR
NMI
IRQLOC
IOADR
KBD
KBDSTRB
TAPEOUT
SPKR
TXTCLR
TXTSET
MIXCLR
MIXSET
LOWSCR
HISCR
LORES
HIRES
TAPEIN
PADDL0
PTRIG
BASIC
BASIC2
F800:
F801:
F802:
F805:
F806:
F808:
F80A:
F80C:
F80E:
F810:
F812:
F814:
F816:
F818:
F819:
F81C:
F81E:
F820:
F821:
F824:
F826:
F828:
F829:
F82C:
F82D:
F82F:
F831:
F832:
F834:
F836:
F838:

4A
08
20
28
A9
90
69
85
B1
45
25
51
91
60
20
C4
B0
C8
20
90
69
48
20
68
C5
90
60
A0
D0
A0
84

F83A:
F83C:
F83E:
F840:
F843:
F844:
F846:
F847:
F848:
F849:
F84B:
F84D:
F84F:
F850:
F852:
F854:
F856:

A0
A9
85
20
88
10
60
48
4A
29
09
85
68
29
90
69
85

47 F8
0F
02
E0
2E
26
30
2E
26
26
00 F8
2C
11
0E F8
F6
01
00 F8
2D
F5
2F
02
27
2D
27
00
30
28 F8
F6

03
04
27
18
02
7F
26

EQU
$45
EQU
$46
EQU
$47
EQU
$48
EQU
$49
EQU
$4E
EQU
$4F
EQU
$50
EQU
$51
EQU
$52
EQU
$53
EQU
$54
EQU
$55
EQU
$95
EQU
$0200
EQU
$03F8
EQU
$03FB
EQU
$03FE
EQU
$C000
EQU
$C000
EQU
$C010
EQU
$C020
EQU
$C030
EQU
$C050
EQU
$C051
EQU
$C052
EQU
$C053
EQU
$C054
EQU
$C055
EQU
$C056
EQU
$C057
EQU
$C060
EQU
$C064
EQU
$C070
EQU
$E000
EQU
$E003
ORG
$F800
ROM START ADDRESS
PLOT
LSR
Y-COORD/2
PHP
SAVE LSB IN CARRY
JSR
GBASCALC CALC BASE ADR IN GBASL,H
PLP
RESTORE LSB FROM CARRY
LDA
#$0F
MASK $0F IF EVEN
BCC
RTMASK
ADC
#$E0
MASK $F0 IF ODD
RTMASK
STA
MASK
PLOT1
LDA
(GBASL),Y DATA
EOR
COLOR
EOR COLOR
AND
MASK
AND MASK
EOR
(GBASL),Y
XOR DATA
STA
(GBASL),Y
TO DATA
RTS
HLINE
JSR
PLOT
PLOT SQUARE
HLINE1
CPY
H2
DONE?
BCS
RTS1
YES, RETURN
INY
NO, INCR INDEX (X-COORD)
JSR
PLOT1
PLOT NEXT SQUARE
BCC
HLINE1
ALWAYS TAKEN
VLINEZ
ADC
#$01
NEXT Y-COORD
VLINE
PHA
SAVE ON STACK
JSR
PLOT
PLOT SQUARE
PLA
CMP
V2
DONE?
BCC
VLINEZ
NO, LOOP
RTS1
RTS
CLRSCR
LDY
#$2F
MAX Y, FULL SCRN CLR
BNE
CLRSC2
ALWAYS TAKEN
CLRTOP
LDY
#$27
MAX Y, TOP SCREEN CLR
CLRSC2
STY
V2
STORE AS BOTTOM COORD
FOR VLINE CALLS
LDY
#$27
RIGHTMOST X-COORD (COLUMN)
CLRSC3
LDA
#$00
TOP COORD FOR VLINE CALLS
STA
COLOR
CLEAR COLOR (BLACK)
JSR
VLINE
DRAW VLINE
DEY
NEXT LEFTMOST X-COORD
BPL
CLRSC3
LOOP UNTIL DONE
RTS
GBASCALC PHA
FOR INPUT 000DEFGH
LSR
AND
#$03
ORA
#$04
GENERATE GBASH=000001FG
STA
GBASH
PLA
AND GBASL=HDEDE000
AND
#$18
BCC
GBCALC
ADC
#$7F
GBCALC
STA
GBASL

77

F858:
F859:
F85A:
F85C:
F85E:
F85F:
F861:
F862:
F864:
F866:
F868:
F869:
F86A:
F86B:
F86C:
F86E:
F870:
F871:
F872:
F873:
F876:
F878:
F879:
F87B:
F87C:
F87D:
F87E:
F87F:
F881:
F882:
F884:
F886:
F889:
F88C:
F88E:
F88F:
F890:
F892:
F893:
F895:
F897:
F899:
F89B:
F89C:
F89D:
F8A0:
F8A3:
F8A5:
F8A7:
F8A9:
F8AA:
F8AD:
F8AF:

0A
0A
05
85
60
A5
18
69
29
85
0A
0A
0A
0A
05
85
60
4A
08
20
B1
28
90
4A
4A
4A
4A
29
60
A6
A4
20
20
A1
A8
4A
90
6A
B0
C9
F0
29
4A
AA
BD
20
D0
A0
A9
AA
BD
85
29

F8B1:
F8B3:
F8B4:
F8B6:
F8B7:
F8B8:
F8BA:
F8BC:
F8BE:
F8BF:
F8C1:
F8C2:
F8C3:
F8C5:
F8C6:
F8C8:
F8C9:
F8CA:
F8CC:
F8CD:
F8D0:
F8D3:
F8D4:
F8D6:
F8D9:
F8DB:
F8DE:
F8E0:
F8E1:
F8E3:
F8E5:

85
98
29
AA
98
A0
E0
F0
4A
90
4A
4A
09
88
D0
C8
88
D0
60
FF
20
48
B1
20
A2
20
C4
C8
90
A2
C0

26
26
30

NXTCOL

03
0F
30

SETCOL

30
30
SCRN
47 F8
26
04

SCRN2

0F

RTMSKZ

3A
3B
96 FD
48 F9
3A

INSDS1

INSDS2
09
10
A2
0C
87
IEVEN
62 F9
79 F8
04
80
00

ERR
GETFMT

A6 F9
2E
03
2F
8F

03
8A
0B
MNNDX1
08
MNNDX2
20
FA
MNNDX3
F2
FF FF
82 F8
3A
DA FD
01
4A F9
2F
F1
03
04

INSTDSP
PRNTOP

PRNTBL

ASL
ASL
ORA
STA
RTS
LDA
CLC
ADC
AND
STA
ASL
ASL
ASL
ASL
ORA
STA
RTS
LSR
PHP
JSR
LDA
PLP
BCC
LSR
LSR
LSR
LSR
AND
RTS
LDX
LDY
JSR
JSR
LDA
TAY
LSR
BCC
ROR
BCS
CMP
BEQ
AND
LSR
TAX
LDA
JSR
BNE
LDY
LDA
TAX
LDA
STA
AND
STA
TYA
AND
TAX
TYA
LDY
CPX
BEQ
LSR
BCC
LSR
LSR
ORA
DEY
BNE
INY
DEY
BNE
RTS
DFB
JSR
PHA
LDA
JSR
LDX
JSR
CPY
INY
BCC
LDX
CPY

78

A
A
GBASL
GBASL
COLOR
#$03
#$0F
COLOR
A
A
A
A
COLOR
COLOR
A
GBASCALC
(GBASL),Y
RTMSKZ
A
A
A
A
#$0F
PCL
PCH
PRYX2
PRBLNK
(PCL,X)
A
IEVEN
ERR
#$A2
ERR
#$87
A
FMT1,X
SCRN2
GETFMT
#$80
#$00

INCREMENT COLOR BY 3

SETS COLOR=17*A MOD 16
BOTH HALF BYTES OF COLOR EQUAL

READ SCREEN Y-COORD/2
SAVE LSB (CARRY)
CALC BASE ADDRESS
GET BYTE
RESTORE LSB FROM CARRY
IF EVEN, USE LO H

SHIFT HIGH HALF BYTE DOWN
MASK 4-BITS
PRINT PCL,H

FOLLOWED BY A BLANK
GET OP CODE
EVEN/ODD TEST
BIT 1 TEST
XXXXXX11 INVALID OP
OPCODE $89 INVALID
MASK BITS
LSB INTO CARRY FOR L/R TEST
GET FORMAT INDEX BYTE
R/L H-BYTE ON CARRY
SUBSTITUTE $80 FOR INVALID OPS
SET PRINT FORMAT INDEX TO 0

FMT2,X
INDEX INTO PRINT FORMAT TABLE
FORMAT
SAVE FOR ADR FIELD FORMATTING
#$03
MASK FOR 2-BIT LENGTH
(P=1 BYTE, 1=2 BYTE, 2=3 BYTE)
LENGTH
OPCODE
#$8F
MASK FOR 1XXX1010 TEST
SAVE IT
OPCODE TO A AGAIN
#$03
#$8A
MNNDX3
A
MNNDX3
FORM INDEX INTO MNEMONIC TABLE
A
A
1) 1XXX1010->00101XXX
#$20
2) XXXYYY01->00111XXX
3) XXXYYY10->00110XXX
MNNDX2
4) XXXYY100->00100XXX
5) XXXXX000->000XXXXX
MNNDX1
$FF,$FF,$FF
INSDS1
GEN FMT, LEN BYTES
SAVE MNEMONIC TABLE INDEX
(PCL),Y
PRBYTE
#$01
PRINT 2 BLANKS
PRBL2
LENGTH
PRINT INST (1-3 BYTES)
IN A 12 CHR FIELD
PRNTOP
#$03
CHAR COUNT FOR MNEMONIC PRINT
#$04

F8E7:
F8E9:
F8EA:
F8EB:
F8EE:
F8F0:
F8F3:
F8F5:
F8F7:
F8F9:
F8FB:
F8FD:
F8FE:
F8FF:
F901:
F903:
F906:
F907:
F909:
F90C:
F90E:
F910:
F912:
F914:
F916:
F918:
F91B:
F91E:
F921:
F923:
F926:
F927:
F929:
F92A:
F92B:
F92D:
F930:
F932:
F934:
F936:
F938:
F93B:
F93C:
F93D:
F93F:
F940:
F941:
F944:
F945:
F948:
F94A:
F94C:
F94F:
F950:
F952:
F953:
F954:
F956:
F958:
F959:
F95B:
F95C:
F95E:
F960:
F961:

F962:
F965:
F967:
F96A:
F96C:
F96F:
F971:
F974:
F976:
F979:
F97B:
F97E:
F980:
F983:
F985:
F988:

90
68
A8
B9
85
B9
85
A9
A0
06
26
2A
88
D0
69
20
CA
D0
20
A4
A2
E0
F0
06
90
BD
20
BD
F0
20
CA
D0
60
88
30
20
A5
C9
B1
90
20
AA
E8
D0
C8
98
20
8A
4C
A2
A9
20
CA
D0
60
38
A5
A4
AA
10
88
65
90
C8
60

04
30
80
03
54
80
90
54
0D
90
20
0D
04
22
33
44

F2

C0 F9
2C
00 FA
2D
00
05
2D
2C

PRMN1
PRMN2

F8
BF
ED FD
EC
48
2F
06
03
1C
2E
0E
B3
ED
B9
03
ED

F9

PRADR1
PRADR2
F9
FD
F9
FD
PRADR3

E7
PRADR4
E7
DA FD
2E
E8
3A
F2
56 F9

PRADR5

RELADR

01

DA FD
DA FD
03
A0
ED FD

PRNTYX
PRNTAX
PRNTX
PRBLNK
PRBL2
PRBL3

F8
PCADJ
PCADJ2
PCADJ3

2F
3B
01
3A
01

PCADJ4

RTS2
*
*
*
*
20
0D
04
22
33
04
04
33
80
04
54
80
90
44
0D
00

BCC
PRNTBL
PLA
TAY
LDA
MNEML,Y
STA
LMNEM
LDA
MNEMR,Y
STA
RMNEM
LDA
#$00
LDY
#$05
ASL
RMNEM
ROL
LMNEM
ROL
DEY
BNE
PRMN2
ADC
#$BF
JSR
COUT
DEX
BNE
PRMN1
JSR
PRBLNK
LDY
LENGTH
LDX
#$06
CPX
#$03
BEQ
PRADR5
ASL
FORMAT
BCC
PRADR3
LDA
CHAR1-1,X
JSR
COUT
LDA
CHAR2-1,X
BEQ
PRADR3
JSR
COUT
DEX
BNE
PRADR1
RTS
DEY
BMI
PRADR2
JSR
PRBYTE
LDA
FORMAT
CMP
#$E8
LDA
(PCL),Y
BCC
PRADR4
JSR
PCADJ3
TAX
INX
BNE
PRNTYX
INY
TYA
JSR
PRBYTE
TXA
JMP
PRBYTE
LDX
#$03
LDA
#$A0
JSR
COUT
DEX
BNE
PRBL2
RTS
SEC
LDA
LENGTH
LDY
PCH
TAX
BPL
PCADJ4
DEY
ADC
PCL
BCC
RTS2
INY
RTS
FMT1 BYTES:
IF Y=0
IF Y=1

RECOVER MNEMONIC INDEX

FETCH 3-CHAR MNEMONIC
(PACKED IN 2-BYTES)

SHIFT 5 BITS OF
CHARACTER INTO A
(CLEARS CARRY)

ADD "?" OFFSET
OUTPUT A CHAR OF MNEM

OUTPUT 3 BLANKS
CNT FOR 6 FORMAT BITS
IF X=3 THEN ADDR.

HANDLE REL ADR MODE
SPECIAL (PRINT TARGET,
NOT OFFSET)
PCL,PCH+OFFSET+1 TO A,Y
+1 TO Y,X

OUTPUT TARGET ADR
OF BRANCH AND RETURN
BLANK COUNT
LOAD A SPACE
OUTPUT A BLANK
LOOP UNTIL COUNT=0
0=1-BYTE, 1=2-BYTE
2=3-BYTE
TEST DISPLACEMENT SIGN
(FOR REL BRANCH)
EXTEND NEG BY DEC PCH
PCL+LENGTH(OR DISPL)+1 TO A
CARRY INTO Y (PCH)

54
FMT1

DFB

$04,$20,$54,$30,$0D

DFB

$80,$04,$90,$03,$22

DFB

$54,$33,$0D,$80,$04

DFB

$90,$04,$20,$54,$33

DFB

$0D,$80,$04,$90,$04

DFB

$20,$54,$3B,$0D,$80

DFB

$04,$90,$00,$22,$44

DFB

$33,$0D,$C8,$44,$00

90
0D
20
04
3B
00
C8

79

XXXXXXY0 INSTRS
THEN LEFT HALF BYTE
THEN RIGHT HALF BYTE
(X=INDEX)

F98A:
F98D:
F98F:
F992:
F994:
F997:
F999:
F99C:
F99E:
F9A1:
F9A2:
F9A5:
F9A6:
F9A7:
F9A8:
F9A9:
F9AA:
F9AB:
F9AC:
F9AD:
F9AE:
F9AF:
F9B0:
F9B1:
F9B2:
F9B3:
F9B4:
F9B7:

11
33
C8
01
44
80
90
44
0D
90
26
9A
00
21
81
82
00
00
59
4D
91
92
86
4A
85
9D
AC
A3

22
0D
44
22
33
04
01
33
80

44

1C
23
1B
8A
9D
A1
19
A8
24
23
19
00
5B
24
AE
AD
7C
15
9C
29
84
11
23
D8
48
94
44
68
94
08
B4
74
4A
A4
00
A2
74
44
32
22
1A
26
88
C4
48
A2

$11,$22,$44,$33,$0D

DFB

$C8,$44,$A9,$01,$22

DFB

$44,$33,$0D,$80,$04

DFB

$90,$01,$22,$44,$33

DFB

$0D,$80,$04,$90

DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB

$26,$31,$87,$9A $ZZXXXY01 INSTR'S
$00
ERR
$21
IMM
$81
Z-PAGE
$82
ABS
$00
IMPLIED
$00
ACCUMULATOR
$59
(ZPAG,X)
$4D
(ZPAG),Y
$91
ZPAG,X
$92
ABS,X
$86
ABS,Y
$4A
(ABS)
$85
ZPAG,Y
$9D
RELATIVE

CHAR1

ASC

",),#($"

CHAR2
*CHAR2:
*
*
*
*
*
*
*

DFB
$D9,$00,$D8,$A4,$A4,$00
"Y",0,"X$$",0
MNEML
IS OF FORM:
(A) XXXXX000
(B) XXXYY100
(C) 1XXX1010
(D) XXXYYY10
(E) XXXYYY01
(X=INDEX)

MNEML

DFB

$1C,$8A,$1C,$23,$5D,$

DFB

$1B,$A1,$9D,$8A,$1D,$23

DFB

$9D,$8B,$1D,$A1,$00,$29

DFB

$19,$AE,$69,$A8,$19,$23

DFB
DFB

$24,$53,$1B,$23,$24,$53
$19,$A1
(A) FORMAT ABOVE

DFB
DFB

$00,$1A,$5B,$5B,$A5,$69
$24,$24
(B) FORMAT

DFB
DFB

$AE,$AE,$A8,$AD,$29,$00
$7C,$00
(C) FORMAT

DFB
DFB

$15,$9C,$6D,$9C,$A5,$69
$29,$53
(D) FORMAT

DFB
DFB

$84,$13,$34,$11,$A5,$69
$23,$A0
(E) FORMAT

DFB

$D8,$62,$5A,$48,$26,$62

DFB

$94,$88,$54,$44,$C8,$54

DFB

$68,$44,$E8,$94,$00,$B4

DFB

$08,$84,$74,$B4,$28,$6E

DFB
DFB

$74,$F4,$CC,$4A,$72,$F2
$A4,$8A
(A) FORMAT

DFB
DFB

$00,$AA,$A2,$A2,$74,$74
$74,$72
(B) FORMAT

DFB
DFB

$44,$68,$B2,$32,$B2,$00
$22,$00
(C) FORMAT

DFB
DFB

$1A,$1A,$26,$26,$72,$72
$88,$C8
(D) FORMAT

DFB
DFB

$C4,$CA,$26,$48,$44,$44
$A2,$C8
(E) FORMAT

0D
22
04

31 87
FMT2

A9 AC
A8 A4

F9BA: D9 00 D8
F9BD: A4 A4 00

F9C0:
F9C3:
F9C6:
F9C9:
F9CC:
F9CF:
F9D2:
F9D5:
F9D8:
F9DB:
F9DE:
F9E0:
F9E3:
F9E6:
F9E8:
F9EB:
F9EE:
F9F0:
F9F3:
F9F6:
F9F8:
F9FB:
F9FE:
FA00:
FA03:
FA06:
FA09:
FA0C:
FA0F:
FA12:
FA15:
FA18:
FA1B:
FA1E:
FA20:
FA23:
FA26:
FA28:
FA2B:
FA2E:
FA30:
FA33:
FA36:
FA38:
FA3B:
FA3E:

DFB
A9

8A
5D
A1
1D
8B
00
AE
19
53
24
A1
1A
A5
24
AE
29
00
9C
A5
53
13
A5
A0
62
26
88
C8
44
00
84
28
F4
72
8A
AA
74
72
68
B2
00
1A
72
C8
CA
44
C8

1C
8B
9D
23
1D
29
69
23
1B
53
5B
69
A8
00
6D
69
34
69
5A
62
54
54
E8
B4
74
6E
CC
F2
A2
74
B2
00
26
72
26
44

MNEMR

80

FA40:
FA43:
FA46:
FA47:
FA49:
FA4A:
FA4C:
FA4E:
FA51:
FA53:
FA54:
FA56:
FA58:
FA5A:
FA5C:
FA5E:
FA60:
FA62:
FA64:
FA66:
FA68:
FA6A:
FA6C:
FA6E:
FA70:
FA72:
FA74:
FA76:
FA78:
FA7A:
FA7D:
FA7E:
FA80:
FA83:
FA86:
FA88:
FA89:
FA8A:
FA8B:
FA8C:
FA8D:
FA8F:
FA92:
FA93:
FA96:
FA97:
FA99:
FA9A:
FA9C:
FA9F:
FAA2:
FAA5:
FAA6:
FAA7:
FAA9:
FAAA:
FAAC:
FAAD:
FAAF:
FAB1:
FAB4:
FAB6:
FAB7:
FAB9:
FABA:
FABD:
FABE:
FABF:
FAC0:
FAC1:
FAC2:
FAC4:
FAC5:
FAC7:
FAC8:
FAC9:
FACB:
FACD:
FACF:
FAD1:
FAD3:
FAD4:
FAD6:
FAD7:
FADA:
FADC:

FF
20
68
85
68
85
A2
BD
95
CA
D0
A1
F0
A4
C9
F0
C9
F0
C9
F0
C9
F0
C9
F0
29
49
C9
F0
B1
99
88
10
20
4C
85
68
48
0A
0A
0A
30
6C
28
20
68
85
68
85
20
20
4C
18
68
85
68
85
68
85
A5
20
84
18
90
18
20
AA
98
48
8A
48
A0
18
B1
AA
88
B1
86
85
B0
A5
48
A5
48
20
A9
85

FF FF
D0 F8

STEP

2C
2D
08
10 FB
3C
F8
3A
42
2F
20
59
60
45
4C
5C
6C
59
40
35
1F
14
04
02
3A
3C 00
F8
3F FF
3C 00
45

XQINIT

XQ1
XQ2

IRQ

03
FE 03
BREAK
4C FF
3A
3B
82 F8
DA FA
65 FF

XBRK

XRTI
48
XRTS
3A
3B
2F
56 F9
3B

PCINC2
PCINC3

14
XJSR
54 F9

02
3A

3A
3B
3A
F3
2D

XJMP
XJMPAT

NEWPCL
RTNJMP

2C
8E FD
45
40

REGDSP
RGDSP1

DFB
JSR
PLA
STA
PLA
STA
LDX
LDA
STA
DEX
BNE
LDA
BEQ
LDY
CMP
BEQ
CMP
BEQ
CMP
BEQ
CMP
BEQ
CMP
BEQ
AND
EOR
CMP
BEQ
LDA
STA
DEY
BPL
JSR
JMP
STA
PLA
PHA
ASL
ASL
ASL
BMI
JMP
PLP
JSR
PLA
STA
PLA
STA
JSR
JSR
JMP
CLC
PLA
STA
PLA
STA
PLA
STA
LDA
JSR
STY
CLC
BCC
CLC
JSR
TAX
TYA
PHA
TXA
PHA
LDY
CLC
LDA
TAX
DEY
LDA
STX
STA
BCS
LDA
PHA
LDA
PHA
JSR
LDA
STA

81

$FF,$FF,$FF
INSTDSP
DISASSEMBLE ONE INST
AT (PCL,H)
RTNL
ADJUST TO USER
STACK. SAVE
RTNH
RTN ADR.
#$08
INITBL-1,X INIT XEQ AREA
XQT,X
XQINIT
(PCL,X)
XBRK
LENGTH
#$20
XJSR
#$60
XRTS
#$4C
XJMP
#$6C
XJMPAT
#$40
XRTI
#$1F
#$14
#$04
XQ2
(PCL),Y
XQT,Y
XQ1
RESTORE
XQT
ACC

USER OPCODE BYTE
SPECIAL IF BREAK
LEN FROM DISASSEMBLY
HANDLE JSR, RTS, JMP,
JMP (), RTI SPECIAL

COPY USER INST TO XEQ AREA
WITH TRAILING NOPS
CHANGE REL BRANCH
DISP TO 4 FOR
JMP TO BRANCH OR
NBRANCH FROM XEQ.
RESTORE USER REG CONTENTS.
XEQ USER OP FROM RAM
(RETURN TO NBRANCH)
**IRQ HANDLER

A
A
A
BREAK
(IRQLOC)
SAV1

TEST FOR BREAK
USER ROUTINE VECTOR IN RAM
SAVE REG'S ON BREAK
INCLUDING PC

PCL
PCH
INSDS1
RGDSP1
MON

STATUS
PCL
PCH
LENGTH
PCADJ3
PCH

PRINT USER PC.
AND REG'S
GO TO MONITOR
SIMULATE RTI BY EXPECTING
STATUS FROM STACK, THEN RTS
RTS SIMULATION
EXTRACT PC FROM STACK
AND UPDATE PC BY 1 (LEN=0)
UPDATE PC BY LEN

NEWPCL
PCADJ2

UPDATE PC AND PUSH
ONTO STACH FOR
JSR SIMULATE

#$02
(PCL),Y
LOAD PC FOR JMP,
(JMP) SIMULATE.
(PCL),Y
PCH
PCL
XJMP
RTNH
RTNL
CROUT
#ACC
A3L

DISPLAY USER REG
CONTENTS WITH
LABELS

FADE:
FAE0:
FAE2:
FAE4:
FAE6:
FAE9:
FAEC:
FAEF:
FAF1:
FAF4:
FAF6:
FAF9:
FAFA:
FAFC:
FAFD:
FAFE:
FB00:
FB02:
FB05:
FB07:
FB08:
FB09:
FB0B:
FB0E:
FB0F:
FB11:
FB12:
FB13:
FB16:
FB19:
FB1A:
FB1B:
FB1C:
FB1D:
FB1E:
FB21:
FB23:
FB24:
FB25:
FB28:
FB2A:
FB2B:
FB2D:
FB2E:
FB2F:
FB31:
FB33:
FB36:
FB39:
FB3C:
FB3E:
FB40:
FB43:
FB46:
FB49:
FB4B:
FB4D:
FB4F:
FB51:
FB53:
FB55:
FB57:
FB59:
FB5B:
FB5D:
FB60:
FB63:
FB65:
FB67:
FB68:
FB6A:
FB6B:
FB6D:
FB6F:
FB71:
FB73:
FB74:
FB76:
FB78:
FB79:
FB7A:
FB7B:
FB7D:
FB7E:
FB80:

A9
85
A2
A9
20
BD
20
A9
20
B5
20
E8
30
60
18
A0
B1
20
85
98
38
B0
20
38
B0
EA
EA
4C
4C
C1
D8
D9
D0
D3
AD
A0
EA
EA
BD
10
C8
D0
88
60
A9
85
AD
AD
AD
A9
F0
AD
AD
20
A9
85
A9
85
A9
85
A9
85
A9
85
4C
20
A0
A5
4A
90
18
A2
B5
75
95
E8
D0
A2
76
50
CA
10
88
D0
60

00
41
FB
A0
ED
1E
ED
BD
ED
4A
DA

RDSP1
FD
FA
FD
FD
FD

E8
BRANCH
01
3A
56 F9
3A

A2
4A FF

NBRNCH

9E
INITBL
0B FB
FD FA
RTBL

70 C0
00

PREAD

64 C0
04

PREAD2

F8

00
48
56
54
51
00
0B
50
53
36
14
22
00
20
28
21
18
23
17
25
22
A4
10
50

RTS2D
INIT
C0
C0
C0

C0
C0
F8

SETTXT

SETGR

SETWND

TABV
FC
FB

MULPM
MUL
MUL2

0C
FE
54
56
54
F7
03

FB
E5

MUL3

MUL4
MUL5

LDA
STA
LDX
LDA
JSR
LDA
JSR
LDA
JSR
LDA
JSR
INX
BMI
RTS
CLC
LDY
LDA
JSR
STA
TYA
SEC
BCS
JSR
SEC
BCS
NOP
NOP
JMP
JMP
DFB
DFB
DFB
DFB
DFB
LDA
LDY
NOP
NOP
LDA
BPL
INY
BNE
DEY
RTS
LDA
STA
LDA
LDA
LDA
LDA
BEQ
LDA
LDA
JSR
LDA
STA
LDA
STA
LDA
STA
LDA
STA
LDA
STA
JMP
JSR
LDY
LDA
LSR
BCC
CLC
LDX
LDA
ADC
STA
INX
BNE
LDX
DFB
DFB
DEX
BPL
DEY
BNE
RTS

82

#ACC/256
A3H
#$FB
#$A0
COUT
RTBL-$FB,X
COUT
#$BD
COUT
ACC+5,X
PRBYTE
RDSP1

#$01
(PCL),Y
PCADJ3
PCL

PCINC2
SAVE
PCINC3

NBRNCH
BRANCH
$C1
$D8
$D9
$D0
$D3
PTRIG
#$00

PADDL0,X
RTS2D
PREAD2

#$00
STATUS
LORES
LOWSCR
TXTSET
#$00
SETWND
TXTCLR
MIXSET
CLRTOP
#$14
WNDTOP
#$00
WNDLFT
#$28
WNDWDTH
#$18
WNDBTM
#$17
CV
VTAB
MD1
#$10
ACL
A
MUL4
#$FE
XTNDL+2,X
AUXL+2,X
XTNDL+2,X
MUL3
#$03
$76
$50
MUL5
MUL2

BRANCH TAKEN,
ADD LEN+2 TO PC

NORMAL RETURN AFTER
XEQ USER OF
GO UPDATE PC
DUMMY FILL FOR
XEQ AREA

TRIGGER PADDLES
INIT COUNT
COMPENSATE FOR 1ST COUNT
COUNT Y-REG EVERY
12 USEC
EXIT AT 255 MAX

CLR STATUS FOR DEBUG
SOFTWARE
INIT VIDEO MODE
SET FOR TEXT MODE
FULL SCREEN WINDOW
SET FOR GRAPHICS MODE
LOWER 4 LINES AS
TEXT WINDOW
SET FOR 40 COL WINDOW
TOP IN A-REG,
BTTM AT LINE 24

VTAB TO ROW 23
VTABS TO ROW IN A-REG
ABS VAL OF AC AUX
INDEX FOR 16 BITS
ACX * AUX + XTND
TO AC, XTND
IF NO CARRY,
NO PARTIAL PROD.
ADD MPLCND (AUX)
TO PARTIAL PROD
(XTND)

FB81:
FB84:
FB86:
FB88:
FB8A:
FB8C:
FB8E:
FB8F:
FB91:
FB93:
FB94:
FB96:
FB98:
FB9A:
FB9C:
FB9E:
FBA0:
FBA1:
FBA3:
FBA4:
FBA6:
FBA8:
FBAA:
FBAD:
FBAF:
FBB1:
FBB3:
FBB4:
FBB5:
FBB7:
FBB9:
FBBA:
FBBC:
FBBE:
FBC0:
FBC1:
FBC2:
FBC3:
FBC5:
FBC7:
FBC9:
FBCA:
FBCC:
FBCE:
FBD0:
FBD2:
FBD3:
FBD4:
FBD6:
FBD8:
FBD9:
FBDB:
FBDD:
FBDF:
FBE2:
FBE4:
FBE6:
FBE9:
FBEC:
FBED:
FBEF:
FBF0:
FBF2:
FBF4:
FBF6:
FBF8:
FBFA:
FBFC:
FBFD:
FBFF:
FC01:
FC02:
FC04:
FC06:
FC08:
FC0A:
FC0C:
FC0E:
FC10:
FC12:
FC14:
FC16:
FC18:
FC1A:
FC1C:

20
A0
06
26
26
26
38
A5
E5
AA
A5
E5
90
86
85
E6
88
D0
60
A0
84
A2
20
A2
B5
10
38
98
F5
95
98
F5
95
E6
60
48
4A
29
09
85
68
29
90
69
85
0A
0A
05
85
60
C9
D0
A9
20
A0
A9
20
AD
88
D0
60
A4
91
E6
A5
C5
B0
60
C9
B0
A8
10
C9
F0
C9
F0
C9
D0
C6
10
A5
85
C6
A5
C5

A4 FB
10
50
51
52
53

DIVPM
DIV
DIV2

52
54
53
55
06
52
53
50
DIV3
E3
00
2F
54
AF FB
50
01
0D

MD1

MD3

00
00
01
01
2F
MDRTS
BASCALC
03
04
29
18
02
7F
28

BSCLC2

28
28
87
12
40
A8 FC
C0
0C
A8 FC
30 C0

BELL1

BELL2

F5
24
28
24
24
21
66
A0
EF
EC
8D
5A
8A
5A
88
C9
24
E8
21
24
24
22
25

RTS2B
STOADV
ADVANCE

RTS3
VIDOUT

BS

UP

JSR
LDY
ASL
ROL
ROL
ROL
SEC
LDA
SBC
TAX
LDA
SBC
BCC
STX
STA
INC
DEY
BNE
RTS
LDY
STY
LDX
JSR
LDX
LDA
BPL
SEC
TYA
SBC
STA
TYA
SBC
STA
INC
RTS
PHA
LSR
AND
ORA
STA
PLA
AND
BCC
ADC
STA
ASL
ASL
ORA
STA
RTS
CMP
BNE
LDA
JSR
LDY
LDA
JSR
LDA
DEY
BNE
RTS
LDY
STA
INC
LDA
CMP
BCS
RTS
CMP
BCS
TAY
BPL
CMP
BEQ
CMP
BEQ
CMP
BNE
DEC
BPL
LDA
STA
DEC
LDA
CMP

83

MD1
#$10
ACL
ACH
XTNDL
XTNDH

ABS VAL OF AC, AUX.
INDEX FOR 16 BITS

XTND/AUX
TO AC.

XTNDL
AUXL

MOD TO XTND.

XTNDH
AUXH
DIV3
XTNDL
XTNDH
ACL
DIV2
#$00
SIGN
#AUXL
MD3
#ACL
LOC1,X
MDRTS

ABS VAL OF AC, AUX
WITH RESULT SIGN
IN LSB OF SIGN.

LOC0,X
LOC0,X

COMPL SPECIFIED REG
IF NEG.

X SPECIFIES AC OR AUX

LOC1,X
LOC1,X
SIGN

A
#$03
#$04
BASH
#$18
BSCLC2
#$7F
BASL

CALC BASE ADR IN BASL,H
FOR GIVEN LINE NO
0<=LINE NO.<=$17
ARG=000ABCDE, GENERATE
BASH=000001CD
AND
BASL=EABAB000

BASL
BASL
#$87
RTS2B
#$40
WAIT
#$C0
#$0C
WAIT
SPKR

BELL CHAR? (CNTRL-G)
NO, RETURN
DELAY .01 SECONDS

TOGGLE SPEAKER AT
1 KHZ FOR .1 SEC.

BELL2
CH
(BASL),Y
CH
CH
WNDWDTH
CR
#$A0
STOADV
STOADV
#$8D
CR
#$8A
LF
#$88
BELL1
CH
RTS3
WNDWDTH
CH
CH
WNDTOP
CV

CURSOR H INDEX TO Y-REG
STORE CHAR IN LINE
INCREMENT CURSOR H INDEX
(MOVE RIGHT)
BEYOND WINDOW WIDTH?
YES CR TO NEXT LINE
NO,RETURN
CONTROL CHAR?
NO,OUTPUT IT.
INVERSE VIDEO?
YES, OUTPUT IT.
CR?
YES.
LINE FEED?
IF SO, DO IT.
BACK SPACE? (CNTRL-H)
NO, CHECK FOR BELL.
DECREMENT CURSOR H INDEX
IF POS, OK. ELSE MOVE UP
SET CH TO WNDWDTH-1
(RIGHTMOST SCREEN POS)
CURSOR V INDEX

FC1E:
FC20:
FC22:
FC24:
FC27:
FC29:
FC2B:
FC2C:
FC2E:
FC30:
FC32:
FC34:
FC36:
FC38:
FC3A:
FC3C:
FC3E:
FC40:
FC42:
FC44:
FC46:
FC47:
FC4A:
FC4D:
FC4F:
FC50:
FC52:
FC54:
FC56:
FC58:
FC5A:
FC5C:
FC5E:
FC60:
FC62:
FC64:
FC66:
FC68:
FC6A:
FC6C:
FC6E:
FC70:
FC72:
FC73:
FC76:
FC78:
FC7A:
FC7C:
FC7E:
FC80:
FC81:
FC82:
FC84:
FC86:
FC88:
FC89:
FC8C:
FC8E:
FC90:
FC91:
FC93:
FC95:
FC97:
FC9A:
FC9C:
FC9E:
FCA0:
FCA2:
FCA3:
FCA5:
FCA7:
FCA8:
FCA9:
FCAA:
FCAC:
FCAE:
FCAF:
FCB1:
FCB3:
FCB4:
FCB6:
FCB8:
FCBA:
FCBC:
FCBE:

B0
C6
A5
20
65
85
60
49
F0
69
90
F0
69
90
F0
69
90
D0
A4
A5
48
20
20
A0
68
69
C5
90
B0
A5
85
A0
84
F0
A9
85
E6
A5
C5
90
C6
A5
48
20
A5
85
A5
85
A4
88
68
69
C5
B0
48
20
B1
91
88
10
30
A0
20
B0
A4
A9
91
C8
C4
90
60
38
48
E9
D0
68
E9
D0
60
E6
D0
E6
A5
C5
A5

0B
25
25
C1 FB
20
28
C0
28
FD
C0
DA
FD
2C
DE
FD
5C
E9
24
25

VTAB
VTABZ

RTS4
ESC1

CLREOP
CLEOP1

24 FC
9E FC
00
00
23
F0
CA
22
25
00
24
E4
00
24
25
25
23
B6
25
22
24 FC
28
2A
29
2B
21

HOME

CR
LF

SCROLL

SCRL1

01
23
0D
24 FC
28
2A
F9
E1
00
9E FC
86
24
A0
28

SCRL2

SCRL3

CLREOL
CLEOLZ
CLEOL2

21
F9

01
FC

WAIT
WAIT2
WAIT3

01
F6
42
02
43
3C
3E
3D

NXTA4

NXTA1

BCS
DEC
LDA
JSR
ADC
STA
RTS
EOR
BEQ
ADC
BCC
BEQ
ADC
BCC
BEQ
ADC
BCC
BNE
LDY
LDA
PHA
JSR
JSR
LDY
PLA
ADC
CMP
BCC
BCS
LDA
STA
LDY
STY
BEQ
LDA
STA
INC
LDA
CMP
BCC
DEC
LDA
PHA
JSR
LDA
STA
LDA
STA
LDY
DEY
PLA
ADC
CMP
BCS
PHA
JSR
LDA
STA
DEY
BPL
BMI
LDY
JSR
BCS
LDY
LDA
STA
INY
CPY
BCC
RTS
SEC
PHA
SBC
BNE
PLA
SBC
BNE
RTS
INC
BNE
INC
LDA
CMP
LDA

84

RTS4
CV
CV
BASCALC
WNDLFT
BASL

IF TOP LINE THEN RETURN
DEC CURSOR V-INDEX
GET CURSOR V-INDEX
GENERATE BASE ADR
ADD WINDOW LEFT INDEX
TO BASL

#$C0
HOME
#$FD
ADVANCE
BS
#$FD
LF
UP
#$FD
CLREOL
RTS4
CH
CV

ESC?
IF SO, DO HOME AND CLEAR
ESC-A OR B CHECK
A, ADVANCE
B, BACKSPACE
ESC-C OR D CHECK
C, DOWN
D, GO UP
ESC-E OR F CHECK
E, CLEAR TO END OF LINE
NOT F, RETURN
CURSOR H TO Y INDEX
CURSOR V TO A-REGISTER
SAVE CURRENT LINE ON STK
CALC BASE ADDRESS
CLEAR TO EOL, SET CARRY
CLEAR FROM H INDEX=0 FOR REST
INCREMENT CURRENT LINE
(CARRY IS SET)
DONE TO BOTTOM OF WINDOW?
NO, KEEP CLEARING LINES
YES, TAB TO CURRENT LINE
INIT CURSOR V
AND H-INDICES

VTABZ
CLEOLZ
#$00
#$00
WNDBTM
CLEOP1
VTAB
WNDTOP
CV
#$00
CH
CLEOP1
#$00
CH
CV
CV
WNDBTM
VTABZ
CV
WNDTOP

THEN CLEAR TO END OF PAGE
CURSOR TO LEFT OF INDEX
(RET CURSOR H=0)
INCR CURSOR V(DOWN 1 LINE)
OFF SCREEN?
NO, SET BASE ADDR
DECR CURSOR V (BACK TO BOTTOM)
START AT TOP OF SCRL WNDW

VTABZ
BASL
BAS2L
BASH
BAS2H
WNDWDTH

GENERATE BASE ADR
COPY BASL,H
TO BAS2L,H

#$01
WNDBTM
SCRL3

INCR LINE NUMBER
DONE?
YES, FINISH

VTABZ
(BASL),Y
(BAS2L),Y

FORM BASL,H (BASE ADDR)
MOVE A CHR UP ON LINE

INIT Y TO RIGHTMOST INDEX
OF SCROLLING WINDOW

NEXT CHAR OF LINE
SCRL2
SCRL1
#$00
CLEOLZ
VTAB
CH
#$A0
(BASL),Y

NEXT LINE (ALWAYS TAKEN)
CLEAR BOTTOM LINE
GET BASE ADDR FOR BOTTOM LINE
CARRY IS SET
CURSOR H INDEX
STORE BLANKS FROM 'HERE'
TO END OF LINES (WNDWDTH)

WNDWDTH
CLEOL2

#$01
WAIT3

1.0204 USEC
(13+27/2*A+5/2*A*A)

#$01
WAIT2
A4L
NXTA1
A4H
A1L
A2L
A1H

INCR 2-BYTE A4
AND A1
INCR 2-BYTE A1.
AND COMPARE TO A2

FCC0:
FCC2:
FCC4:
FCC6:
FCC8:
FCC9:
FCCB:
FCCE:
FCD0:
FCD2:
FCD4:
FCD6:
FCD9:
FCDA:
FCDB:
FCDC:
FCDE:
FCE0:
FCE2:
FCE3:
FCE5:
FCE8:

E5
E6
D0
E6
60
A0
20
D0
69
B0
A0
20
C8
C8
88
D0
90
A0
88
D0
AC
A0

FCEA:
FCEB:
FCEC:
FCEE:
FCEF:
FCF2:
FCF3:
FCF4:
FCF6:
FCF7:
FCF9:
FCFA:
FCFD:
FCFE:
FD01:
FD03:
FD05:
FD07:
FD09:
FD0B:
FD0C:
FD0E:
FD10:
FD11:
FD13:
FD15:
FD17:
FD18:
FD1B:
FD1D:
FD1F:
FD21:
FD24:
FD26:
FD28:
FD2B:
FD2E:
FD2F:
FD32:
FD35:
FD38:
FD3A:
FD3C:
FD3D:
FD3F:
FD40:
FD42:
FD44:
FD47:
FD4A:
FD4B:
FD4D:
FD50:
FD52:
FD54:
FD56:
FD58:
FD5A:
FD5C:
FD5F:
FD60:
FD62:
FD64:

CA
60
A2
48
20
68
2A
A0
CA
D0
60
20
88
AD
45
10
45
85
C0
60
A4
B1
48
29
09
91
68
6C
E6
D0
E6
2C
10
91
AD
2C
60
20
20
20
C9
F0
60
A5
48
A9
85
BD
20
68
85
BD
C9
F0
C9
F0
E0
90
20
E8
D0
A9
20

3F
3C
02
3D
4B
DB FC
F9
FE
F5
21
DB FC

RTS4B
HEADR

WRBIT

ZERDLY
FD
05
32
ONEDLY
FD
20 C0
2C

08

WRTAPE

RDBYTE
RDBYT2

FA FC

3A
F5
FD FC

RD2BIT
RDBIT

60 C0
2F
F8
2F
2F
80
24
28

RDKEY

3F
40
28
38
4E
02
4F
00
F5
28
00
10

00
KEYIN

C0

KEYIN2

C0
C0

0C FD
2C FC
0C FD
9B
F3

ESC

32

NOTCR

RDCHAR

FF
32
00 02
ED FD
32
00 02
88
1D
98
0A
F8
03
3A FF
NOTCR1
13
DC
ED FD

CANCEL

SBC
INC
BNE
INC
RTS
LDY
JSR
BNE
ADC
BCS
LDY
JSR
INY
INY
DEY
BNE
BCC
LDY
DEY
BNE
LDY
LDY
DEX
RTS
LDX
PHA
JSR
PLA
ROL
LDY
DEX
BNE
RTS
JSR
DEY
LDA
EOR
BPL
EOR
STA
CPY
RTS
LDY
LDA
PHA
AND
ORA
STA
PLA
JMP
INC
BNE
INC
BIT
BPL
STA
LDA
BIT
RTS
JSR
JSR
JSR
CMP
BEQ
RTS
LDA
PHA
LDA
STA
LDA
JSR
PLA
STA
LDA
CMP
BEQ
CMP
BEQ
CPX
BCC
JSR
INX
BNE
LDA
JSR

85

A2H
A1L
RTS4B
A1H
#$4B
ZERDLY
HEADR
#$FE
HEADR
#$21
ZERDLY

ZERDLY
WRTAPE
#$32

(CARRY SET IF >=)

WRITE A*256 'LONG 1'
HALF CYCLES
(650 USEC EACH)
THEN A 'SHORT 0'
(400 USEC)
WRITE TWO HALF CYCLES
OF 250 USEC ('0')
OR 500 USEC ('0')

Y IS COUNT FOR
TIMING LOOP

ONEDLY
TAPEOUT
#$2C

#$08
RD2BIT

8 BITS TO READ
READ TWO TRANSITIONS
(FIND EDGE)

#$3A

NEXT BIT
COUNT FOR SAMPLES

RDBYT2
RDBIT
TAPEIN
LASTIN
RDBIT
LASTIN
LASTIN
#$80
CH
(BASL),Y

DECR Y UNTIL
TAPE TRANSITION

SET CARRY ON Y

SET SCREEN TO FLASH

#$3F
#$40
(BASL),Y
(KSWL)
RNDL
KEYIN2
RNDH
KBD
KEYIN
(BASL),Y
KBD
KBDSTRB

GO TO USER KEY-IN

KEY DOWN?
LOOP
REPLACE FLASHING SCREEN
GET KEYCODE
CLR KEY STROBE

RDKEY
ESC1
RDKEY
#$9B
ESC

GET KEYCODE
HANDLE ESC FUNC.
READ KEY
ESC?
YES, DON'T RETURN

INCR RND NUMBER

INVFLG
#$FF
INVFLG
IN,X
COUT
INVFLG
IN,X
#$88
BCKSPC
#$98
CANCEL
#$F8
NOTCR1
BELL
NXTCHAR
#$DC
COUT

ECHO USER LINE
NON INVERSE

CHECK FOR EDIT KEYS
BS, CTRL-X

MARGIN?
YES, SOUND BELL
ADVANCE INPUT INDEX
BACKSLASH AFTER CANCELLED LINE

FD67:
FD6A:
FD6C:
FD6F:
FD71:
FD72:
FD74:
FD75:
FD78:
FD7A:
FD7C:

20
A5
20
A2
8A
F0
CA
20
C9
D0
B1

8E FD
33
ED FD
01

GETLNZ
GETLN

35 FD
95
02
28

NXTCHAR

FD7E:
FD80:
FD82:
FD84:
FD87:
FD89:
FD8B:
FD8E:
FD90:
FD92:
FD94:
FD96:
FD99:
FD9C:
FD9E:
FDA0:
FDA3:
FDA5:
FDA7:
FDA9:
FDAB:
FDAD:
FDAF:
FDB1:
FDB3:
FDB6:
FDB8:
FDBB:
FDBD:
FDC0:
FDC3:
FDC5:
FDC6:
FDC7:
FDC9:
FDCA:
FDCB:
FDCD:
FDCF:
FDD1:
FDD3:
FDD4:
FDD6:
FDD9:
FDDA:
FDDB:
FDDC:
FDDD:
FDDE:
FDDF:
FDE2:
FDE3:
FDE5:
FDE7:
FDE9:
FDEB:
FDED:
FDF0:
FDF2:
FDF4:
FDF6:
FDF8:
FDF9:
FDFC:
FDFD:
FDFF:
FE00:
FE02:
FE04:
FE05:
FE07:
FE09:
FE0B:
FE0D:

C9
90
29
9D
C9
D0
20
A9
D0
A4
A6
20
20
A0
A9
4C
A5
09
85
A5
85
A5
29
D0
20
A9
20
B1
20
20
90
60
4A
90
4A
4A
A5
90
49
65
48
A9
20
68
48
4A
4A
4A
4A
20
68
29
09
C9
90
69
6C
C9
90
25
84
48
20
68
A4
60
C6
F0
CA
D0
C9
D0
85
A5

E0
02
DF
00
8D
B2
9C
8D
5B
3D
3C
8E
40
00
AD
ED
3C
07
3E
3D
3F
3C
07
03
92
A0
ED
3C
DA
BA
E8

CAPTST

BCKSPC
F3

02

ADDINP

FC
CROUT
PRA1
FD
F9

PRYX2

FD
XAM8

MODSCHK

FD

XAM
DATAOUT

FD
FD
FC
RTS4C
XAMPM

EA

3E
02
FF
3C

ADD

BD
ED FD
PRBYTE

E5 FD
0F
B0
BA
02
06
36 00
A0
02
32
35

PRHEX
PRHEXZ

COUT
COUT1

COUTZ

FD FB
35
34
9F

BL1
BLANK

16
BA
BB
31
3E

STOR

JSR
LDA
JSR
LDX
TXA
BEQ
DEX
JSR
CMP
BNE
LDA

CROUT
PROMPT
COUT
#$01

CMP
BCC
AND
STA
CMP
BNE
JSR
LDA
BNE
LDY
LDX
JSR
JSR
LDY
LDA
JMP
LDA
ORA
STA
LDA
STA
LDA
AND
BNE
JSR
LDA
JSR
LDA
JSR
JSR
BCC
RTS
LSR
BCC
LSR
LSR
LDA
BCC
EOR
ADC
PHA
LDA
JSR
PLA
PHA
LSR
LSR
LSR
LSR
JSR
PLA
AND
ORA
CMP
BCC
ADC
JMP
CMP
BCC
AND
STY
PHA
JSR
PLA
LDY
RTS
DEC
BEQ
DEX
BNE
CMP
BNE
STA
LDA

#$E0
ADDINP
#$DF
IN,X
#$8D
NOTCR
CLREOL
#$8D
COUT
A1H
A1L
CROUT
PRNTYX
#$00
#$AD
COUT
A1L
#$07
A2L
A1H
A2H
A1L
#$07
DATAOUT
PRA1
#$A0
COUT
(A1L),Y
PRBYTE
NXTA1
MODSCHK

86

OUTPUT CR
OUTPUT PROMPT CHAR
INIT INPUT INDEX
WILL BACKSPACE TO 0

GETLNZ
RDCHAR
#PICK
CAPTST
(BASL),Y

A
XAM
A
A
A2L
ADD
#$FF
A1L
#$BD
COUT

A
A
A
A
PRHEXZ
#$0F
#$B0
#$BA
COUT
#$06
(CSWL)
#$A0
COUTZ
INVFLG
YSAV1
VIDOUT
YSAV1

USE SCREEN CHAR
FOR CTRL-U

CONVERT TO CAPS
ADD TO INPUT BUF

CLR TO EOL IF CR

PRINT CR,A1 IN HEX

PRINT '-'

SET TO FINISH AT
MOD 8=7

OUTPUT BLANK
OUTPUT BYTE IN HEX
CHECK IF TIME TO,
PRINT ADDR
DETERMINE IF MON
MODE IS XAM
ADD, OR SUB

SUB: FORM 2'S COMPLEMENT

PRINT '=', THEN RESULT
PRINT BYTE AS 2 HEX
DIGITS, DESTROYS A-REG

PRINT HEX DIG IN A-REG
LSB'S

VECTOR TO USER OUTPUT ROUTINE
DON'T OUTPUT CTRL'S INVERSE
MASK WITH INVERSE FLAG
SAV Y-REG
SAV A-REG
OUTPUT A-REG AS ASCII
RESTORE A-REG
AND Y-REG
THEN RETURN

YSAV
XAM8
SETMDZ
#$BA
XAMPM
MODE
A2L

BLANK TO MON
AFTER BLANK
DATA STORE MODE?
NO, XAM, ADD, OR SUB
KEEP IN STORE MODE

FE0F:
FE11:
FE13:
FE15:
FE17:
FE18:
FE1A:
FE1D:
FE1F:
FE20:
FE22:
FE24:
FE26:
FE28:
FE29:
FE2B:
FE2C:
FE2E:
FE30:
FE33:
FE35:
FE36:
FE38:
FE3A:
FE3C:
FE3F:
FE41:
FE44:
FE46:
FE49:
FE4B:
FE4E:
FE50:
FE53:
FE55:
FE58:
FE5B:
FE5D:
FE5E:
FE61:
FE63:
FE64:
FE67:
FE6A:
FE6C:
FE6E:
FE6F:
FE70:
FE72:
FE74:
FE75:
FE76:
FE78:
FE7A:
FE7C:
FE7D:
FE7F:
FE80:
FE82:
FE84:
FE86:
FE88:
FE89:
FE8B:
FE8D:
FE8F:
FE91:
FE93:
FE95:
FE97:
FE99:
FE9B:
FE9D:
FE9F:
FEA1:
FEA3:
FEA5:
FEA7:
FEA9:
FEAB:
FEAD:
FEAE:
FEAF:
FEB0:
FEB3:

91
E6
D0
E6
60
A4
B9
85
60
A2
B5
95
95
CA
10
60
B1
91
20
90
60
B1
D1
F0
20
B1
20
A9
20
A9
20
B1
20
A9
20
20
90
60
20
A9
48
20
20
85
84
68
38
E9
D0
60
8A
F0
B5
95
CA
10
60
A0
D0
A0
84
60
A9
85
A2
A0
D0
A9
85
A2
A0
A5
29
F0
09
A0
F0
A9
94
95
60
EA
EA
4C
4C

40
40
02
41
34
FF 01
31
01
3E
42
44

RTS5
SETMODE
SETMDZ
LT
LT2

F7
3C
42
B4 FC
F7

MOVE

3C
42
1C
92
3C
DA
A0
ED
A8
ED
42
DA
A9
ED
B4
D9

VFY

FD
FD
FD
FD
FD
FD
FC

75 FE
14

VFYOK

LIST
LIST2

D0 F8
53 F9
3A
3B

01
EF
A1PC
07
3C
3A

A1PCLP

F9
3F
02
FF
32

A1PCRTS
SETINV
SETNORM
SETIFLG

00
3E
38
1B
08
00
3E
36
F0
3E
0F
06
C0
00
02
FD
00
01

SETKBD
INPORT
INPRT

00 E0
03 E0

XBASIC
BASCONT

SETVID
OUTPORT
OUTPRT
IOPRT

IOPRT1
IOPRT2

STA
INC
BNE
INC
RTS
LDY
LDA
STA
RTS
LDX
LDA
STA
STA
DEX
BPL
RTS
LDA
STA
JSR
BCC
RTS
LDA
CMP
BEQ
JSR
LDA
JSR
LDA
JSR
LDA
JSR
LDA
JSR
LDA
JSR
JSR
BCC
RTS
JSR
LDA
PHA
JSR
JSR
STA
STY
PLA
SEC
SBC
BNE
RTS
TXA
BEQ
LDA
STA
DEX
BPL
RTS
LDY
BNE
LDY
STY
RTS
LDA
STA
LDX
LDY
BNE
LDA
STA
LDX
LDY
LDA
AND
BEQ
ORA
LDY
BEQ
LDA
STY
STA
RTS
NOP
NOP
JMP
JMP

87

(A3L),Y
A3L
RTS5
A3H
YSAV
IN-1,Y
MODE
#$01
A2L,X
A4L,X
A5L,X

STORE AS LOW BYTE AS (A3)
INCR A3, RETURN

SAVE CONVERTED ':', '+',
'-', '.' AS MODE.

COPY A2 (2 BYTES) TO
A4 AND A5

LT2
(A1L),Y
(A4L),Y
NXTA4
MOVE

MOVE (A1 TO A2) TO
(A4)

(A1L),Y
(A4L),Y
VFYOK
PRA1
(A1L),Y
PRBYTE
#$A0
COUT
#$A8
COUT
(A4L),Y
PRBYTE
#$A9
COUT
NXTA4
VFY

VERIFY (A1 TO A2) WITH
(A4)

A1PC
#$14

MOVE A1 (2 BYTES) TO
PC IF SPEC'D AND
DISEMBLE 20 INSTRS

INSTDSP
PCADJ
PCL
PCH

#$01
LIST2

A1PCRTS
A1L,X
PCL,X

ADJUST PC EACH INSTR

NEXT OF 20 INSTRS

IF USER SPEC'D ADR
COPY FROM A1 TO PC

A1PCLP
#$3F
SETIFLG
#$FF
INVFLG

SET FOR INVERSE VID
VIA COUT1
SET FOR NORMAL VID

#$00
SIMULATE PORT #0 INPUT
A2L
SPECIFIED (KEYIN ROUTINE)
#KSWL
#KEYIN
IOPRT
#$00
SIMULATE PORT #0 OUTPUT
A2L
SPECIFIED (COUT1 ROUTINE)
#CSWL
#COUT1
A2L
SET RAM IN/OUT VECTORS
#$0F
IOPRT1
#IOADR/256
#$00
IOPRT2
#COUT1/256
LOC0,X
LOC1,X

BASIC
BASIC2

TO BASIC WITH SCRATCH
CONTINUE BASIC

FEB6:
FEB9:
FEBC:
FEBF:
FEC2:
FEC4:
FEC7:
FECA:
FECD:
FECF:
FED2:
FED4:
FED6:
FED8:
FED9:
FEDB:
FEDE:
FEE1:
FEE3:
FEE4:
FEE6:
FEE8:
FEEB:
FEED:
FEEF:
FEF0:
FEF3:
FEF5:
FEF6:
FEF9:
FEFA:
FEFB:
FEFD:
FF00:
FF02:
FF05:
FF07:
FF0A:
FF0C:
FF0F:
FF11:
FF14:
FF16:
FF19:
FF1B:
FF1D:
FF1F:
FF22:
FF24:
FF26:
FF29:
FF2B:
FF2D:
FF2F:
FF32:
FF34:
FF37:
FF3A:
FF3C:
FF3F:
FF41:
FF42:
FF44:
FF46:
FF48:
FF49:
FF4A:
FF4C:
FF4E:
FF50:
FF51:
FF52:
FF54:
FF55:
FF57:
FF58:
FF59:
FF5C:
FF5F:
FF62:
FF65:
FF66:
FF69:
FF6B:
FF6D:

20
20
6C
4C
C6
20
4C
4C
A9
20
A0
A2
41
48
A1
20
20
A0
68
90
A0
20
F0
A2
0A
20
D0
60
20
68
68
D0
20
A9
20
85
20
A0
20
B0
20
A0
20
81
45
85
20
A0
90
20
C5
F0
A9
20
A9
20
20
A9
4C
A5
48
A5
A6
A4
28
60
85
86
84
08
68
85
BA
86
D8
60
20
20
20
20
D8
20
A9
85
20

75
3F
3A
D7
34
75
43
F8
40
C9
27
00
3C

FE
FF
00
FA
FE
FA
03

GO

REGZ
TRACE
STEPZ
USR
WRITE

FC
WR1

3C
ED FE
BA FC
1D
EE
22
ED FE
4D
10

WRBYTE
WRBYT2

D6 FC
FA
00 FE

6C
FA
16
C9
2E
FA
24
FD
F9
FD
3B
EC
3C
2E
2E
BA
35
F0
EC
2E
0D
C5
ED
D2
ED
ED
87
ED
48

FC

CRMON

READ

FC
FC
RD2
FC
FC
FC

RD3

FC

FC

PRERR
FD
FD
FD
BELL
FD
RESTORE

45
46
47

RESTR1

45
46
47

SAVE
SAV1

48
49

84
2F
93
89

FE
FB
FE
FE

RESET

MON
3A FF
AA
33
67 FD

MONZ

JSR
JSR
JMP
JMP
DEC
JSR
JMP
JMP
LDA
JSR
LDY
LDX
EOR
PHA
LDA
JSR
JSR
LDY
PLA
BCC
LDY
JSR
BEQ
LDX
ASL
JSR
BNE
RTS
JSR
PLA
PLA
BNE
JSR
LDA
JSR
STA
JSR
LDY
JSR
BCS
JSR
LDY
JSR
STA
EOR
STA
JSR
LDY
BCC
JSR
CMP
BEQ
LDA
JSR
LDA
JSR
JSR
LDA
JMP
LDA
PHA
LDA
LDX
LDY
PLP
RTS
STA
STX
STY
PHP
PLA
STA
TSX
STX
CLD
RTS
JSR
JSR
JSR
JSR
CLD
JSR
LDA
STA
JSR

88

A1PC
RESTORE
(PCL)
REGDSP
YSAV
A1PC
STEP
USRADR
#$40
HEADR
#$27
#$00
(A1L,X)

ADR TO PC IF SPEC'D
RESTORE META REGS
GO TO USER SUBR
TO REG DISPLAY
ADR TO PC IF SPEC'D
TAKE ONE STEP
TO USR SUBR AT USRADR
WRITE 10-SEC HEADER

(A1L,X)
WRBYTE
NXTA1
#$1D
WR1
#$22
WRBYTE
BELL
#$10
A
WRBIT
WRBYT2
BL1

MONZ
RD2BIT
#$16
HEADR
CHKSUM
RD2BIT
#$24
RDBIT
RD2
RDBIT
#$3B
RDBYTE
(A1L,X)
CHKSUM
CHKSUM
NXTA1
#$35
RD3
RDBYTE
CHKSUM
BELL
#$C5
COUT
#$D2
COUT
COUT
#$87
COUT
STATUS

HANDLE A CR AS BLANK
THEN POP STACK
AND RTN TO MON
FIND TAPEIN EDGE
DELAY 3.5 SECONDS
INIT CHKSUM=$FF
FIND TAPEIN EDGE
LOOK FOR SYNC BIT
(SHORT 0)
LOOP UNTIL FOUND
SKIP SECOND SYNC H-CYCLE
INDEX FOR 0/1 TEST
READ A BYTE
STORE AT (A1)
UPDATE RUNNING CHKSUM
INC A1, COMPARE TO A2
COMPENSATE 0/1 INDEX
LOOP UNTIL DONE
READ CHKSUM BYTE
GOOD, SOUND BELL AND RETURN
PRINT "ERR", THEN BELL

OUTPUT BELL AND RETURN
RESTORE 6502 REG CONTENTS
USED BY DEBUG SOFTWARE

ACC
XREG
YREG

ACC
XREG
YREG

SAVE 6502 REG CONTENTS

STATUS
SPNT

SETNORM
INIT
SETVID
SETKBD

SET SCREEN MODE
AND INIT KBD/SCREEN
AS I/O DEV'S
MUST SET HEX MODE!

BELL
#$AA
PROMPT
GETLNZ

'*' PROMPT FOR MON
READ A LINE

FF70:
FF73:
FF76:
FF78:
FF7A:
FF7B:
FF7D:
FF80:
FF82:
FF85:
FF87:
FF8A:
FF8C:
FF8D:
FF8E:
FF8F:
FF90:
FF91:
FF93:
FF95:
FF96:
FF98:
FF9A:
FF9C:
FF9E:
FFA0:
FFA2:
FFA3:
FFA5:
FFA7:
FFA9:
FFAB:
FFAD:
FFB0:
FFB1:
FFB3:
FFB5:
FFB7:
FFB9:
FFBB:
FFBD:
FFBE:
FFC0:
FFC1:
FFC4:
FFC5:
FFC7:

20
20
84
A0
88
30
D9
D0
20
A4
4C
A2
0A
0A
0A
0A
0A
26
26
CA
10
A5
D0
B5
95
95
E8
F0
D0
A2
86
86
B9
C8
49
C9
90
69
C9
B0
60
A9
48
B9
48
A5
A0

C7 FF
A7 FF
34
17

FFC9:
FFCB:
FFCC:
FFCD:
FFCE:
FFCF:
FFD0:
FFD1:
FFD2:
FFD3:
FFD4:
FFD5:
FFD6:
FFD7:
FFD8:
FFD9:
FFDA:
FFDB:
FFDC:
FFDD:
FFDE:
FFDF:
FFE0:
FFE1:
FFE2:
FFE3:
FFE4:
FFE5:
FFE6:
FFE7:
FFE8:
FFE9:
FFEA:
FFEB:
FFEC:
FFED:
FFEE:
FFEF:

84 31
60
BC
B2
BE
ED
EF
C4
EC
A9
BB
A6
A4
06
95
07
02
05
F0
00
EB
93
A7
C6
99
B2
C9
BE
C1
35
8C
C3
96
AF
17
17
2B
1F

NXTITM

CHRSRCH
E8
CC FF
F8
BE FF
34
73 FF
03

DIG

NXTBIT
3E
3F
F8
31
06
3F
3D
41

NXTBAS

NXTBS2
F3
06
00
3E
3F
00 02

GETNUM

NXTCHR

B0
0A
D3
88
FA
CD
FE

TOSUB

E3 FF
31
00

ZMODE

CHRTBL

SUBTBL

JSR
JSR
STY
LDY
DEY
BMI
CMP
BNE
JSR
LDY
JMP
LDX
ASL
ASL
ASL
ASL
ASL
ROL
ROL
DEX
BPL
LDA
BNE
LDA
STA
STA
INX
BEQ
BNE
LDX
STX
STX
LDA
INY
EOR
CMP
BCC
ADC
CMP
BCS
RTS
LDA
PHA
LDA
PHA
LDA
LDY
STY
RTS
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB

89

ZMODE
GETNUM
YSAV
#$17

CLEAR MON
GET ITEM,
CHAR IN
X-REG=0

MODE, SCAN IDX
NON-HEX
A-REG
IF NO HEX INPUT

MON
CHRTBL,Y
CHRSRCH
TOSUB
YSAV
NXTITM
#$03
A
A
A
A
A
A2L
A2H

NOT FOUND, GO TO MON
FIND CMND CHAR IN TEL
FOUND, CALL CORRESPONDING
SUBROUTINE

GOT HEX DIG,
SHIFT INTO A2

LEAVE X=$FF IF DIG
NXTBIT
MODE
NXTBS2
A2H,X
A1H,X
A3H,X
NXTBAS
NXTCHR
#$00
A2L
A2H
IN,Y
#$B0
#$0A
DIG
#$88
#$FA
DIG
#GO/256
SUBTBL,Y
MODE
#$00
MODE
$BC
$B2
$BE
$ED
$EF
$C4
$EC
$A9
$BB
$A6
$A4
$06
$95
$07
$02
$05
$F0
$00
$EB
$93
$A7
$C6
$99
BASCONT-1
USR-1
REGZ-1
TRACE-1
VFY-1
INPRT-1
STEPZ-1
OUTPRT-1
XBASIC-1
SETMODE-1
SETMODE-1
MOVE-1
LT-1

IF MODE IS ZERO
THEN COPY A2 TO
A1 AND A3

CLEAR A2

GET CHAR

IF HEX DIG, THEN

PUSH HIGH-ORDER
SUBR ADR ON STK
PUSH LOW-ORDER
SUBR ADR ON STK
CLR MODE, OLD MODE
TO A-REG
GO TO SUBR VIA RTS
F("CTRL-C")
F("CTRL-Y")
F("CTRL-E")
F("T")
F("V")
F("CTRL-K")
F("S")
F("CTRL-P")
F("CTRL-B")
F("-")
F("+")
F("M") (F=EX-OR $B0+$89)
F("<")
F("N")
F("I")
F("L")
F("W")
F("G")
F("R")
F(":")
F(".")
F("CR")
F(BLANK)

FFF0:
FFF1:
FFF2:
FFF3:
FFF4:
FFF5:
FFF6:
FFF7:
FFF8:
FFF9:
FFFA:
FFFB:
FFFC:
FFFD:
FFFE:
FFFF:

83
7F
5D
CC
B5
FC
17
17
F5
03
FB
03
59
FF
86
FA
XQTNZ

DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
EQU

90

SETNORM-1
SETINV-1
LIST-1
WRITE-1
GO-1
READ-1
SETMODE-1
SETMODE-1
CRMON-1
BLANK-1
NMI
NMI/256
RESET
RESET/256
IRQ
IRQ/256
$3C

NMI VECTOR
RESET VECTOR
IRQ VECTOR

F500:
F502:
F503:
F505:
F507:
F509:
F50B:
F50C:
F50D:
F50E:
F50F:
F511:
F513:
F515:
F516:

E9
4A
D0
A4
A6
D0
88
CA
8A
18
E5
85
10
C8
98

81
14
3F
3E
01

3A
3E
01

***********************
*
*
*
APPLE-II
*
*
MINI-ASSEMBLER
*
*
*
* COPYRIGHT 1977 BY *
* APPLE COMPUTER INC. *
*
*
* ALL RIGHTS RESERVED *
*
*
*
S. WOZNIAK
*
*
A. BAUM
*
***********************
TITLE "APPLE-II MINI-ASSEMBLER"
FORMAT
EQU
$2E
LENGTH
EQU
$2F
MODE
EQU
$31
PROMPT
EQU
$33
YSAV
EQU
$34
L
EQU
$35
PCL
EQU
$3A
PCH
EQU
$3B
A1H
EQU
$3D
A2L
EQU
$3E
A2H
EQU
$3F
A4L
EQU
$42
A4H
EQU
$43
FMT
EQU
$44
IN
EQU
$200
INSDS2
EQU
$F88E
INSTDSP EQU
$F8D0
PRBL2
EQU
$F94A
PCADJ
EQU
$F953
CHAR1
EQU
$F9B4
CHAR2
EQU
$F9BA
MNEML
EQU
$F9C0
MNEMR
EQU
$FA00
CURSUP
EQU
$FC1A
GETLNZ
EQU
$FD67
COUT
EQU
$FDED
BL1
EQU
$FE00
A1PCLP
EQU
$FE78
BELL
EQU
$FF3A
GETNUM
EQU
$FFA7
TOSUB
EQU
$FFBE
ZMODE
EQU
$FFC7
CHRTBL
EQU
$FFCC
ORG
$F500
REL
SBC
#$81
IS FMT COMPATIBLE
LSR
WITH RELATIVE MODE?
BNE
ERR3
NO.
LDY
A2H
LDX
A2L
DOUBLE DECREMENT
BNE
REL2
DEY
REL2
DEX
TXA
CLC
SBC
PCL
FORM ADDR-PC-2
STA
A2L
BPL
REL3
INY
REL3
TYA

91

F517:
F519:
F51B:
F51D:
F520:
F522:
F523:
F525:
F528:
F52B:
F52E:
F531:
F533:
F535:
F538:
F53B:
F53D:
F540:
F542:
F544:
F545:
F547:
F54A:
F54C:
F54E:
F550:
F552:
F554:
F556:
F559:
F55C:
F55E:
F561:
F562:
F565:
F567:
F569:
F56C:
F56E:
F570:
F572:
F574:
F576:
F578:
F57A:
F57C:
F57E:
F580:
F582:
F584:
F586:
F588:
F589:
F58A:
F58D:
F58F:
F592:
F595:
F597:
F599:
F59C:
F59F:
F5A2:
F5A4:
F5A6:
F5A7:
F5A9:
F5AB:
F5AC:
F5AF:
F5B1:
F5B3:
F5B4:
F5B6:
F5B9:
F5BB:
F5BD:
F5C0:
F5C1:
F5C3:
F5C5:
F5C7:
F5C8:
F5C9:
F5CB:

E5
D0
A4
B9
91
88
10
20
20
20
20
84
85
4C
20
A4
20
84
A0
88
30
D9
D0
C0
D0
A5
A0
C6
20
4C
A5
20
AA
BD
C5
D0
BD
C5
D0
A5
A4
C0
F0
C5
F0
C6
D0
E6
C6
F0
A4
98
AA
20
A9
20
20
A9
85
20
20
AD
C9
F0
C8
C9
F0
88
20
C9
D0
8A
F0
20
A9
85
20
0A
E9
C9
90
0A
0A
A2
0A

3B
6B
2F
3D 00
3A
F8
1A
1A
D0
53
3B
3A
95
BE
34
A7
34
17
4B
CC
F8
15
E8
31
00
34
00
95
3D
8E

FC
FC
F8
F9

F5
FF
FF

FF

FE
F5
F8

00 FA
42
13
C0 F9
43
0C
44
2E
9D
88
2E
9F
3D
DC
44
35
D6
34

4A
DE
ED
3A
A1
33
67
C7
00
A0
13

F9
FD
FF

FD
FF
02

A4
92
A7 FF
93
D5
D2
78 FE
03
3D
34 F6
BE
C2
C1

04

SBC
BNE
LDY
LDA
STA
DEY
BPL
JSR
JSR
JSR
JSR
STY
STA
JMP
FAKEMON3 JSR
LDY
FAKEMON JSR
STY
LDY
FAKEMON2 DEY
BMI
CMP
BNE
CPY
BNE
LDA
LDY
DEC
JSR
JMP
TRYNEXT LDA
JSR
TAX
LDA
CMP
BNE
LDA
CMP
BNE
LDA
LDY
CPY
BEQ
NREL
CMP
BEQ
NEXTOP
DEC
BNE
INC
DEC
BEQ
ERR
LDY
ERR2
TYA
TAX
JSR
LDA
JSR
RESETZ
JSR
NXTLINE LDA
STA
JSR
JSR
LDA
CMP
BEQ
INY
CMP
BEQ
DEY
JSR
CMP
ERR4
BNE
TXA
BEQ
JSR
SPACE
LDA
STA
NXTMN
JSR
NXTM
ASL
SBC
CMP
BCC
ASL
ASL
LDX
NXTM2
ASL
ERR3
FINDOP
FNDOP2

PCH
ERR
LENGTH
A1H,Y
(PCL),Y
FNDOP2
CURSUP
CURSUP
INSTDSP
PCADJ
PCH
PCL
NXTLINE
TOSUB
YSAV
GETNUM
YSAV
#$17
RESETZ
CHRTBL,Y
FAKEMON2
#$15
FAKEMON3
MODE
#$0
YSAV
BL1
NXTLINE
A1H
INSDS2
MNEMR,X
A4L
NEXTOP
MNEML,X
A4H
NEXTOP
FMT
FORMAT
#$9D
REL
FORMAT
FINDOP
A1H
TRYNEXT
FMT
L
TRYNEXT
YSAV

PRBL2
#$DE
COUT
BELL
#$A1
PROMPT
GETLNZ
ZMODE
IN
#$A0
SPACE
#$A4
FAKEMON
GETNUM
#$93
ERR2
ERR2
A1PCLP
#$3
A1H
GETNSP
A
#$BE
#$C2
ERR2
A
A
#$4
A

92

ERROR IF >1-BYTE BRANCH
MOVE INST TO (PC)

RESTORE CURSOR
TYPE FORMATTED LINE
UPDATE PC

GET NEXT LINE
GO TO DELIM HANDLER
RESTORE Y-INDEX
READ PARAM
SAVE Y-INDEX
INIT DELIMITER INDEX
CHECK NEXT DELIM
ERR IF UNRECOGNIZED DELIM
COMPARE WITH DELIM TABLE
NO MATCH
MATCH, IS IT CR?
NO, HANDLE IT IN MONITOR

HANDLE CR OUTSIDE MONITOR
GET TRIAL OPCODE
GET FMT+LENGTH FOR OPCODE
GET LOWER MNEMONIC BYTE
MATCH?
NO, TRY NEXT OPCODE.
GET UPPER MNEMONIC BYTE
MATCH?
NO, TRY NEXT OPCODE
GET TRIAL FORMAT
TRIAL FORMAT RELATIVE?
YES.
SAME FORMAT?
YES.
NO, TRY NEXT OPCODE
NO MORE, TRY WITH LEN=2
WAS L=2 ALREADY?
NO.
YES, UNRECOGNIZED INST.

PRINT ^ UNDER LAST READ
CHAR TO INDICATE ERROR
POSITION.
'!'
INITIALIZE PROMPT
GET LINE.
INIT SCREEN STUFF
GET CHAR
ASCII BLANK?
YES
ASCII '$' IN COL 1?
YES, SIMULATE MONITOR
NO, BACKUP A CHAR
GET A NUMBER
':' TERMINATOR?
NO, ERR.
NO ADR PRECEDING COLON.
MOVE ADR TO PCL, PCH.
COUNT OF CHARS IN MNEMONIC
GET FIRST MNEM CHAR.
SUBTRACT OFFSET
LEGAL CHAR?
NO.
COMPRESS-LEFT JUSTIFY

DO 5 TRIPLE WORD SHIFTS

F5CC:
F5CE:
F5D0:
F5D1:
F5D3:
F5D5:
F5D7:
F5D9:
F5DB:
F5DE:
F5E0:
F5E3:
F5E5:
F5E8:
F5EB:
F5ED:
F5F0:
F5F2:
F5F4:
F5F6:
F5F8:
F5F9:
F5FA:
F5FC:
F5FE:
F600:
F603:
F605:
F607:
F608:
F60A:
F60C:
F60D:
F60F:
F610:
F612:
F614:
F615:
F616:
F618:
F61A:
F61C:
F61E:
F620:
F622:
F624:
F626:
F629:
F62B:
F62D:
F62F:
F631:
F634:
F637:
F638:
F63A:
F63C:

26
26
CA
10
C6
F0
10
A2
20
84
DD
D0
20
DD
F0
BD
F0
C9
F0
A4
18
88
26
E0
D0
20
A5
F0
E8
86
A2
88
86
CA
10
A5
0A
0A
05
C9
B0
A6
F0
09
85
84
B9
C9
F0
C9
D0
4C
B9
C8
C9
F0
60

42
43
F8
3D
F4
E4
05
34
34
B4
13
34
BA
0D
BA
07
A4
03
34

F6

FORM1
FORM2

F9
F6
F9
F9

44
03
0D
A7 FF
3F
01

FORM3
FORM4
FORM5

35
03

FORM6

3D

FORM7

C9
44

35
20
06
35
02
80
44
34
00 02
BB
04
8D
80
5C F5
00 02

FORM8

FORM9
GETNSP

A0
F8

F666: 4C 92 F5

MINIASM

ROL
ROL
DEX
BPL
DEC
BEQ
BPL
LDX
JSR
STY
CMP
BNE
JSR
CMP
BEQ
LDA
BEQ
CMP
BEQ
LDY
CLC
DEY
ROL
CPX
BNE
JSR
LDA
BEQ
INX
STX
LDX
DEY
STX
DEX
BPL
LDA
ASL
ASL
ORA
CMP
BCS
LDX
BEQ
ORA
STA
STY
LDA
CMP
BEQ
CMP
BNE
JMP
LDA
INY
CMP
BEQ
RTS
ORG
JMP

A4L
A4H
NXTM2
A1H
NXTM2
NXTMN
#$5
GETNSP
YSAV
CHAR1,X
FORM3
GETNSP
CHAR2,X
FORM5
CHAR2,X
FORM4
#$A4
FORM4
YSAV

FMT
#$3
FORM7
GETNUM
A2H
FORM6
L
#$3
A1H
FORM2
FMT
A
A
L
#$20
FORM8
L
FORM8
#$80
FMT
YSAV
IN,Y
#$BB
FORM9
#$8D
ERR4
TRYNEXT
IN,Y
#$A0
GETNSP
$F666
RESETZ

93

DONE WITH 3 CHARS?
YES, BUT DO 1 MORE SHIFT
NO
5 CHARS IN ADDR MODE
GET FIRST CHAR OF ADDR
FIRST CHAR MATCH PATTERN?
NO
YES, GET SECOND CHAR
MATCHES SECOND HALF?
YES.
NO, IS SECOND HALF ZERO?
YES.
NO,SECOND HALF OPTIONAL?
YES.
CLEAR BIT-NO MATCH
BACK UP 1 CHAR
FORM FORMAT BYTE
TIME TO CHECK FOR ADDR.
NO
YES
HIGH-ORDER BYTE ZERO
NO, INCR FOR 2-BYTE
STORE LENGTH
RELOAD FORMAT INDEX
BACKUP A CHAR
SAVE INDEX
DONE WITH FORMAT CHECK?
NO.
YES, PUT LENGTH
IN LOW BITS

ADD "$" IF NONZERO LENGTH
AND DON'T ALREADY HAVE IT

GET NEXT NONBLANK
'' START OF COMMENT?
YES
CARRIAGE RETURN?
NO, ERR.

GET NEXT NON BLANK CHAR

F425:
F426:
F428:
F42A:
F42C:
F42E:
F42F:
F431:
F432:
F434:
F437:
F439:
F43B:
F43E:
F440:
F441:
F443:
F445:
F447:
F449:
F44B:
F44D:
F44E:
F450:
F451:
F453:
F455:
F457:
F459:
F45B:
F45D:
F45F:
F461:
F463:
F465:
F467:
F468:
F46B:
F46E:
F470:
F472:
F474:
F477:
F479:

18
A2
B5
75
95
CA
10
60
06
20
24
10
20
E6
38
A2
94
B5
B4
94
95
CA
D0
60
A9
85
A5
C9
30
C6
06
26
26
A5
D0
60
20
20
A5
C5
D0
20
50
70

02
F9
F5
F9
F7
F3
37 F4
F9
05
A4 F4
F3
04
FB
F7
F3
F7
F3
F3
8E
F8
F9
C0
0C
F8
FB
FA
F9
F8
EE
A4 F4
7B F4
F4
F8
F7
25 F4
EA
05

***********************
*
*
* APPLE-II FLOATING *
*
POINT ROUTINES
*
*
*
* COPYRIGHT 1977 BY *
* APPLE COMPUTER INC. *
*
*
* ALL RIGHTS RESERVED *
*
*
*
S. WOZNIAK
*
*
*
***********************
TITLE "FLOATING POINT ROUTINES"
SIGN
EPZ $F3
X2
EPZ $F4
M2
EPZ $F5
X1
EPZ $F8
M1
EPZ $F9
E
EPZ $FC
OVLOC
EQU $3F5
ORG $F425
ADD
CLC
CLEAR CARRY
LDX #$2
INDEX FOR 3-BYTE ADD.
ADD1
LDA M1,X
ADC M2,X
ADD A BYTE OF MANT2 TO MANT1
STA M1,X
DEX
INDEX TO NEXT MORE SIGNIF. BYTE.
BPL ADD1
LOOP UNTIL DONE.
RTS
RETURN
MD1
ASL SIGN
CLEAR LSB OF SIGN.
JSR ABSWAP
ABS VAL OF M1, THEN SWAP WITH M2
ABSWAP
BIT M1
MANT1 NEGATIVE?
BPL ABSWAP1 NO, SWAP WITH MANT2 AND RETURN.
JSR FCOMPL
YES, COMPLEMENT IT.
INC SIGN
INCR SIGN, COMPLEMENTING LSB.
ABSWAP1
SEC
SET CARRY FOR RETURN TO MUL/DIV.
SWAP
LDX #$4
INDEX FOR 4 BYTE SWAP.
SWAP1
STY E-1,X
LDA X1-1,X
SWAP A BYTE OF EXP/MANT1 WITH
LDY X2-1,X
EXP/MANT2 AND LEAVE A COPY OF
STY X1-1,X
MANT1 IN E (3 BYTES). E+3 USED
STA X2-1,X
DEX
ADVANCE INDEX TO NEXT BYTE
BNE SWAP1
LOOP UNTIL DONE.
RTS
RETURN
FLOAT
LDA #$8E
INIT EXP1 TO 14,
STA X1
THEN NORMALIZE TO FLOAT.
NORM1
LDA M1
HIGH-ORDER MANT1 BYTE.
CMP #$C0
UPPER TWO BITS UNEQUAL?
BMI RTS1
YES, RETURN WITH MANT1 NORMALIZED
DEC X1
DECREMENT EXP1.
ASL M1+2
ROL M1+1
SHIFT MANT1 (3 BYTES) LEFT.
ROL M1
NORM
LDA X1
EXP1 ZERO?
BNE NORM1
NO, CONTINUE NORMALIZING.
RTS1
RTS
RETURN.
FSUB
JSR FCOMPL
CMPL MANT1,CLEARS CARRY UNLESS 0
SWPALGN
JSR ALGNSWP RIGHT SHIFT MANT1 OR SWAP WITH
FADD
LDA X2
CMP X1
COMPARE EXP1 WITH EXP2.
BNE SWPALGN IF #,SWAP ADDENDS OR ALIGN MANTS.
JSR ADD
ADD ALIGNED MANTISSAS.
ADDEND
BVC NORM
NO OVERFLOW, NORMALIZE RESULT.
BVS RTLOG
OV: SHIFT M1 RIGHT, CARRY INTO SIGN

94

F47B: 90 C4
F47D:
F47F:
F480:
F482:
F484:
F486:
F488:
F489:
F48B:
F48C:
F48F:
F491:
F494:
F495:
F498:
F49A:
F49D:
F49E:
F4A0:
F4A2:
F4A4:
F4A5:
F4A7:
F4A9:
F4AB:
F4AD:
F4AE:
F4B0:
F4B2:
F4B5:
F4B7:
F4BA:
F4BB:
F4BD:
F4BF:
F4C1:
F4C2:
F4C3:
F4C5:
F4C7:
F4C8:
F4CA:
F4CC:
F4CD:
F4CF:
F4D1:
F4D3:
F4D5:
F4D7:
F4D9:
F4DB:
F4DD:
F4DE:
F4E0:
F4E2:
F4E4:
F4E6:
F4E8:
F4EA:
F4EC:
F4ED:
F4EE:
F4F0:
F4F2:
F4F4:
F4F6:
F4F7:
F4F9:

A5
0A
E6
F0
A2
76
E8
D0
60
20
65
20
18
20
90
20
88
10
46
90
38
A2
A9
F5
95
CA
D0
F0
20
E5
20
38
A2
B5
F5
48
CA
10
A2
68
90
95
E8
D0
26
26
26
06
26
26
B0
88
D0
F0
86
86
86
B0
30
68
68
90
49
85
A0
60
10
4C

F9

F63D:
F640:
F642:
F644:
F646:
F648:
F64A:
F64C:
F64E:
F650:
F652:
F654:
F656:
F657:
F659:
F65B:
F65D:

20
A5
10
C9
D0
24
10
A5
F0
E6
D0
E6
60
A9
85
85
60

7D F4
F8
13
8E
F5
F9
0A
FB
06
FA
02
F9

F8
75
FA
FF
FB
32 F4
F8
E2 F4
84 F4
03
25 F4
F5
F3
BF
03
00
F8
F8
F7
C5
32 F4
F8
E2 F4
02
F5
FC

F8
FD
02
F8
F8
FB
FA
F9
F7
F6
F5
1C
DA
BE
FB
FA
F9
0D
04

B2
80
F8
17
F7
F5 03

00
F9
FA

ALGNSWP
BCC SWAP
SWAP IF CARRY CLEAR,
*
ELSE SHIFT RIGHT ARITH.
RTAR
LDA M1
SIGN OF MANT1 INTO CARRY FOR
ASL
RIGHT ARITH SHIFT.
RTLOG
INC X1
INCR X1 TO ADJUST FOR RIGHT SHIFT
BEQ OVFL
EXP1 OUT OF RANGE.
RTLOG1
LDX #$FA
INDEX FOR 6:BYTE RIGHT SHIFT.
ROR1
ROR E+3,X
INX
NEXT BYTE OF SHIFT.
BNE ROR1
LOOP UNTIL DONE.
RTS
RETURN.
FMUL
JSR MD1
ABS VAL OF MANT1, MANT2
ADC X1
ADD EXP1 TO EXP2 FOR PRODUCT EXP
JSR MD2
CHECK PROD. EXP AND PREP. FOR MUL
CLC
CLEAR CARRY FOR FIRST BIT.
MUL1
JSR RTLOG1
M1 AND E RIGHT (PROD AND MPLIER)
BCC MUL2
IF CARRY CLEAR, SKIP PARTIAL PROD
JSR ADD
ADD MULTIPLICAND TO PRODUCT.
MUL2
DEY
NEXT MUL ITERATION.
BPL MUL1
LOOP UNTIL DONE.
MDEND
LSR SIGN
TEST SIGN LSB.
NORMX
BCC NORM
IF EVEN,NORMALIZE PROD,ELSE COMP
FCOMPL
SEC
SET CARRY FOR SUBTRACT.
LDX #$3
INDEX FOR 3 BYTE SUBTRACT.
COMPL1
LDA #$0
CLEAR A.
SBC X1,X
SUBTRACT BYTE OF EXP1.
STA X1,X
RESTORE IT.
DEX
NEXT MORE SIGNIFICANT BYTE.
BNE COMPL1
LOOP UNTIL DONE.
BEQ ADDEND
NORMALIZE (OR SHIFT RT IF OVFL).
FDIV
JSR MD1
TAKE ABS VAL OF MANT1, MANT2.
SBC X1
SUBTRACT EXP1 FROM EXP2.
JSR MD2
SAVE AS QUOTIENT EXP.
DIV1
SEC
SET CARRY FOR SUBTRACT.
LDX #$2
INDEX FOR 3-BYTE SUBTRACTION.
DIV2
LDA M2,X
SBC E,X
SUBTRACT A BYTE OF E FROM MANT2.
PHA
SAVE ON STACK.
DEX
NEXT MORE SIGNIFICANT BYTE.
BPL DIV2
LOOP UNTIL DONE.
LDX #$FD
INDEX FOR 3-BYTE CONDITIONAL MOVE
DIV3
PLA
PULL BYTE OF DIFFERENCE OFF STACK
BCC DIV4
IF M2" prompt character should appear on screen
indicating that you are now in BASIC.

2.

Load one of the supplied demonstration cassettes into recorder.
Set recorder level to approximately 5 and start recorder. Type
"LOAD" and return. First beep indicates that APPLE II has found
beginning of program; second indicates end of program followed
by ">" character on screen. If error occurs on loading, try a
different demo tape or try changing cassette volume level.

3.

Type RUN and carriage return to execute demonstration program.
Listings of these are included in the last section of this
manual.

109

THE APPLE II SWITCHING POWER SUPPLY

Switching power supplies generally have both advantages and peculiarities
not generally found in conventional power supplies. The Apple II user
is urged to review this section.

Your Apple II is equipped with an AC line
voltage filter and a three wire AC line cord.
It is important to make sure that the third
wine is returned to earth ground. Use a continuity checker or ohmmeter to ensure that
the third wire is actually returned to earth.
Continuity should be checked for between the
power supply case and an available water pipe
for example. The line filter, which is of a
type approved by domestic (U.L. CSA) and
international (VDE) agencies must be returned
to earth to function properly and to avoid
potential shock hazards.

The APPLE II power supply is of the "flyback" switching type. In
this system, the AC line is rectified directly, "chopped up" by a high
frequency oscillator and coupled through a small transformer to the
diodes, filters, etc., and results in four low voltage DC supplies to
run APPLE II. The transformer isolates the DC supplies from the line
and is provided with several shields to prevent "hash" from being
coupled into the logic or peripherals. In the "flyback" system, the
energy transferred through from the AC line side to DC supply side is
stored in the transformer's inductance on one-half of the operating
cycle, then transferred to the output filter capacitors on the second
half of the operating cycle. Similar systems are used in TV sets to
provide horizontal deflection and the high voltages to run the CRT.
Regulation of the DC voltages is accomplished by controlling the
frequency at which the converter operates; the greater the output power
needed, the lower the frequency of the converter. If the converter is
overloaded, the operating frequency will drop into the audible range
with squeels and squawks warning the user that something is wrong.
All DC outputs are regulated at the same time and one of the four
outputs (the +5 volt supply) is compared to a reference voltage with
the difference error fed to a feedback loop to assist the oscillator
in running at the needed frequency. Since all DC outputs are regulated
together, their voltages will reflect to some extent unequal loadings.
110

For example; if the +5 supply is loaded very heavily, then all
other supply voltages will increase in voltage slightly; conversely,
very light loading on the +5 supply and heavy loading on the +12
supply will cause both it and the others to sag lightly. If precision
reference voltages are needed for peripheral applications, they should
be provided for in the peripheral design.
In general, the APPLE II design is conservative with respect to
component ratings and operating termperatures. An over-voltage crowbar
shutdown system and an auxilliary control feedback loop are provided
to ensure that even very unlikely failure modes will not cause damage to
theAPPLE II computer system. The over-voltage protection references to
the DC output voltages only. The AC line voltage input must be within
the specified limits, i.e., 1Ø7V to 132V.
Under no circumstances, should more
than 14Ø VAC be applied to the input
of the power supply. Permanent damage
will result.
Since the output voltages are controlled by changing the operating
frequency of the converter, and since that frequency has an upper limit
determined by the switching speed of power transistors, there then must
be a minimum load on the supply; the Apple II board with minimum memory
(4K) is well above that minimum load. However, with the board disconnected,
there is no load on the supply, and the internal over-voltage
protection circuitry causes the supply to turn off. A 9 watt load
distributed roughly 5O-5O between the +5 and +12 supply is the nominal
minimum load.
Nominal load current ratios are: The +12V supply load is ½ that of the +5V.
The - 5V supply load is 1/1Ø that of the +5V.
The -12V supply load is 1/lØ, that of the +5V.
The supply voltages are +5.Ø + Ø.15 volts, +11.8 + Ø.5 volts, -12.Ø + 1V,
-5.2 + O.5 volts. The tolerances are greatly reduced when the loads are
close to nominal.
The Apple II power supply will power the Apple II board and all present
and forthcoming plug-in cards, we recommend the use of low power TTL, CMOS,
etc. so that the total power drawn is within the thermal limits of the entire
system. In particular, the user should keep the total power drawn by any
one card to less than 1.5 watts, and the total current drawn by all the cards
together within the following limits:
+ 12V
+ 5V
- 5V
- 12V

-

use
use
use
use

no
no
no
no

more
more
more
more

than
than
than
than

25Ø
5ØØ
2ØØ
2ØØ

mA
mA
mA
mA

The power supply is allowed to run indefinetly under short circuit
or open circuit conditions.

111

CAUTION: There are dangerous high
voltages inside the power supply
case. Much of the internal circuitry
is NOT isolated from the power line,
and special equipment is needed for
service. NO REPAIR BY THE USER IS
ALLOWED.

NOTES ON INTERFACING WITH THE HOME TV

Accessories are available to aid the user in connecting the Apple II
system to a home color TV with a minimum of trouble. These units are called
"RF Modulators" and they generate a radio frequency signal corresponding to
the carrier of one or two of the lower VHF television bands; 61.25 MHz
(channel 3) or 67.25 MHz (channel 4). This RF signal is then modulated with
the composite video signal generated by the Apple II.
Users report success with the following RF modulators:
the "PixieVerter" (a kit)
ATV Research
13th and Broadway
Dakota City, Nebraska 68731
the "TV-1"
(a kit)
UHF Associates
6O37 Haviland Ave.
Whittier, CA 9O6O1
the "Sup-r-Mod" by
(assembled & tested)
M&R Enterprises
P.O. Box 1O11
Sunnyvale,
CA94O88
the RF Modulator
Electronics Systems
P.O. Box 212
Burlingame, CA 94O1O

(a P.C. board)

Most of the above are available through local computer stores.
The Apple II owner who wishes to use one of these RF Modulators should
read the following notes carefully.
All these modulators have a free running transistor oscillator. The
M&R Enterprises unit is pre-tuned to Channel 4. The PixieVerter and the
TV-1 have tuning by means of a jumper on the P.C. board and a small trimmer
capacitor. All these units have a residual FM which may cause trouble if
the TV set in use has a IF pass band with excessive ripple. The unit from
M&R has the least residual FM.
All the units except the M&R unit are kits to be built and tuned by
the customer. All the kits are incomplete to some extent. The unit from
Electronics Systems is just a printed circuit board with assembly instructions.
The kits from UHF Associates and ATV do not have an RF cable or a shielded
box or a balun transformer, or an antenna switch. The M&R unit is complete.
Some cautions are in order. The Apple II, by virtue of its color graphics
capability, operates the TV set in a linear mode rather than the 100% contrast
mode satisfactory for displaying text. For this reason, radio frequency interference (RFI) generated by a computer (or peripherals) will beat with the

112

carrier of the RF modulator to produce faint spurious background patterns
(called "worms") This RFI "trash" must be of quite a low level if worms
are to be prevented. In fact, these spurious beats must be 4Ø to 5Ødb
below the signal level to reduce worms to an acceptable level. When it is
remembered that only 2 to 6 mV (across 3ØØ , is presented to the VHF input
of the TV set, then stray RFI getting into the TV must be less than 5ØØ V
to obtain a clean picture. Therefore we recommend that a good, co-ax
cable be used to carry the signal from any modulator to the TV set, such
as RG/59u (with copper shield), Belden #8241 or an equivalent miniature
type such as Belden #8218. We also recommend that the RF modulator been
closed in a tight metal box (an unpainted die cast aluminum box such as
Pomona #2428). Even with these precautions, some trouble may be encountered
with worms, and can be greatly helped by threading the coax cable connecting
the modulator to the TV set repeatedly through a Ferrite toroid core
Apple Computer supplies these cores in a kit:along with a 4 circuit
connector/cable assembly to match the auxilliary video connector found on
the Apple II board. This kit has order number A2MØ1ØX. The M&R "Sup-r-Mod
is supplied with a coax cable and toroids.
Any computer containing fast switching logic and high frequency clocks
will radiate some 'radio frequency energy. Apple II is equipped with a
good line filter and many other precautions have been taken to minimize
radiated energy. The user is urged not to connect "antennas" to this
computer; wires strung about carrying clocks and/data will act as antennas,
and subsequent radiated energy may prove to be a nuisance.
Another caution concerns possible long term effects on the TV picture
tube. Most home TV sets have "Brightness" and "Contrast" controls with a
very wide range of adjustment. When an un-changing picture is displayed
with high brightness for a long period ,a faint discoloration of the
TV CRT may occur as an inverse pattern observable with the TV set
turned off. This condition may be avoided by keeping the "Brightness
"turned down slightly and "Contrast" moderate.

113

A SIMPLE SERIAL OUTPUT

The Apple II is equipped with a l6 pin DIP socket most frequently
used to connect potentiometers, switches, etc. to the computer for
paddle control and other game applications. This socket, located at
J-14, has outputs available as well. With an appropriate machine
language program, these output lines may be used to serialize data in
a format suitable for a teletype. A suitable interface circuit must
be built since the outputs are merely LSTTL and won't run a teletype
without help. Several interface circuits are discussed below and the
user may pick the one best suited to his needs.
The ASR - 33 Teletype
The ASR - 33 Teletype of recent vintage has a transistor circuit
to drive its solenoids. This circuit is quite easy to interface to,
since it is provided with its own power supply. (Figure la) It can
be set up for a 2OmA current loop and interfaced as follows (whether
or not the teletype is strapped for full duplex or half duplex operation):
a) The yellow wire and purple wire should both go to
terminal 9 of Terminal Strip X. If the purple wire
is going to terminal 8, then remove it and relocate
it at terminal 9. This is necessary to change from
the 6OmA current loop to the 2OmA current loop.
b) Above Terminal Strip X is a connector socket identified as "2". Pin 8 is the input line + or high; Pin
7 is the input line - or low. This connector mates
with a Molex receptacle model l375 #Ø3-Ø9-2l5l or
#O3-O9-2l53. Recommended terminals are Molex #Ø2-Ø92136. An alternate connection method is via spade lugs
to Terminal Strip X, terminal 7 (the + input line) and
6 (the - input line).
c) The following circuit can be built on a 16 pin DIP
component carrier and then plugged into the Apple's
l6 pin socket found at J-l4: (The junction of the
3.3k resistor and the transistor base lead is floating). Pins 16 and 9 are used as tie points as they
are unconnected on the Apple board. (Figure la).

114

The "RS - 232 Interface"
For this interface to be legitimate, it is necessary to twice invert
the signal appearing at J-14 pin 15 and have it swing more than 5 volts
both above and below ground. The following circuit does that but requires
that both +12 and -12 supplies be used. (Figure 2) Snipping off pins
on the DIP-component carrier will allow the spare terminals to be used for
tie points. The output ground connects to pin 7 of the DB-25 connector.
The signal output connects to pin 3 of the DB-25 connector. The "protective"
ground wire normally found on pin 1 of the DB-25 connector may be connected
to the Apple's base plate if desired. Placing a #4 lug under one of the
four power supply mounting screws is perhaps the simplest method. The +12
volt supply is easily found on the auxiliary Video connector (see Figure S-11
or Figure 7 of the manual). The -12 volt supply may be found at pin 33 of
the peripheral connectors (see Figure 4) or at the power supply connector
(see Figure 5 of the manual).
A Serial Out Machine Center Language Program
Once the appropriate circuit has been selected and constructed a machine
language program is needed to drive the circuit. Figure 3 lists such a teletype output machine language routine. It can be used in conjunction with an
Integer BASIC program that doesn't require page $3ØØ hex of memory. This
program resides in memory from $37Ø to $3E9. Columns three and four of the
listing show the op-code used. To enter this program into the Apple II the
following procedure is followed:
Entering Machine Language Program
l.
2.
3.

Power up Apple II
Depress and release the "RESET" key. An asterick
and flashing cursor should appear on the left hand
side of the screen below the random text matrix.
Now type in the data from columns one, two and three
for each line from $37Ø to Ø3E9. For example, type in
"37Ø: A9 82" and then depress and release the "RETURN"
key. Then repeat this procedure for the data at $372
and on until you complete entering the program.

Executing this Program
l.

From BASIC a CALL 88Ø ($37Ø) will start the execution of
this program. It will use the teletype or suitable 8Ø
column printer as the primary output device.

115

2.

PR#Ø will inactivate the printer transfering control
back to the Video monitor as the primary output device.

3.

In Monitor mode $37ØØ activates the printer and hitting
the "RESET" key exits the program.

Saving the Machine Language Program
After the machine language program has been entered and checked for
accuracy it should, for convenience, be saved on tape - that is unless
you prefer to enter it by keyboard every time you want to use it.
The way it is saved is as follows:
1. Insert a blank program cassette into the tape
recorder and rewind it.
2.

Hit the "RESET" key. The system should move
into Monitor mode. An asterick "*" and flashing cursor should appear on the left-hand side
of the screen.

3.

Type in "37Ø.Ø3E9W 37Ø.Ø3E9W".

4.

Start the tape recorder in record mode and depress
the "RETURN" key.

5.

When the program has been written to tape, the asterick
and flashing cursor will reappear.

The Program
After entering, checking and saving the program perform the following
procedure to get a feeling of how the program is used:
1. Bc (control B) into BASIC
2.

Turn the teletype (printer on)

3.

Type in the following
lØ CALL 88Ø
l5 PRINT "ABCD...XYZØl123456789"
2Ø PR#Ø
25 END

4.

Type in RUN and hit the "RETURN" key. The
text in line l5 should be printed on the
teletype and control is returned to the keyboard and Video monitor

116

Line lØ activates the teletype machine routine and all "PRINT" statements following it will be printed to the teletype until a PR#Ø statement is
encountered. Then the text in line l5 will appear on the teletype's output.
Line 2Ø deactivates the printer and the program ends on line 25.
Conclusion
With the circuits and machine language program described in this paper
the user may develop a relatively simple serial output interface to an ASR-3
or RS-232 compatible printers. This circuit can be activated through BASIC
or monitor modes. And is a valuable addition to any users program library.

117

+5V

EBC

3.3K

1

16
15

3.3K

150Ω

3.3K
3.3K
150 Ω

2N3906 (OR EQUIV.)

+
OUTPUT TO TELETYPE

PIN 15
J-14

-

8

RESISTORS ARE 1/4 WATT CARBON

9
-

(a)

(b)
FIGURE 2

ASR-33

+12 (JUMPERED TO +12 SUPPLY)
3.3K
2N3906
2N3904

470Ω
3.3K

PIN 15
J-14

3.3K
PIN 8
J-14
-12 (JUMPERED TO -12 SUPPLY)

FIGURE 2

118

RS-232

+

TELETYPE DRIVER ROUTINES

PAGE: 1

3:42 P.M., 11/18/1977
TITLE TELETYPE DRIVER ROUTINES'
1
*************************
2
3
*
*
4
*
*
TTYDRIVER:
5
*
TELETYPE OUTPUT *
6
*
*
ROUTINE FOR 72
7
*
COLUMN PRINT WITH *
8
*
*
BASIC LIST
9
*
*
10 *
COPYRIGHT 1977 BY: *
11 *
APPLE COMPUTER INC. *
12 *
*
11/18/77
13 *
*
14 *
*
R. WIGGINTON
15 *
*
S. WOZNIAK
16 *
*
17 *************************
;FOR APPLE-II
$21
18 WNDWDTH EQU
;CURSOR HORIZ.
CH
EQU
$24
19
;CHAR. OUT SWITCH
CSWL
EQU
$36
20
YSAVE
EQU
$778
21
;COLUMN COUNT LOC.
EQU
$7F8
22 COLCNT
MARK
EQU
$CO58
23
EQU
$CO59
24 SPACE
WAIT
EQU
$FCA8
25
ORG
$370
26
***WARNING: OPERAND OVERFLOW IN LINE 27
#TTOUT
0370: A9 82
27 TTINIT: LDA
;POINT TO TTY ROUTINES
STA
CSWL
0372: 85 36
28
;HIGH BYTE
LDA
#TTOUT/256
0374: A9 03
29
STA
CSWL+1
0376: 85 37
30
;SET WINDOW WIDTH
LDA
#72
0378: A9 48
31
;TO NUMBER COLUMNS ONT
STA
WNDWDTH
037A: 85 21
32
LDA
CH
037C: A5 24
33
;WHERE WE ARE NOW.
STA
COLCNT
037E: 8D F8
34
RTS
0381: 60
35
;SAVE TWICE
PHA
0382: 48
36 TTOUT:
;ON STACK.
PHA
0383: 48
37
;CHECK FOR A TAB.
TTOUT2:
LDA
COLCNT
0384: AD F8
38
CMP
CH
0387: C5 24
39
;RESTORE OUTPUT CHAR.
PLA
0389: 68
40
;IF C SET, NO TAB
BCS
TESTCTRL
038A: BO 03
41
PHA
038C: 48
42
;PRINT A SPACE.
LDA
#$A0
038D: A9 AO
43
;TRICK TO DETERMINE
TESTCTRL:
BIT
RTS1
038F: 2C CO
44
;IF CONTROL CHAR.
BEQ
PRNTIT
0392: FO 03
45
;IF NOT, ADD ONE TO CM
INC
COLCNT
0394: EE F8
46
;PRINT THE CHAR ON TTY
PRNTIT:
JSR
DOCHAR
0397: 20 C1
47
;RESTORE CHAR
PLA
039A: 68
48
;AND PUT BACK ON STAC
PHA
TTOUT2
0393: 48
49
;DO MORE SPACES FOR TA
BCC
#$OD
039C: 90 E6
50
;CHECK FOR CAR RET.
FOR
A
039E: 49 OD
51
;ELIM PARITY
ASL
FINISH
03A0: OA
52
;IF NOT CR, DONE.
BNE
03A1: DO OD
53

FIGURE 3a

119

TELETYPE DRIVER ROUTINES
11/13/1977
3:42 P.M.,
03A3:
8D F8 07 54
03A6:
A9 8A
55
03A8:
20 C1 03 56
03AB:
A9 58
57
03AD:
20 A8 FC 58
0330:
AD F8 07 59
0333:
F0 08
60
0335:
E5 21
61
0337:
E9 F7
62
0339:
90 04
63
0393:
69 1F
64
033D:
85 24
65
033F:
68
66
03C0:
60
67
03C1:
68
03C4:
8C 78 07 69
03C5:
08
70
03C7:
A0 08
71
03C3:
18
72
03C9:
48
73
03C3:
80 05
74
03CE:
AD 59 C0 75
0300:
90 03
76
0303:
AD 58 C0 77
0305:
A9 D7
78
0306:
48
79
03D8:
A9 20
80
0309:
4A
81
03D3:
90 FD
82
03DC:
68
83
030E:
6A
84
03E0:
88
85
03E1:
D0 E3
86
03E2:
AC 78 07 87
03E3:
28
88
03E5:
60
89
03E8:
90
03E9:
91

FINISH:

SETCH:
RETURN:
RTS1:
* HERE
DOCHAR:

TTOUT3:

MARKOUT:
TTOUT4:
DLY1:
DLY2:

STA
LDA
JSR
LDA
JSR
LDA
3E0
S3C
SSC
BCC
ADC
STA
PLA
RTS
STY
PHP
LDY
CLC
PHA
3CS
LDA
3CC
LDA
LDA
PHA
LDA
LSR
BCC
PLA
SBC
3NE
PLA
ROR
DEY
BNE
LDY
PLP
RTS

********SUCCESSFUL ASSEMBLY: NO ERRORS
FIGURE 3b

120

COLCNT
#38A
DOCHAR
#153
7AIT
COLCNT
SETCH
7VD7DTH
#SF7
RETURN
#11F
CH

TELETYPE PRINT
YSAVE
#SOS

MARKOUT
SPACE
TTOUT4
MARK
#%D7

PAGE: 2
;CLEAR COLUMN COUNT
;NOW DO LINE FEED

;200MSEC DELAY FOR LIB
;CHECK IF IN MARGIN
;FOR CR, RESET CH
;IF SO, CARRY SET.

;ADJUST CH

;RETURN TO CALLER
A CHARACTER ROUTINE:
;SAVE STATUS.
;11 BITS (1 START, 1 2
;BEGIN 7ITH SPACE (ST2
;SAVE A REG AND SET FOI
;SEND A SPACE
;SEND A MARK
;DELAY 9.091 MSEC FOR

#$20
A
DLY2
#101
DLY1
A
TTOUT3
YSAVE

;110 BAUD
;NEXT BIT (STOP BITS ?
LOOP 11 3ITS.
;RESTORE Y-REG.
;RESTORE STATUS
;RETURN

CROSS-REFERNCE:TELETYPE DRIVER ROUTINES
0024
0033
0039 0065
CH
0718
0034
0038 0046
COLCNT
0036
0028
0030
05YL
0305
0085
DLYI
0308
0082
DLY2
0301
0047
0056
DOCHAR
0330
0053
FINISH
CO58
0077
MARK
0300
0074
MARKOUT
0397
0045
PRNTIT
038F
0063
RETURN
0300
0044
RTS1
0330
0060
SETCH
CO59
0075
SPACE
033F
0041
TESTCTRL
0370
TTINIT
0332
0027
0029
TTOUT
0384
0050
TTOUT2
03C8
0089
TTOUT3
0303
0076
TTOUT4
FCAB
0058
WAIT
0021
0032
0061
WNDWDTH
0778
0069
0090
YSAVE
ILE:

0054

FIGURE 3c

121

0059

INTERFACING THE APPLE
This section defines the connections by which external devices are
attached to the APPLE II board. Included are pin diagrams, signal
descriptions, loading constraints and other useful information.
TABLE OF CONTENTS
l.

CONNECTOR LOCATION DIAGRAM

2.

CASSETTE DATA JACKS (2 EACH)

3.

GAME I/O CONNECTOR

4.

KEYBOARD CONNECTOR

5.

PERIPHERAL CONNECTORS (8 EACH)

6.

POWER CONNECTOR

7.

SPEAKER CONNECTOR

8.

VIDEO OUTPUT JACK

9.

AUXILIARY VIDEO OUTPUT CONNECTOR

122

Figure lA

APPLE II Board-Complete View

123

K1

0

J2

3

1

J4

4

Connector Location Detail

K

J

B

A
2

2

J5

5

TOP VIEW

4

J8

8

9

J9

5

APPLE II PC BOARD

3

J6

7

A7

PE RIPHE RALS

6

10

6

J11

11

7

J12

12

B14A

J14B

14

J14

K14

SPEAKER
CONNECTOR

GAME I/O
CONNECTOR

AUXILIARY
VIDEO OUTPUT
CONNECTOR

VIDEO OUTPUT

CASSETTE DATA OUT

CASSETTE DATA IN

K12 K13

13

Front of PC Board

124

Figure 1B

POWER
CONNECTOR

KEYBOARD
CONNECTOR

1

CONNECTOR LOCATIONS

Right Side
of PC Board

BACK EDGE OF PC BOARD

CASSETTE JACKS
A convenient means for interfacing an inexpensive audio cassette
tape recorder to the APPLE II is provided by these two standard
(3.5mm) miniature phone jacks located at the back of the APPLE II
board.
CASSETTE DATA IN JACK: Designed for connection to the "EARPHONE"
or "MONITOR" output found on most audio cassette tape recorders.
V =lVpp (nominal), Z =l2K Ohms. Located at K12 as illustrated in
IN
IN
Figure
CASSETTE DATA OUT JACK: Designed for connection to the "MIC" or
"MICROPHONE" input found on most audio cassette tape recorders.
V
=25 mV into l7 Ohms, Z
=lØØ Ohms. Located at Kl3 as illustrated
OUT
OUT
in in Figure l.

GAME I/O CONNECTOR
The Game I/O Connector provides a means for connecting paddle controls,
lights and switches to the APPLE II for use in controlling video games,
etc. It is a 16 pin IC socket located at Jl4 and is illustrated in
Figure l and 2.

Figure 2

GAME I/O CONNECTOR
TOP VIEW

( Front Edge of PC Board )
+5V
SWO
SW1
SW2
CO4O STB
PDLO
PDL2
GND

1
2
3
4
5
6
7
8

16
15
14
13
12
11
10
9

LOCATION J14

125

N.C.
ANO
AN1
AN2
AN3
PDL3
PDL1
N.C.

SIGNAL DESCRIPTIONS FOR GAME I/O
AN0-AN3:

8 addresses (CØ58-CØ5F) are assigned to selectively
"SET" or "CLEAR" these four "ANNUNCIATOR" outputs.
Envisioned to control indicator lights, each is a
74LSxx series TTL output and must be buffered if used
to drive lamps.

CØ4Ø STB:

A utility strobe output. Will go low during Ø2 of a
read or write cycle to addresses CØ4Ø-CØ4F. This is
a 74LSxx series TTL output.

GND:

System circuit ground. 0 Volt line from power supply.

NC:

No connection.

PDLØ-PDL3:

Paddle control inputs.
resistance and +5V for
resistors are provided
prevent excess current
ohms.

SWØ-SW2:

Switch inputs. Testable by reading from addresses
CØ61-CØ63 (or CØ69-CØ6B). These are uncommitted
74LSxx series inputs.

+5V:

Positive 5-Volt supply. To avoid burning out the connector
pin, current drain MUST be less than l00mA.

Requires a Ø-l5ØK ohm variable
each paddle. Internal lØØ ohm
in series with external pot to
if pot goes completely to zero

KEYBOARD CONNECTOR
This connector provides the means for connecting as ASCII keyboard
to the APPLE II board. It is a l6 pin IC socket located at A7 and is
illustrated in Figures 1 and 3.

Figure 3

KEYBOARD CONNECTOR
TOP VIEW

( Front Edge of PC Board )
+5V
STROBE
RESET
N.C.
B6
B5
B7
GND

1
2
3
4
5
6
7
8

16
15
14
13
12
11
10
9

LOCATION A7

126

N.C.
-12V
N.C.
B2
B1
B4
B3
N.C.

SIGNAL DESCRIPTION FOR KEYBOARD INTERFACE
Bl-B7:

7 bit ASCII data from keyboard, positive logic (high level=
"l"), TTL logic levels expected.

GND:

System circuit ground.

NC:

No connection.

RESET:

System reset input. Requires switch closure to ground.

Ø Volt line from power supply.

STROBE: Strobe output from keyboard. The APPLE II recognizes the
positive going edge of the incoming strobe.
+5V:

Positive 5-Volt supply. To avoid burning out the connector
pin, current drain MUST be less than 1ØØmA.

-l2V:

Negative l2-Volt supply. Keyboard should draw less than
5OmA.

PERIPHERAL CONNECTORS
The eight Peripheral Connectors mounted near the back edge of the
APPLE II board provide a convenient means of connecting expansion
hardware and peripheral devices to the APPLE II I/O Bus. These are
Winchester #2HW25CØ-lll (or equivalent) pin card edge connectors
with pins on .1Ø" centers. Location and pin outs are illustrated in
Figures 1 and 4.
SIGNAL DESCRIPTION FOR PERIPHERAL I/O
AO-A15:

16 bit system address bus. Addresses are set up by the
65Ø2 within 3ØØnS after the beginning of Ø1. These lines
will drive up to a total of l6 standard TTL loads.

"DEVICE SELECT: Sixteen addresses are set aside for each peripheral
connector. A read or write to such an address will
send pin 4l on the selected connector low during Ø2
(5ØØnS). Each will drive 4 standard TTL loads.
DØ-D7:

8 bit system data bus. During a write cycle data is
set up by the 65Ø2 less than 3ØØnS after the beginning
of Ø2. During a read cycle the 65Ø2 expects data to
be ready no less than 1ØØnS before the end of Ø2.
These lines will drive up to a total of 8 total low
power schottky TTL loads.

127

DMA:

Direct Memory Access control output. This line has a
3K Ohm pullup to +5V and should be driven with an
open collector output.

DMA IN:

Direct Memory Access daisy chain input from higher
priority peripheral devices. Will present no more
than 4 standard TTL loads to the driving device.

DMA OUT:

Direct Memory Access daisy chain output to lower
priority peripheral devices. This line will drive
4 standard TTL loads.

GND:

System circuit ground. Ø Volt line from power supply.

INH:

Inhibit Line.When a device pulls this line low, all
ROM's on board are disabled (Hex addressed DØØØ through
FFFF). This line has a 3K Ohm pullup to +5V and
should be driven with an open collector output.

INT IN:

Interrupt daisy chain input from higher priority peripheral devices. Will present no more than 4 standard
TTL loads to the driving device.

INT OUT:

Interrupt daisy chain output to lower priority peripheral devices. This line will drive 4 standard TTL
loads.

I/O SELECT:

256 addresses are set aside for each peripheral connector
(see address map in "MEMORY" section). A read or write
of such an address will send pin 1 on the selected
connector low during Ø2 (5ØØnS). This line will drive
4 standard TTL loads.

I/O STROBE:

Pin 2Ø on all peripheral connectors will go low during
Ø, of a read or write to any address C8ØØ-OFFF. This
line will drive a total of 4 standard TTL loads.

IRQ:

Interrupt request line to the 65Ø2. This line has a
3K Ohm pullup to +5V and should be driven with an open
collector output.It is active low.

NC:

No connection.

NMI:

Non Maskable Interrupt request line to the 65Ø2. This
line has a 3K Ohm pullup to +5V and should be driven with
an open collector output.It is active low.

Q3

A 1MHz (nonsymmetrical) general purpose timing signal. Will
drive up to a total of 16 standard TTL loads.

RDY:

'Ready" line to the 65Ø2. This line should change only
during Ø1, and when low will halt the microprocessor at
the next READ cycle. This line has a 3K Ohm pullup to
+5V and should be driven with an open collector output.

RES:

Reset line from "RESET" key on keyboard. Active low. Will
drive 2 MOS loads per Peripheral Connector.
128

R/W:

READ/WRITE line from 65Ø2. When high indicates that a read
cycle is in progress, and when low that a write cycle is
in progress. This line will drive up to a total of 16
standard TTL loads.

USER l:

The function of this line will be described in a later
document.

ØO:

Microprocessor phase V clock. Will drive up to a total of
16 standard TTL loads.

Ø1:

Phase l clock, complement of Ø0. Will drive up to a total
of l6 standard TTL loads.

7M:

Seven MHz high frequency clock. Will drive up to a total
of 16 standard TTL loads.

+12V:

Positive l2-Volt supply.

+5V:

Positive 5-Volt supply

-5V:

Negative 5-Volt supply.

-12V:

Negative l2-Volt supply.

POWER CONNECTOR
The four voltages required by the APPLE II are supplied via this
AMP #9-35Ø28-l,6 pin connector. See location and pin out in Figures
l and 5.
PIN DESCRIPTION
GND:

(2 pins) system circuit ground. Ø Volt line from power
supply.

+l2V:

Positive 12-Volt line from power supply.

+5V:

Positive 5-Volt line from power supply.

-5V:

Negative 5-Volt line from power supply.

-l2V:

Negative 5-Volt line from power supply.

129

PERIPHERAL CONNECTORS

Figure 4

(EIGHT OF EACH)

PINOUT

TOP VIEW

(Back Edge of PC Board)

GND
DMA IN
INT IN
NMI
IRQ
RES
INH
-12V
-5V
N.C.
7M
Q3
1
USER 1
0
DEVICE SELECT
D7
D6
D5
D4
D3
D2
D1
D0
+12V

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1

+5V
DMA OUT
INT OUT
DMA
RDY
I/O STROBE
N.C.
R/W
A15
A14
A13
A12
A11
A10
A9
A8
A7
A6
A5
A4
A3
A2
A1
A0
I/O SELECT

( Toward Front Edge of PC Board)
LOCATIONS JS TO J12

Figure 5
PINOUT

POWER CONNECTOR
TOP VIEW

( Toward Right side of PC Board)

(BLUE/WHITE WIRE) -12V
(ORANGE WIRE +5V
(BLACK WIRE GND

5

6

3

4

1

2

LOCATION K1

130

- 5V (BLUE WIRE)
+12V (ORANGE/WHITE WIRE)
GND (BLACK WIRE)

SPEAKER CONNECTOR
This is a MOLEX KK 1ØØ series connector with two .25" square pins on
.lØ" centers. See location and pin out in Figures 1 and 6.
SIGNAL DESCRIPTION FOR SPEAKER
+5V:

System +5 Volts

SPKR:

Output line to speaker. Will deliver about .5 watt into
8 Ohms.

Figure 6
SPEAKER CONNECTIONS

SPKR

+5V

Right Edge of
PC Board

PINOUT

Right Edge of PC Board
LOCATION B14A

VIDEO OUTPUT JACK
This standard RCA phono jack located at the back edge of the APPLE II
P.C. board will supply NTSC compatible, EIA standard, positive composite
video to an external video monitor.
A video level control near the connector allows the output level to be
adjusted from Ø to l Volt (peak) into an external 75 OHM load.
Additional tint (hue) range is provided by an adjustable trimmer capacitor.
See locations illustrated in Figure l.

131

AUXILIARY VIDEO OUTPUT CONNECTOR
This is a MOLEX KK 100 series connector with four .25" square pins
on .lØ" centers. It provides composite video and two power supply
voltages. Video out on this connector is not adjustable by the on
board 200 Ohm trim pot. See Figures l and 7.
SIGNAL DESCRIPTION
System circuit ground.

VIDEO

NTSC compatible positive composite VIDEO. DC coupled
emitter follower output (not short circuit protected).
SYNC TIP is Ø Volts, black level is about .75 Volts, and
white level is about 2.Ø Volts into 47Ø Ohms. Output level
is non-adjustable.

+l2V:

+l2 Volt line from power supply.

+5V:

-5 Volt line from power supply.

Figure 7

Ø Volt line from power supply.

AUXILIARY VIDEO OUTPUT CONNECTOR
PINOUT

+12V
-5V
VIDEO
GND

Right Edge of PC Board
LOCATION J14B

132

Back Edge of PC Board

GND:

INSTALLING YOUR OWN RAM
THE POSSIBILITIES
The APPLE II computer is designed to use dynamic RAM chips organized
as 4O96 x l bit, or 16384 x 1 bit called "4K° and "16K" RAMs
respectively. These must be used in sets of 8 to match the system
data bus (which is 8 bits wide) and are organized into rows of 8.
Thus, each row may contain either 4Ø96 (4K) or 16384 (l6K) locations
of Random Access Memory depending upon whether 4K or 16K chips are
used. If all three rows on the APPLE II board are filled with 4K
RAM chips, then l2288 (l2K) memory locations will be available for
storing programs or data, and if all three rows contain l6K RAM
chips then 49152 (commonly called 48K) locations of RAM memory will
exist on board!
RESTRICTIONS
It is quite possible to have the three rows of RAM sockets filled with
any combination of 4K RAMs, l6K RAMs or empty as long as certain rules
are followed:
1. All sockets in a row must have the same type (4K or 16K)
RAMs.
2.

There MUST be RAM assigned to the zero block of addresses.

ASSIGNING RAM
The APPLE II has 48K addresses available for assignment of RAM memory.
Since RAM can be installed in increments as small as 4K, a means of
selecting which address range each row of memory chips will respond
to has been provided by the inclusion of three MEMORY SELECT sockets
on board.

Figure 8

MEMORY SELECT SOCKETS
TOP VIEW

PINOUT
(0000-OFFF)
(1000-1FFF)
(2000-2FFF)
(3000-3FFF)
(4000-4FFF)
(5000-5FFF)
(6000-EFFF)

4K
4K
4K
4K
4K
4K
4K

"0" BLOCK1
"1" BLOCK 2
"2" BLOCK 3
"3" BLOCK 4
"4" BLOCK 5
"5" BLOCK 6
"6" BLOCK 7

14
13
12
11
10
9
8

RAM ROW C
RAM ROW D
RAM ROW E
N.C.
16K "0" BLOCK (0000-3FFF)
16K "4" BLOCK (4000-7FFF)
16K "8" BLOCK (8000-BFFF)

LOCATIONS D1, E1, F1

133

MEMORY

TABLE OF CONTENTS
1.

INTRODUCTION

2.

INSTALLING YOUR OWN RAM

3.

MEMORY SELECT SOCKETS

4.

MEMORY MAP BY 4K BLOCKS5.

5.

DETAILED MAP OF ASSIGNED ADDRESSES

INTRODUCTION
APPLE II is supplied completely tested with the specified amount of
RAM memory and correct memory select jumpers. There are five different
sets of standard memory jumper blocks:
1.
2.
3.
4.
5.

4K 4K 4K BASIC
4K 4K 4K HIRES
l6K 4K 4K
l6K l6K 4K
l6K l6K 16K

A set of three each of one of the above is supplied with the board.
Type 1 is supplied with 4K or 8K systems. Both type 1 and 2 are
supplied with 12K systems. Type 1 is a contiguous memory range for
maximum BASIC program size. Type 2 is non-contiguous and allows 8K
dedicated to HIRES screen memory with approximately 2K of user BASIC
space. Type 3 is supplied with 16K, 2CØK and 24K systems. Type 4
with 3ØK and 36K systems and type 5 with 48K systems.
Additional memory may easily be added just by plugging into sockets
along with correct memory jumper blocks.
The 65Ø2 microprocessor generates a l6 bit address, which allows
65536 (commonly called 65K) different memory locations to be specified.
For convenience we represent each l6 bit (binary) address as a 4-digit
hexadecimal number. Hexadecimal notation (hex) is explained in the
Monitor section of this nlanual.
In the APPLE II, certain address ranges have been assigned to RAM
memory, ROM memory, the I/O bus, and hardware functions. The memory
and address maps give the details.

134

MEMORY SELECT SOCKETS
The location and pin out for memory select sockets are illustrated
in Figures l and 8.
HOW TO USE
There are three MEMORY SELECT sockets, Thcated at Dl, El and Fl
respectively. RAM memory is assigned to various address ranges by
inserting jumper wires as described below. All three MEMORY SELECT
sockets MUST be jumpered identically! The easiest way to do this
is to use Apple supplied memory blocks.
Let us learn by example:
If you have plugged 16K RAMs into row "C" (the sockets located at
C3-ClØ on the board), and you want them to occupy the first 16K of
addresses starting at ØØØØ, jumper pin l4 to pin lØ on all three
MEMORY SELECT sockets (thereby assigning row "C" to the ØØØØ-3FFF
range of memory).
If in addition you have inserted 4K RAMs into rows "D" and "E", and
you want them each to occupy the first 4K addresses starting at 4ØØØ
and 5ØØØ respectively, jumper pin 13 to pin 5 (thereby assigning row
"D" to the 4ØØØ-4FFF range of memory), and jumper pin l2 to pin 6
(thereby assigning row "E" to the 5ØØØ-5FFF range of memory). Remember
to jumper all three MEMORY SELECT sockets the same.
Now you have a large contiguous range of addresses filled with RAM
memory. This is the 24K addresses from ØØØØ-5FFF.
By following the above examples you should be able to assign each
row of RAM to any address range allowed on the MEMORY SELECT sockets.
Remember that to do this properly you must know three things:
l.

Which rows have RAM installed?

2.

Which address ranges do you want them to
occupy?

3. Jumper all three MEMORY SELECT sockets the
same!
If you are not sure think carefully, essentially all the necessary
information is given above.

135

SYSTEM TIMING
SIGNAL DESCRIPTIONS
l4M:

Master oscillator output, 14.3l8 MHz +/- 35 ppm.
timing signals are derived from this one.

7M:

Intermediate timing signal, 7.l59 MHz.

All other

COLOR REF: Color reference frequency used by video circuitry, 3.530 MHz.
Ø0:

Phase Ø clock to microprocessor, l.Ø23 MHz nominal.

Ø1:

Microprocessor phase l clock, complement of Ø0, l.023 Mhz
nominal.

Ø2

Same as Ø0. Included here because the 6502 hardware and
programming manuals use the designation Ø2 instead of Ø0 .

Q3:

A general purpose timing signal which occurs at the same
rate as the microprocessor clocks but is nonsymmetrical.

MICROPROCESSOR OPERATIONS
ADDRESS:

The address from the microprocessor changes during Ø1,
and is stable about 300nS after the start of Ø1.

DATA WRITE:

During a write cycle, data from the microprocessor
appears on the data bus during Ø2, and is stable about
3ØØnS after the start of Ø2.

DATA READ:

During a read cycle, the microprocessor will expect
data to appear on the data bus no less than l00nS prior
to the end of Ø2.
SYSTEM TIMING DIAGRAM

TIMING CIRCUITRY
BLOCK DIAGRAM
MASTER
OSCILLATOR

TIMING
CIRCUITRY

TIMING RELATIONSHIPS
14M

7M
COLOR REF

0
1
2

3

140

145
AD13
AD14
AD15

14
15
16
17

AD11
AD12

13

1

38

F12-15

TO H12
PERI I/O MUX
FIG. S-9

I/O SEL

20

SEE FIG. S-2

SYSTEM BUS

(1/4)

74LS08

6

4

Z0
E1

5 H1

4

15

14

16

5

F12

7

E2

VCC 27
Z1

+5V

F8

2

A2

74LS138

25

10

20 21

A3

24

3

11

20 21

6

E3

23

12

20 21

8

GND

22

13

20 21

FIGURE S-5 ROM MEMORY

1

A1

26

9

20 21 20 21

F0

F3

ROM

D0

F5

ROM

D8

F6

ROM
E0

F8

ROM

E8

F11

F9

ROM

ROM MEMORY ARRAY

ROM

AD3
AD4
AD5
AD6
AD7
AD8

5
6
7
8
9
10

12 AD10
32
INH

AD9

AD2

4

11

AD1

3

CHIP SELECTS
FROM F12

RA01
3.3K

+5V

AD0

2

A4

A3

A2

A1

A0

24
VCC

D4

D2

D1

D0

11

10

9

18

19

22

23

1

D6

D5

20

21

12

D7
CS2
CS1 CS3 GND

A10

A9

A8

A7

17

16

15

9316B
13
3
A5 ROM D3
2K x 8
2
A6
14

4

5

6

7

8

+5V

ROM PINOUT DETAIL

DA7

DA6

DA5

DA4

DA3

DA2

DA1

DA0

42

43

44

45

46

47

48

49

10260 BRANDLEY DRIVE
CUPERTINO, CALIFORNIA 95014 U.S.A.
TELEPHONE (408) 996-1010

10260 BRANDLEY DRIVE
CUPERTINO, CALIFORNIA 95014 U.S.A.
TELEPHONE (408) 996-1010



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.7
Linearized                      : Yes
XMP Toolkit                     : Adobe XMP Core 4.0-c316 44.253921, Sun Oct 01 2006 17:14:39
Format                          : application/pdf
Title                           : Apple II Redbook
Description                     : Books
Creator                         : GeeDee 2008
Modify Date                     : 2008:05:19 02:37:44-03:00
Create Date                     : 2008:03:29 21:08:01-03:00
Metadata Date                   : 2008:05:19 02:37:44-03:00
Creator Tool                    : Adobe Illustrator CS2
Thumbnail Width                 : 216
Thumbnail Height                : 256
Thumbnail Format                : JPEG
Thumbnail Image                 : (Binary data 13290 bytes, use -b option to extract)
Document ID                     : uuid:73c19f2a-b5b1-42a2-8af0-5e2b026302df
Instance ID                     : uuid:e7d5aecb-b895-4150-bb1d-37ea40c19fb0
Has XFA                         : No
Page Count                      : 158
Page Layout                     : SinglePage
Subject                         : Books
Author                          : GeeDee 2008
EXIF Metadata provided by EXIF.tools

Navigation menu