Text content (OCR)
Releasing the power to everyone.
February 1985,
Vol. 1, No. 1
My Two Bits
Tom Weshaar
“Congratulations on avoiding the ‘Apple
Computer Co. = Apple I computer’ trap’
writes Brooke Boering (author of the freeware
programs Fire Organ and One-Key DOS) in
response to last month’s My Two Bits. Open-
Appleis primarily about the Apple Il compu-
ter. But its important to keep a watchful eye
on our friends at Apple, Inc., as well. As noted
here last month, there is far more respect for
the Applell outside the company than inside
it There is tremendous technological pres-
sure inside Apple to “improve” the Apple II
beyond recognition, even though those of us
‘on the buying side are only beginning to
understand what we can do with the unimproved model.
This pressure doesn’t come entirely from within Apple. The February Popular
Computing includes a review of the Apple llc that includes statements like these:
“1found the licto be justa second facelift for the Apple Il Plus. Cosmetic surgery
is fine in some cases, but nothing short of major internal surgery will modemize
the Apple II line”
“From a design perspective, compatibility is the lIc’s Achilles’ heel. To maintain
that compatibility, Apple's engineers couldn't make the lic very different from its
predecessors.”
“The licisn’ta bad computer. It's just a computer based on aged technology”
‘The technonerd that wrote that review, like his many confederates inside
Apple. has precious little understanding of why we users have purchased more
than two million of these machines. We want them precisely because the Apple II
has evolved.
Ask hackers who were weaned on Radio Shack Model Ones, Commodore Pets, or
Texas Instruments 99/4s what they eat for dinner nowadays. All the time and
energy they spent learning how to use those lizards has lost its worth. Meanwhile,
those of us lucky (or wise, as the case may be) enough to start with an Apple have
something of appreciating value inside our heads.
Itis Open-Apple’seditorial policy to protect that investment. We'll happily make
mock of Popular Computing or any other publication thatattemptsto liquidate our
investment. And we'll be watching developments at Apple, Inc. for internal attempts
to bankruptus, too.
Its important to realize that those of us who already own Apple Ils represent a
significant proportion of Apple Computer, Inc's. future revenue. Its a fundamental
rule ofbusiness that people who have boughta companys products in the pastare
more likely than anybody else to buy again,
‘According to press reports, Apple sold about 750,000 Iles and lcs in 1984 (up
from 580,000 in 1983). About a third of those went to homes, offices, or schools
thatalready had an Apple in the family. That proportion will increase, not decrease,
from here on out.
Looking at the data another way, 37 per cent of the people who already own a
computer expect to buy another within a year, while only 15 per cent ofnon-owners
expect to buy, according to a study done last summer by Dataquest and Software
Access International.
Apple's president, John Sculley, is a marketing man. Marketing men live by the
‘commandment that a company shalt produce goods that customers want to buy
rather than goods that engineers want to produce.
Unfortunately, itisn’tat all certain that Scully and Apple are taking the desires of
current Apple II owners seriously—even though we represent a ton of future
business potential. One gets the impression that their market research is totally
based on people who have either never seen a computer before or who have used
only competitive brands.
The latest example of this disregard for current owners is word from reliable
sources that future models in the “Apple II family” won't support DOS 3.3. (If it
won't support DOS 3.3 it’s not an Apple II is it?)
The reason the new machines can’t use DOS 3.3, Apple's engineers say, is
that Apple is converting all its computers to the 5 1/2-inch plastic-encased disks
used on the Macintosh. These disks hold 409,600 bytes of data. DOS 3.3, we are
constantly misinformed (most recently in the January 1985 inCider, page 82), can
handle disks no larger than 143,360 bytes.
As the owners of 40-track drives know, this upper limit is all myth. DOS 3.5 will
work, without modification, on disk drives having as many as 50 tracks and 32
sectors (the equivalent of exactly the Macintosh’s 409,600 bytes). Apple's engi-
neers, however, don'tseem to know this. (Quick, name the only company that sells
ahard disk for the Apple Ii that doesn’t support DOS 3.3.)
Ican’tbelieve a marketing man like Sculley would leta decision like this be made
ifhe knew both the true potential of DOS 3.5 and how his best customers feel about
it Since his marketing and engineering minions don't seem to be telling him, |
guess you and | will have to. Fire up your word processor and let Sculley know what
you think. In case you don’t have it handy, his address is:
John Sculley, President
Poole Computer, Inc.
20525 Mariani Ave
Cupertino, Calif. 95014
Lest | be misunderstood, let me make it clear | have nothing against 3 1/2 inch
disks. think they're wonderful. I have nothing against ProDOS. | think it's wonder-
ful too, But the common investment of time, knowledge, and productive software
Apple users have in DOS 3.3 is simply too valuable to walk away from. If Apple's
engineers can't figure out how to get DOS 3.5 to work with 400K disks, there are a
dozen or more companies with names like Corvus, Rana, MicroSci, and Diversified
Software Research who could show them how. Its time for Apple to spend a little
more ofits research and development money on its bread and butter product.
Enough of my blustering. The theme of this month’s Open-Apple isn’t monitor-
ing Apple—our main task, actually, is to investigate the Apple Monitor. First,
however, I want to thank all of you who have already signed on as Open-Apple
subscribers. The response rate you've given our subscription campaign has been
fantastic— and we didn’t even have a sweepstakes.
ASong Called the System Monitor
One of the greatest death scenes in all movie history, according to a film critic
friend of ours, occurs in 2001: A Space Odyssey. HAL, an intelligent computer on
board a spaceship bound for Jupiter, decides the biggest risk to his mission’s
success is human error and becomes very hostile toward the astronauts accom-
panying him.
Dave, a human spaceman, eventually works his way into HAL's memory bank and
starts removing ROMs and RAMs (which look like small glass slabs). As each slabis
removed, HAL loses intelligence. HAL pleads with Dave to stop. As Dave yanks out
HAL's last bit of intelligence, HAL is singing Daisy, which was the first thing he ever
leamed.
10 © OpenApple
Fortunately, Apples are meek and mild-mannered machines. But ifthe day ever
comes that you find it necessary to climb inside and start removing intelligence,
the last thing your Apple will sing is a song called the Systém Monitor. This is the
first thing Apples ever learned. Itincludes software Steve Wozniak wrote in 1976 to
impress his friends the Homebrew Computer Club.
Cornerstone treasures, The Monitor software is very elementary. But it's the
comerstone of the Apple's operating system. .
When people talk about the Monitor, they usually mean one of two things (or
three things, ifyou count display screens). In one sense, the Monitor consists of all
the machine language subroutines found between byte 63488 (in hex that's
$F800) and 65535 ($FFFF). These routines do things such as retrieve the mes-
sages you type on your keyboard, print text on your screen, and beep your speaker,
In addition, these routines include a program that allows you to interact with
your Apple. Using this program, you can determine or change the contents of any
memory byte, move data around in memory, verify that two ranges of bytes are the
same, and do hexadecimal arithmetic and other stuff. This program, although itis,
really just a subset of the entire Apple system monitor, is also usually called the
Monitor.
The Monitor program, like the rest of the system monitor, Is very elementary.
Most of the commands consist of a single character. Error messages consist of a
single beep. Nonetheless, it provides a way for you to “get inside” your Apple and
deal with it on a byte level —at any time. Very few other computers have a built-in
program that opens the system up to you as much as this one does.
In and out. The Monitor program starts at byte 65385 (SFF69). You execute the
program by entering call 65585, or more typically, call -151 (a negative 151 and a
positive 65385 appear to Basic as the same number when you're using the call
Vol. 1, No. 1
command). When you enter one of these commands, the Applesoft bracket prompt
will change to an asterisk, like this:
JoALL -152
The asterisk prompt is your signal that you are “in the Monitor’. Now that we're
here, let's figure out if there's anything we can do that's useful.
First ofall, try entering a familiar Basic command. How about:
SPRINT “I~
(beep)
No luck. That beep, however, is the Monitor's signal that you made a syntax error.
Notice that no error message is printed on the screen. How about a DOS com:
mand? Try this:
CATALOG
DISK VOLUME 254
A 02 HELLO
sand so on
DOS commands work just fine from within the Monitor. 'vejust shown aDOS3.3
catalog, but ProDOS works too. With DOS 3,3 youll see a string of numbers
following the command's display. ProDOS eats these for breakfast. ifthe numbers
intrique you, look at the If Then Maybe column in the June 1984 Softalk. On page
Reviewer's
Corner
‘The Sider. By First Class Peripherals. The Sider isa 10 megabyte hard disk drive for
the Apple I-Plus and Ile that sells, by mail order only, for $695. At this eye-opening
price I thought we'd better try one. So far I'm impressed.
About four weeks after | placed my order, UPS delivered a massive, mostly empty,
box. Inside were the drive itself, a peripheral card for slot 7, and some cables and
instructions. The thing takes about two hours to install and initialize.
After the Sider is installed, your system uses it for booting when you tum on your
computer or press open-apple-reset. If you haven't tumed the Sider on, your
computer will “lock-up”; butyou can press control-reset to enter Basic and PR¥6to
boot from your floppy rive if you want to go that route.
When the Sider starts up, a menu appears that gives you your choice of booting
CP/M, Pascal, ProDOS, or DOS 3.5. You can also boot a floppy disk in slot 6 (it
usually won't be able to use the hard drive, however), run system utilities, or park.
heads (quit) from this menu.
One small problem with the way the Sider supports all four operating systems is
that you have to set aside at least a few sectors on the disk for each of them. The
actual share of space each gets is up to you. The system utilities and the main
menu program run under DOS 3.3. Its the only operating system that actually
comes with the drive—you must buy the master disks for the others from the
appropriate source, as usual.
Under DOS 3.3, the Sider appears to be a bunch of floppy disks, each with a
different volume number, in slot 7, drive 1 If you initialize the Sider with the
maximum amount of DOS 3.3 disk space, you'll get 61 standard 140K volumes,
numbered 1 through 61 You access these with the standard DOS 3.3 Vparameter,
for example, CATALOG, V35. You can switch back and forth between these 61
“disks”, or volumes, simply by specifying different numbers. If you don’t specify a
number, you get whatever volume you used last.
Under DOS 3.3, the Sider also allows you to have large, 400K volumes. As
mentioned in My Two Bits, DOS 3.3 can handle disks of this size without modifica-
tion. You can have up to 22 of these larger volumes at one time.
As implemented on the Sider, ProDOS must always have two equalsized
volumes. They're called /hard1 and /hard2. Ifyou maximize the ProDOS space at
initialization, each volume will have 9,076 blocks of space —a little over 4.5 meg-
abytes each. The ProDOS system of prefixes, subdirectories, and pathnames
makes a good deal more sense when you have large amounts of space like this to
work with,
Besides their large capacity, hard disks are also famous for their speed. This is
because the disk is always spinning—there’s no coming-up-to-speed delay—and
because it spins much faster than a floppy can. The following chart compares how
long it takes to sequentially load ten high-resolution graphics from a floppy disk,
the Sider, and a RAM (memory-based) disk. It's interesting to note that the operat-
ing system you use makesa lot of difference. Ifyour primary interestis speed rather
than capacity, a speed enhanced DOS—such as ProntoDOS, DiversiDOS or
ProDOS—helps more than a hard disk or even a RAM disk.
Seconds required to bload ten hi-res graphics
Floppy Sider RAE dicle
standard 00S 3.3 88 a 24
high-speed 3.3 20 3 a
Prob0s 18 6 2
An unusual feature of the Sider is that one periperhal card can handlea two-drive.
system. Most hard disks for the Apple don't have that capability. Those of you with
uninterruptable power supplies (review upcoming ina future issue) will be happy to
learn that the Sider draws only 40 watts of power.
Ifthe Sider has a weakness, it's the documentation. Don’t expect the manual to
be as slick as the companys advertising. The manual does an adequate job of
explaining how to install and initialize the drive and how to troubleshoot any
problems. However, it’s quite thin on actual operation. The “park heads" selection
on the main menu, for example, isn’t mentioned in the manual. | assume it’s bad
news if the lights go out with the heads engaged, but who knows~the manual
doesn't say anything about how to turn the unit off.
The Sider comes witha one-year warranty. To receive service you must first follow
adiagnostic prodecure outlined in the manual. Ifthe unitis defective you then call
to get a repair authorization and return the drive in its original packing to First.
Class Peripherals. They fix it free while it's in warranty; they charge $150 after that.
‘Are these folks for real? Apple charges $1495 for its 5 megabyte Profile hard
drive— half the capacity at twice the price. This is a new company and buyers take
the risk they won't be around long. However, they appear to be doing things right.
Their strategy is to sell by mail at below retail prices, Their marketis Apple Il users
willing to forgo a dealer's handholding in exchange for those prices. (I suspect
there's hundreds of thousands of people like that.)
The drive itself is manufactured by a company called Xebec. Members of the
Apple users group in Miami bought a bunch of these drives a few months ago and
our friends down there say they've been happy with thern. I'm certainly happy with
mine.
The Sider, by First Class Peripherals (P.O. Box 6187, Lehigh Valley, Penn, 18001; 800-538-
1307). One-year warranty. $695
Downloaded from www.Apple2Online.com
February 1985.
141 of that issue, Roger Wagner throughly explores where these meaningless
numbers come from and why, Ifthese numbers don't intrigue you, justignore them.
Now open the door on your disk drive and try the catalog command again. This is
a good way to force a disk i/o error. Why do that? Try itand see:
*CATALOS
1/0 ERROR (beep)
1
This time you do get an error message. This is because DOS is sending the
message to you. But the important thing to notice is the prompt you get ater the
error. A DOS error from within the Monitor always lifts you back up into Applesoft.
Enter call-151 again, and try out what happens when you press control-reset. Once
again the Applesoft prompt will reappear.
So we've established that call -151 gets you into the Monitor and that control-
reset gets you back out. Basic commands don't work in the Monitor; DOS com-
mands do; however, they send you to Applesoft after an error.
Hexamining memory. Now let's try just pressing retum a few times. Voila! You
should get a display that looks something like this, but probably with different
numbers:
* (press return)
8900- A2 00 AO 02 88 BL 3E 49
* (press return)
BG08- 3E 92 BC 4A 3¢ 09 BC 99
* (press return)
8810- 00 8B EB CO 55 90 CD AZ
Not your normal, school-kid, decimal numbers, mind you; but hexadecimal
numbers.
In our friendly, everyday decimal system, each digit has ten possible values, 0
through 9. The digit on the far right represents units or ones; the next one to the
left, tens; the next hundreds (10 * 10); the next thousands (10 * 10* 10) and so on.
‘The hexadecimal system works exactly the same way, except each digit has
sixteen possible values, 0 through F (Startat 0, go up to 9, use A for 10, B for 11; F for
15.) Justas in the decimal system, the digit on the far right represents units or ones;
the next one to the left, sixteens; the next 256s (16 * 16); the next 4096s (16 * 16 *
16); and so on.
A two-digit hexadecimal number can range in value from $00 (0) to $FF (255).
dollar sign in front of anumber indicates it is a hexadecimal number. A four-digit
hexadecimal number can range in value from $0000 (0) to $FFFF (65535).
Look again at the display you get by simply pressing on the retum key. The
numbers on the left edge of the screen are four-digit hexadecimal numbers. They
represent an addressin your Apple's memory. The bytes that make up computer
memory can be considered small electronic cells that can hold any value between
0 and 255. Each of these cells has an address—kind of like a Post Office Box
number, From the Monitor, you can examine the contents of these cells by simply
pressing return.
In the above example, the contents of cell $B800 (47104) is $A2 (162); $B801
holds $00; $8802 holds $A0; and so on. Each line of the display shows you the
values in eight consecutive bytes. The second line begins with byte $B808, the third
with byte $B810,
Fine, but what ifyou want to see the value in byte $03D0, not byte $8800? Just say
so:
0300
0300- 4c
You can determine the value currently in any of your Apple's memory bytes by
simply giving the address of the byte you are interested in (in hexadecimal) and
pressing retum. If you specify an address with a number that has less than four
digits, leading zeros will be added automatically. If you specify more than four
digits, all but the final four will be ignored. Thus:
2
0e2- 04
"20
020-08
¥20000
200 4c
If you are interested in the values in a range of memory bytes, you have two
Open-Apple 11
choices. The firstis to give the address of the frst byte you're interested in and then
press retum a bunch of times. This gives you a display like this one:
"300
0300- 4c
* (press return)
BF 30 4C 84 90 4c FO
. (press return)
(0308- AA 4C BS 87 AD OF 90 AC
' (press return)
erEe- 0€ 90 68 AD C2 AA AC CL
Alternatively, to see a range of bytes you can give the beginning address of the
range followed by period and the ending address, like this:
*300.363
e302- 4C BF 90 4C 84 90 4c FD
@308- AA 4C BS 87 AD OF 9D AC
03€0- 0£ 9D 6 80
If you give a Jong range, such as 2000.3000, the values will quickly scroll by on
your screen. You can stop the scrolling by pressing control-S; restart it by pressing
control-S a second time (any other alphanumeric key will also restart scrolling).
You can send these memory dumps to your printer, if you like. Use the DOS
command pr#1 (assuming your printer is connected to slot 1) to pass output to
your printer, Use pr#0 to stop it again. (The Monitor also includes its own versions
of the pr# and in# commands, but they interfere with DOS, Always use the DOS
versions.)
Disassembling your Apple. If you have a silcon-based brain, you may find
these rows of hexadecimal numbers very interesting and useful. If, on the other
hand, you have a carbon-based brain like most humans, you probably find them
difficult to work with. For you the Monitor has a command called List. Beginners.
won't find its display any more intelligible than the last, but experienced users find
it quite useful. To use List, enter an address, put an L immediately after it (don’t
includea space), and press return:
"300
0200-
0303
0306-
0303-
o30c-
o30F-
032-
03€3-
oxE5-
0x€3-
oxa-
oxe0-
ote
o3eF-
o3F2-
03F3-
ox6-
oF.
O3F8- AC 65 FF INP SFFES
exe. 4c 65 FF HP SFFGS
This range of memory (which you'll only get if you booted with a DOS 3.3 disk)
begins at the same byte as our earlier row-by-row display. Again, the numbers on
the left indicate the addresses of the bytes revealed on the right. The numbers in
the three columns in the middle of the display are the actual values in these
memory cells. you compare them to the row-by-row display you'llfind theyarethe
same.
The difference is that the List command assumes these numbers area machine
language program. List organizes the numbers into a meaningful display. On the
right side of the display is an assembly language translation of the machine
language instructions.
For example, the machine language code for jump (equivalentto Basic’s goto) is
$4C. The address ofthe machine language program that is to be jumped to always
follows the jump command byte. In machine language, addresses are usually
written backwards. (No, | don’t know why.) Thus the 4C BF 9Din the first line of our
display translates into JMP $9DBF,
MP $908F
np $9084
ne s6FD
JM $8785
LOR $900F
Loy $900¢
RIS
Loa sence
Lov sAACL
RTS
HP $0851
Nop
NOP
IMP SFASS
0
STA $4038,x
cu
om
12 Open-Apple
The List command isn’t always able to give a true translation of a range of
machine language instructions. For example, look at the question marks near the
bottom of the listing, The stuff stored in bytes $3F2 through $3F4 is data, not a
command. But the List command has no way to know that It insists on translating
the data as if it were a meaningful instruction and gets nowhere.
If you have a Ilc, incidentally, the List command will correctly list the additional
codes of the 65C02 instruction set, something the List command in other versions
of the Il can’t do.
Now you know how to list the contents of your computer's memory as raw
hexadecimal values and asa machine language program. There is one other useful
format for examining memory—as ASCII values. Many bytes hold a number that
actually represents a letter or other character. The Monitor can’t show you those
letters and numbers directly, but we'll show you how to get a peek at them ina
minute.
Warming; when examining your Apple's memory with any of these techniques,
avoid the area from $C000 to $COFF. This range of memory addresses doesn't
contain true memory bytes. Instead, it's full of soft switches that control your Apple.
and the peripherals connected to it. Throwing these switches accidentally can
mess things up. Non-believers may enter C055 (return) and rejoin us after using
controlreset to recover.
Making changes. We've looked at how you can enter the Monitor with the call
-151. command. There are also other ways to enter the Monitor. You may be familiar
with “crashing” into the Monitor, which happens when a machine language pro-
gram executes a break instruction. The reset key can also be used get into the
Monitor if you make some adjustments to a few special memory cells.
Scan back and look at that “data” we saw earlier at bytes $3F2 through $3F4
when we used the List command. What that data actually represents is an address
the Monitor wll jump to when you press the reset key, and a check byte that makes
sure the reset address is current. If you look at bytes $3F2 and $3F3 in the above
display, you'll find they say BF 9D. Tur them around, since they are in the back-
wards machine language notation, and you have $9DBF. This is the same address
the first line of our display jumped to.
Under DOS 3.3, $9DBF is the beginning of the DOS "warmstart” routine. (Under
ProDOS, those bytes point to $BE00, which is Basic-system’s warmstart address.)
Thus, pressing reset normally warmstarts DOS, which in tum warmstarts Basic,
which in turns explains why we go from the Monitor to Applesoft when we press the
reset key.
If instead of Applesoft you'd like control-reset to put you in the Monitor, all you
have to do is change the address at $3F2 so it points to the beginning of the
Monitor program. As we leamed earlier, the Monitor begins at $FF69. To make it all
work, youalso have to puta $5A in byte $3F4. Ifyou wantto know why, read the June
1985 DOStalk, which examined all this in detail. You might also like to look at
Trapping Reset on page 16 this letter.
So now we know we want to put 69 FF 5A in bytes $3F2 through $3F4. But how?
In addition to allowing you to examine memory, the Monitor makes it quite easy
to change the values in memory cells. As before, you give the address you want to
startat, follow itimmediately with a colon, and then enter the values you wantin the
specified bytes. You must separate the values with spaces, like this:
1372269 FF SA
You can change up to 85 consecutive values in one command line —just make
sure you puta space between all the values. You can also enter a fewvaluues on one
line and continue where you left off in the next line by simply entering a colon with
no leading address.
‘After changing some bytes, you can confirm the presence of your new values by
pressing return as many times as necessary. The returns will produce a memory
display that begins at the last complete address you entered. Watch:
*2000:11 22 33
#244 55 56
1:77 68 95
AA 8 CC
* (press return)
2000- 11 22 33 44 55 66 77 88
. (press return)
2008- 99 9A BB CC 02 00 00 e@
Let's assume you've made the 3F2:69 FF 5A change to fix your Apple so that
control-reset will always take you to the Monitor (until the next time you re-boot,
anyhow). Now how do you get back to Basic?
The first line of the disassembly display we looked at earlier also contained a
jump to the DOS warmstart address. The Monitor has a command, called Go, that
allows you to execute the instructions at any memory address. To get back to Basic
Vol. 1. No.1
now that we've changed how control-reset works, we can do this:
#3006
1
In this command, 3D0 (note that's a zero, not a big 0) is the address we want to
jump to, the G tells the Monitor to jump. This address, $3D0, is known as the DOS
warmstart vector, and isa worthwhile address to remember if you use the Monitor
much,
Let me see letters. Control-Y is known as the Monitor's user command.
Assembly language programmers can write a special routine, place its address at
$5F9-$3FA, and execute it directly from the Monitor by entering controF. Here's a
special routine that you can use to change the Monitor’s memory dumps from
hexadecimal numbers to their equivalent ASCII characters:
#35200 03 (put address of routine at $3°8)
*3@0:AS 3C 25 @7 00 @3 20.92 (put routine at $300)
#30 BL 3C 48 29 7F 9 20
#260 08 68 09 08 48 A OE
#200 02 9 AO 20 £0 FO 6B
#:20 [0 FO 20 6A FC 90 08
1:60
After typing all this in, check it carefully. If you heard any beeps as you were
entering the line, you made a mistake— probably you substituted an 0 for zero.
Now you can examine memory in ASCII by entering the examine memory com-
mands just as before but also pressing controFY before pressing retum. Charac-
ters preceeded by an ‘in the display are control characters:
*690.AB00(contral-Y, return)
nege-")"€ 2 INIT
seg8- LOADS AVE
This monthyou've leamed how to examine the contents of your Apple's memory
as rawhexadecimal values, asan assembly language program listing andas ASCII
characters. You've also learned how to enter new hexadecimal values into memory.
Next month we'll examine some of the fancier things the Monitor can do, such as
move and compare values. For now, however, let's look at some Monitor tricks
involving Applesoft, DOS, and Logo.
Picking Up
Applesoft
f
The Basic connection. Getting the Monitor to dump memory in ASCII as we've
Justdone is a nice feature, but typingin all those hexadecimal numbers is a pain in
the chips. If we were dealing with Basic, we could write a program and save it, but
there's no way to do that from the Monitor. We could save those two ranges of
memory we've typed in as binary files and write a Basic program that would reload
them, but then you wouldn't leam anything new.
Several years ago a fellow named S.H. Lam wrote a letter to Call -A.PPL.E. in
which he showed how to execute Monitor commands from Basic. This technique
has since been used all over the place. | even used it in DOStalk in March (DOS 3.3
disk free space patch) and May (DOS 3.3 type command).
The technique provides for entering editing, and saving machine language
programs and requires relatively few characters to be typed, which cuts time, effort,
and mistakes.
Unfortunately, people often have trouble getting all the Is dotted and Ts crossed
when using this technique — especially when typos sneak into program listings, as,
happened in the May DOStalk.
The technique works like this, You write an Applesoft program that simply
defines whatyou would normally type into the Monitor asa string. After defining the.
string, your program jumps to a subroutine that gets Applesoft to type the string
into the Monitor for you. Here's the magic subroutine:
February 1985,
500 CS=C$ + “ N DSCEG” : REM space required before and after N
510 FOR I=1 TO LEN (C$)
S12 + POKE SLL+T, ASC(NIDS(CE,1,1))+128
S14 NEXT
520 POKE 72,0: CAL -144
530 RETURN
The first line of this routine tacks IY D9C6G onto the end of your command string.
Note that there must be a space before and after theN. More than 95 per cent ofall
reported problems with this techniqueare caused by a missing space between the
opening quote and the N.
if your command string (C$) is 500:0, then after line 500 is executed it wll be
500:0 N D9C6G. Lines 510-514 poke this command string into your Apple's key-
board input buffer. Line 520 calls a machine language subroutine inside the
Monitor that executes whatever's in that buffer.
Inthis case the Monitor would puta zero at byte $300, set display to normal, and
Jump to $D9C6. $D9C6 is a charmed spot inside Applesoft that continues execu-
tion of our Applesoft program. In this case we continue at line 5350's return from the
Lam subroutine.
‘One problem with the Lam technique is that the shortcut we used earlier of
entering colon without an address doesn't work. Here's how you would set up an
ASCII memory dump loader using the Lam technique:
39:00 03° : GOSUB S20
-300:AS 3C 29 07 D0 03 20 92"
128 0$="308:FD 81 3C 48 29 7F C8 20°
130 C$="310:80 08 68 09 CO 48 AB DE”
140 C$="318:08 @2 A AB 20 ED FD 6B”
320:20 ED FD 20 BA FC 90 08"
160 C$="328:60" : GOSUB Seo
170 END
+ GUSUE 500
GOSUB S00
G0SUB 500
GOSUB 500
GOSUE 500
500 C$=C$ + “ N O9CGG™ : REM space required before and after N
520 FOR T=1 TO LEN (C8)
512 + POKE SL1+1, ASC(MIDS(CS,1,1)}+128
S14 NEXT
520 POKE 72,0 : CALL -144
530 RETURN
Tosave even more typing time, the lines from 100 to 170 could be combined. But
there's an even better way, and its a DOS trick.
Digging
Into DOS
Writing Monitor programs. Earlier in this letter, | pointed out that DOS com-
mands work from within the Monitor. This flexibility leads to an interesting trick.
When considering DOS commands that you can use inside the Monitor, you will
think right away to try catalog, but how about fp or bload myfile or -/users.disk/
convert? Here's the real beauty, though, exec ascil.dump.
The exec command works just fine from inside the Monitor. What you put in the
text file you'll exec is bare Monitor commands. Instead of typing in a whole Basic
program, all you really have to do is sit down at your word processor and enter:
CALL -151 (optional, not needed if you exec From
within the Monitor.)
3F3:00 03
00:95 3C 29 07 09 @3 20 92
308:F0 81 30 48 29 7F C9 20
0 08 68 09 CA 4B AS OE
@2 AB AO 20 ED FO G8
32:20 ED FD 20 8A FC 90 08
328360
(a5 with the Lam technique, you must use
@ loading adsress on each Li
Use a word processor to create an exec file filled with Monitor commands. This
gives you the ability to edit your mistakes and to save your work. Now we can write
“Monitor programs”. It works with both DOS 3.3 and ProDOS.
Ifyou get into this, you might want to use it to edit our control-Y program a little.
Change byte $303 to $0F and you'll geta display 16 columns wide. A$1F at that spot
will give you a 32-column display —anice use for your 80-column screen (which, of.
course, you can tum on from within the Monitor with a pr#3).
It's not the kind of thing they teach your children in school, but the Apple
Monitor is readily available from Logo just as itis from Basic. With most Logos, the
‘command call -151 or its equivalent is probably the most convenient way to get into
the Monitor.
With Apple's 128K version, however, getting into the Monitor requiresa few tricks.
You can't simply call the Monitor's starting address, because Logo tums on and
uses all 128K of RAM memory. The Monitor ROM is tuned off and is invisible when
you're inside Logo.
On Apple's 128K computers, pressing Reset automatically turns on the ROM,
makingit momentarily accessible. Normally Logo trapsa press of the Reset key, as
we did earlier in this letter. It quickly tums the ROM back off, the RAM back on, and
informs you that you've pressed the Reset key and should reboot. The reboot
message seems a little heavy handed, however, since your program and data are
still intact and ready to run.
To getinto the Monitor, we can change the contents of the soft-entry vector. Then
Reset will provide our passageway in. This is easy enough. The problem then
becomes one of getting back out again. Apple's 128K Logo doesn’t support the
standard $3D0G warmstart address.
Tosolve this, let's move the contents of Logo’s soft-entry vector into the control-Y
vector. Then when we press control-Y from inside the Monitor, we'll go back to Logo
Via its Reset trap, and all necessary bank switching will be handled for us.
Logo commands will look like gibberish to those of you who have never encoun-
tered them before, so we'll explain them a little. In Logo you write programs by
creating a series of subroutines, called procedures. Each procedure is given a
name and you execute the procedure by simply saying its name. You might, for
example, write a routine that draws a house on the high-res screen and call it
house. Every time you enter the word another house will appear on the screen.
Let's write a short program, called mon, that will poke the changes we need into
the soft-entry and contro-¥ vectors. Apple's 128K Logo does haveall the primitives
(built-in procedures) we need for this. Ifyou are using a different version of Logo,
your version may have different names for these primitives. .DEPOSIT adr valis like
a Basic poke. .EXAMINE adris like a Basic peek.
First, let's write the procedure that will do the actual poking,
TO DD.NON.POKES =
-DEPOSIT 1017 .ExAMINE 1018
DEPOSIT 1018 EXAMINE 1011
DEPOSIT 1010 105
-DEPOSIT 1011 255
DEPOSIT 1012 90
ND
The to tells Logo we are writing a procedure. This causes what we type to be
stored, rather than executed immediately; the same effect line numbers have in
Basic. The effect lasts until we type end, which tells Logo we are done with that
procedure.
After the to you put the name of your procedure. On the next and following lines.
‘come what you want to do. The first two lines of our procedure move the Reset-trap
address that Logo keeps in the soft-entry vector into the control-Y vector. The final
three lines poke the address of the Monitor program into the soft-entry vector and
correct the power-up byte.
One problem with do.mon.pokes is that if you run it twice, by accident or
otherwise, the control-Y vector ends up with the Monitor's address in it and you
can't get back to Logo. Let's write another procedure that will call do.mon.pokes,
but only if it hasn't been run already. We can tell by looking at byte 1018, which
always equals 255 before running do.mon.pokesand some other value afterward.
TO HON
IF 255 = .EXAMINE 1018 [00.MON.POKES)
0
That's all there is to It. To execute, type mon, then press Reset.
Detecting NOT SELECTED
Is there an easy way to detect that a printer is off
before the NOT SELECTED message appears?
Harold D. Portnoy
Bloomfield Hills, Mich.
(For those of you who don't have the Grappler+
interface card, the Grappler places a beep and the
words “NOT SELECTED in the middle of the screen
when you try to print something and the printer is
tured off or deselected.)
The standard answer to this question is no. How-
ever, if you are writing software for your own system
and thus know in advance what printer and interface
card your program will use, it can be done quite
easily.
Enter the Monitor with acall-151 and take a look at
the softswitches associated with your printer. There
are sixteen of them; they begin at $C0B0+s0, where
= your slot number, If your printer interface card isin
slot 1 for example, look at the switches $C090.CO9F,
‘Sart with your printer tured off.
e° off)
51 51 S1 SI S151 51
51 51 Si S151 SI
your printer on: leave unselected)
2.CeSF
50 $0 SO SD 5D SD 50
50 SD SO SO 50 SD 50
er on; selected)
52 $3 53 $3 93 53 53
$3 53 53 52 5253 53
The values shown here are what you'll see if you
have a Grappler*, Other cards will display other
talues. All you have to do now Is peek at one of these
locations and see if the expected value is present. For
example:
NOT"
PEEK ( 45260+5.
NT NS;~ SELECTED
RUN this program while selecting and deselecting
your printer. If you have a lic, you'll find that it can’t
tell the difference between a printer that is selected
and one that's turned off (though it can tell selected
from deselected ifthe printer is turned on). I suspect
this will be true of al serial printer interfaces.
ProDOS and compilers
Can | use a DOS 3.3 Applesoft compiler (Einstein,
‘TASC, Expediter), transfer the object code to ProDOS
16) = 83 THEN NS=""=REM 63-553
2 GOTO 20
using Convert, then patch the 1/O hooks to get Pro-
DOS to recognize DOS commands?
' Michael Couvillon
Ft Walton Beach, Fla.
T haven't tested it, but theory tells me it will never
work, ProDOS uses a different scheme for recogniz-
ing DOS commands than DOS3.3. Anybody out there
know of an Applesoft compiler that can produce
ProDOS-compatible object code?
FIND:/user group/
Doyou know of any Apple Il user groups in my area
(northeast comer of Oklahoma)?
Claude E. Williams
Jay, Okla.
You're surrounded by them—but they're all about
60 mites away. I don'thave anything on these groups
except their addresses, but you could write for more
information:
Tulsa Computer Society's Aople Users
°.0. Box 1133
Tulsa, 0K 74101
Joplin Apple Users Group
1903 £. 36th
Joplin, MO 64801
Razorback H.8.U.6.
3000 Rogers Ave.
Fort Snith, A 72301
Hfyowhave a modem, the closest groups to youare
probably the Micronet Apple User Group on Comput
Serve and the Source Apple User Group.
Incidentally we're trying to develop a data base on
Apple user groups here at Open-Apple. We also
exchange subscriptions with groups that have news-
letters.
Msg from a parallel universe
>
CEREAL INTERFACE
SE
SOUPER CEREAL. /NTERFACE
Itried the programs dealing with the onerrroutines
in the January issue (page 2) and put the "empty’ file
on the ProDOS /ram volume. This speeds things up
greatly and makes life easy on the old disk drives. It
also executed the onerr routine 8,400 times without
fail while | watched the late night news. What else are
people doing with /ram?
TS. Goodfellow
Raleigh, NC.
Mousetrapped
There seems to bea lack of good information on the
lic. | hope your publication can supply that need as
well as others. For instance, | feel suckered now for
buyingMousePaint. as [have been unable tofind any
other programs that use the IIc mouse. Help.
Tom Milford
St Louis, Mo.
Vol. 1, No.1
More mouse software should be upcoming soon.
Apple has provided software developers with a
Macintosh-like interface for the Apple Il series that
uses the 80-column text screen, the mouse, and the
infamous "Mousetext” characters that occasionally
‘appear on your screen where inverse capitals should
be. Software using this interface will likely begin to
appear by summer.
Tm not completely sold on the mouse—we have a
lot of trouble around here with the ball sliding, rather
than rolling, across the desktop; this will drive you
nuts with great speed. I like the features of Apple's
human-computer mouseface, however.
Stalking the I/O Error
I recently bought Terrapin Logo for the Apple and
the disk wouldn't boot. Just for the heck of it. | went
under the hood and reversed my drives. To my sur-
prise, the disk booted ok on my former drive 2 (then
the door hinge broke).
At the same time, along the same lines, I got an
unprotected demo disk thatwouldn'tload. Using Disk
Recovery | checked it out and got a report that both
sides were full of bad sectors, but, strangely, the pro-
gram couldn't seem to make up its mind about which
sectors were bad—they changed every time I ran the
program. After my second drive was fixed, the front
side breezed through the testwith no errors reported.
also tested a couple of unprotected commercial
disks that were perfectly functional. However, one con-
tained many mis-assigned sectors and the other had
an invalid track/sector list. In both cases | suspect that
the producers resorted to subterfuge to conceala very
substantial part of their programming and the combi-
nation could cause the unwary to delete a large chunk
of an otherwise valid program.
Gardyloo,
Ralph Moredock
‘Campbell, CA
Thave several floppy drives; the oldest has been my
most-used drive for almost four years. None of them
have ever been adjusted, aligned, or (blush) even
cleaned. | did take one apart once to see what was
inside, but | didn't tueek anything.
Based on this experience, I suspect many disk drive
problems start as software problems and become
hardware problems onlyafter the drive gets “adjusted”
inanattemptto fixthings. Those of you oho have had
real hardware problems will probably vehemently
disagree with me.
The Number One cause of disk problems is bad
centering. Disks must be perfectly centered in the
drive or they won't work. There isa mechanism inside
the drive that is supposed to center the disk, but it
doesn't work reliably.
Hub rings on your disks help solve the centering
Problem. Most disks sold nowadays come with these;
I recommend you refuse to buy any that don't have
them. The hub ring stiffens the magnetic material,
consequently the centering device does its job better.
The original purpose of hub rings was to keep the
center of the disk from wearing out, but this hasn't
beena problem on 5-1/4 inch disks.
‘The best tip for centering disks, however, is to wai
until the drive is spinning before closing the driv
door. Yes, | know all the books say not to do that. Jus
never open the door while the drive is running—o
more exactly writing on the disk. That can destrot
disks, Butclosing the door with the drive on not only
doesn't hurt anything, it actually helps,
Adisk that is accidentally initialized while off-cente
February 1985
isparticularly useless. As soon as you remove it from
the drive you've lostany data you've saved oni. Youll
never get it back in the drive in just exactly the same
off-center orientation youstarted with. Thus, itis very
important to delay door-closing when initializing
disks.
Whenever you have a commercial disk that won't
boot, but just sits in the drive and spins, open and
close the drive door. This will center the disk and
allow it to boot about 90 per cent of the time. And
while we're talking about doors, let's mention that it
may not help, but it certainly doesn't hurt to openthe
doors on your drives before you turn off your compu-
ter, That little flicker of the in-use light could mean the
drive head is flickering too.
If your disk is centered property and still doesn't
work, the next most common problem is electrical
interference from your display screen. Monitors and
television sets work by guiding an electron beam
across the screen with electromagnetic radiation. If
your disk drive is close enough to the screen, this
radiation wil! overwhelm the tiny signals the disk
head is picking up from the magnetic fields recorded
on the disk.
To solve the problem, simply move the disk drive
farther away from the display screen. Magnetic inter-
ference occurs quite often with the IIc because the
drive is naturally close to the screen. And it occurs
almost every time youtry to usea Ilc while it's sitting
‘on top ofa television set.
If the disk still won't boot, try changing to a differ-
ent model of Apple. | was about to throw out two
commercial, copy-protected disks that I thought had
shot craps; however, I finally figured out that both
boot just fine on my II-Plus. It's only on Hes and lcs
that they won't work. This ts one of the many joys of
copy protection.
Finally, if your disk still won't boot, get out your
DOS 3.3 System Master and BRUN BOOTIS5. | really
have purchased a commercial program within the
last year that used DOS 3.2. These disks will not boot
on today's Apples unless you boot via BOOTIS.
Ifthat doesn't work either, you've covered about 98
percent of the probable problems. If we split up the 2
per cent that’s left, there's a L9 per cent chance the
disk is bad, a .09 per cent chance of some other
problem (try cleaning the edge contacts on your disk
drive card), and a.01 per cent chance your disk drive
is bad.
The only clear sign that a drive needs to be adjusted
ts that disks written with one drive can’t be read by
another and vice-versa. One of those suckers needs
fixing. All you have to do then is figure out which one,
As to the unusual things Disk Recovery found on
unprotected commercial disks, | suspect an attempt
to enhance performance rather than subterfugeis the
root cause. For example, GPLE uses. very strange file
structure. You can't successfully copy it by BLOADING
it, finding its loading address and length, and BSAV-
ING it with those parameters, The reason for thisisn’t
subterfuge, however, but to get it to load quickly.
AppleWorks vs Oki
Thave an Apple tle, Grappler, and Okidata 92. Any
idea how | can get AppleWorks to work with my prin-
ter? As usual, my Apple dealer doesn’t have the
foggiest
Arlene Samowich
Nashville, Tenn
There is an answer to your problem. I just don't
know what it is, But here's a note | found in the
Princeton (NJ) Apple Users Group newsletter, “Clancy-
Paul (a dealer in Princeton) has ‘found’ the Apple-
Works configuration disk that Bart Thomas donated
to them and spoke about at the last meeting. Anyone
who has other than an Apple Parallel Interface Card,
‘or who's using an Okidata 92 printer, will probably
need this fix to print properly”
From yet another note in the same newsletter, |
know that Bart Thomas is an alternate system opera-
tor for the Micronet Apple User Group on Compu-
Serve. Thus, I suspect Bart could put the fix you (and
many others) need on MAUG (if t's not already there)
and you could download it. if the fics available from
other sources I'm sure one of our readers wil tell us
about it.
Dump 80
Explain how to get an 80-column screen dump to
printer and Il sign up for 100 months.
Steve Madigan
Culver City, Calif
To do a screen dump, you have to peek directly at
screen memory to get each character. Screen memory
has a Byzantine organization, so begin by setting up
anarray that holds the starting address of each of the
24 lines on the screen, like this:
108 IM LADR(23)
110 FOR I= TO 23 : READ X + LADR(I)=X : NEXT
120 DATA 1024, 1152, 1280, 1408, 1536, 1664,
1792, 1920, 1064, 1192, 1320, 1448,
1876, 1704, 1832, 1960, 1104, 1232,
1360, 1488, 1616, 1744, 1872, 2000
Our program will use one loop to advance from tine
toline. Asecond loop inside the first will peek ateach
of the 80 characters on a line. The trick is that there
aren't really 80 different addresses for each line.
There are only 40 different addresses —but half of
them (odd columns if you consider the first column
number 0) are in main memory and half of them are
in auxiliary memory When the 80-column mode is
active, you can switch back and forth between the
two memory banks by hitting softswitches at 49237
(even columns) and 49236 (odd columns).
Thus, the rest of our program looks like this (don’t
forget to include the lines 100 to 120 above!):
200 IF PEEK(78)=198 THEN 250 : REN 3.3 or ProOOS?
210 POKE 43602,0 : REM brute force <cr> for 005 3.3
250 PRINT CHRS(4);“PRHL” : REM printer on
260 PRINT CHRS(9);°9ON" : REM dont mess up screen
300 FOR LINE = @ 10 23
305:
ue
320
330
348
350
360:
DO + NEXT
380 : PRINT LS
390 NEXT
OR CHR=@ TO 39
OR=LADR((LINE) +CHR
POKE 49237.@ : REM peel even coluans
(S=_ 5+CHRS (PEEK(ADR) )
POKE 492360 : REM peek odd columns
+ LS=LB+CHRS (PEEK(ADR) )
400 REM Rehook 80-col screen without erasing it.
410 REM See tip on page 6 of January Open-Apple.
420 IF PEEK(978)=190 THEN 450 : REM 3.3 or Prod0S?
430 POKE S4,? + POKE 55,195 : CALL 1002 : REM 005 3.3
449 SOTO 508
450 PRINT CHRS (4); “PRHASCIO7” > REN ProdOS
500 END
To get this program to work I had to resort to a
couple of tricks you may not have seen before. Inline
200 we determine if our program is running under
DOS3.3 or ProDOS. If 3.3, we need to print aretumso
Open-Apple 15
DOS will recognize the DOS command in line 250—
but a retum may mess up our screen display. Thus
we resort to the brute force technique in line 210.
In lines 250 and 260 we tum on the printer. Line
260 has two functions. First, it tells your printer inter-
face card that we don't want what we print sent tothe
screen. It would mess up the very display we are
trying to dump if it did. Secondly, it tells the card to.
expect 90 characters per line. Since we will be print-
ing 80 characters plus a carriage retum for each line,
the card will actually see 81 characters perline. If you
use the standard CHRS(9);"80N" in line 260, your
dump will be double-spaced because both your pro-
gram and your interface card will send carriage
returns after 80 characters.
Lines 300 through 390 scan the display memory
and place the characters found in the string variable
LS. After gathering a line, L$ is printed in line 380. The
routine would be a lot faster if we could print the
characters as we gather them in lines 340 and 360
rather than saving them in a string for printing later.
However, for reasons! don't understand, the system I
tested this program on (a IIc/Imagewriter combina-
tion) consistently garbled things when I tried to PRINT
while the even columns were tumed on. Can any of
‘you wizards out there explain that?
Finally lines 400 to 450 tum the printer off and
returnto the 80-column screen without erasing it. For
the details on how this works look on page 6 of last
month's newsletter.
That will be $200, please.
Problem too complex
Here's a little program you may find interesting (1
find it perplexing).
LIST
10 ONERR GOTO 100
20 PRINT “HELLO FROM LINE 20”
30 Ae"
40 END
102 I=1+1 : PRINT I
11@ CALL -3268 : GOTO 20
RUN
HELLO FRON LINE 20
1
HELLO FROY LINE 20
2
HELLO FROW LINE 28 (program hangs)
(you press Reset)
just
FORMULA TOD COMPLEX ERROR
]
‘The call -5288 that yourecommended in the January
issue (page 2) doesn’t work if the error is type mis-
match or string too long. The computer hangs and
you have to hit Reset. Then, when you try to list the
program, you get ?formula too complex. A second
attempt to list the program usually works, What's
going on here? I'm extremely frustrated at trying to
bullet proof my programs.
Brent Thorwall
Crystal Lake, Ill.
T haven't been able to figure this one out—maybe
somebody else can help. The stack appears to be
getting messed up, but in looking at the Applesoft
code I can’t see why it would. ! have figured out that
the error isn’t absolutely related to type mismatch —
try replacing line 30 withA$=A, also a type mismatch
error, and it runs just like it’s supposed to.
I'm sure there's an explanation for this, anybody
out there got an easy answer?
16 Open-Apple
Trapping Reset
I'l be happy to contribute $24 a year to keep you
productive and off the streets.
How can I direct a program to line x or line y after
Reset has been hit?
Dennis Mah
Federal Way, Wash.
My kids thank you.
Your question is short, to the point, and theoreti-
cally very easy to answer. So why hasittaken me two
days to figure it all out? In the process I've made an
incredible, new, useless discovery about the 6502
microprocessor. Please, no more questions like this
one!
Part of the reason your question was so hard was
that | was sure | could answer it witha few PEEKS and
POKES. | wanted to do this completely from Basic. |
didn’t want to have to stick any little assembly lan-
guage routines anywhere.
The reason | had trouble is that pressing Reset,
unbeknownst to me, scrambles the contents of the
6502's stack register. Applesoft uses a small section
of the stack to parse command lines. If the stack
register accidentally points at this area after a Reset,
Dr. Basic trips over his own feet and tumbles to the
ground.
In addition to scrambling the stack pointer, press-
ing Reset disables interrupts and causes the 6502 to
‘etch the address stored at SFFFC and jump there, On
ail but the earliest Apples SFFFC points to $FA62. The
routine there is called, appropriately enough, reset.
That routine puts the 6502 in binary (rather than
4ecimal) mode; tums on normal (rather than inverse)
characters; turns off graphics and tums on full-
cindou, 40-column text with the cursor at the bottom:
‘ofthe screen; connects the keyboard for inputand the
display screen for output (disconnecting DOS from
the | Ohooks in the process); turns offannunciators 0
and 1 and tums on annunciators 2 and 3; clears the
keyboard strobe; tums off any active peripheral card
ROM: and rings the Apple's bell.
Inthe He and llc, special hardware circuits also tum
‘on the motherboard ROM and the main bank of RAM.
Auxiliary RAM is disabled. On earlier Apples with 64K
of memory on the other hand, Reset does not change
the memory configuration.
After doing all of the above, the reset routine takes a
look at byte 1012 (93F4). Ifthis byte, called the power-
up byte, contains the proper value, the routine next
jumps to the address stored in a place called the
soft-entry vector, whichis at 1010 ($3F2). Ifthe power-
up byte contains can other value, as it always does
Open-Apple
© Cope 1985
‘Tom Weishaar
Published monthly.
World-wide price:
US$24/year
‘Send all
ism wagerar of Tom Computer and
{wo diferent unrelated. independent companies
Path aveyene'n ne woidhad en Apple
fom Weishaar Apple
Open
immediately after you tum on your computer, reset
will attempt to boot a disk.
‘The address usually stored in the soft-entry vector
is the DOS warmstart address — 40383 ($9DBF) for
DOS 3.5; 48640 ($BE00) for ProDOS.
Thus, the next thing Reset normally does is warm-
start DOS. For DOS 5.3, this means the language card
is switched back to whatever language had been in
use when Reset was pressed; DOS is reconnected to
the I/O hooks; a NOMONICO is executed; and ajump
occurs to Basic’s warmstart address, 54332 ($D43C),
The Applesoft prompt and cursor appear on your
screen. Your program and data are intact, but your
program is no longer running.
ProDOS‘s Basic.system, on the other hand, handles
warmstarts a little differently, It first jumps to the
CLEAR command inside Applesoft at 54885 ($D665),
which empties out all yourvariables and leaves them
filled with zeros. This isn’t real handy if you'd like to
recover from a Reset without losing any data. The
CLEAR routine also fixes the stack register, however
—something DOS 3.3 neglects to do. Next ProDOS
reconnects itself to the 1/O links, pushes the cursor
cover to the left edge of the screen, and warmstarts
Basic at 54335 ($D43F). Again the Applesoft prompt
and cursor appear on your screen. Your program is
intact but no longer running: your data is gone.
(Note the two Basic warmstart addresses are differ-
ent by three bytes. ProDOS skips the first warmstart
instruction, which sends a carriage return to the
screen. AProDOS reset doesn't mal the screen scroll.
ADOS 3.5 reset does. This is why. It’s also why Pro-
DOS has to push the cursor to the left edge of the
screen by hand.)
Now you know everything there is to know (and
much more than you probably wanted to know)
about Reset. Your original question remains, however
—how do you keep a Basic program running and
send control to a special error routine when Reset is
pressed?
Intheory all you have to do is change DOS so that
Instead of warmstarting Basic, it jumps to a Basic
error handler. Applesoft doesn't have a “Reset” error,
thus we'll have to use another one. There’sa good one
at 58123 ($£30B)—illegal direct. This error occurs
when you try to do an INPUT, GET, or a few other
commands from the keyboard. It never occurs in a
running program. So let's modify DOS a little; a sim-
ple task,
DOS 3.3 keeps the Basic warmstart address in an
internal vector table; it's at $9DSE (40286) when DOS
is at its normal 48K location. ProDOS, on the other
hand, doesn’t use a vector table for this. In fact, the
bytes you have to change move around from one
ProDOS version to another. Luckily, they're easy to
find: first look at the ProDOS warmstart vector at
48640 ($BE00) to determine where the actual warm-
Start code lies; the bytes that must be changed are the
‘th and 12th bytes of the warmstart code (at least
that's where they've been inall Basic.system versions
to date).
After we make these modifications, Reset, in con-
junction with an ONERRGOTO statement in your pro-
‘gram, will pass control to ONERR with the code foran
illegal direct error (149) stored where you can fish it
out with the standard PEEK(222).
That's the theory anyhow. But Basic still occasion-
ally crashes under DOS 3.3 because of stack prob-
lems and under ProDOS we lose all our data. Let's fic
these problems, too. With ProDOS, we'll change the
_jump to the CLEAR subroutine into ajump tojust the
Stack initialization subroutine, which lives at byte
Vol. 1, No.1
54915 ($D683). With DOS 3.5, we'll put the jump to
the stack initialization subroutine over the top of the
automatic NOMONICO (good riddance!).
Whew. Alittle program that doesall this stuff follows:
10 REM Reset trap
123:
91S +
REM address of FP illegal direct error
REM address of FP stack initialization
30 IF PEEK(978}=157 THEN $0 : REM 005 3.3 active
35 IF PEEK(978)=190 THEN 60 : REM ProO0S active
40 PRINT “ACTIVE 005 NOT RECOGNIZED." : END
50 Al=40286 : REM 48K DOS 3.3 Basic uarnstart vector
52 A2=40401 : REN auto NONONICO+1
53. IF PEEK(40409)=0 THEN 58
S4 FOR 1=40403 TO 40400 STEP -1 :
+: POKE 1,PEEK{(I-3)
56 NEXT REM
58 GOTO 70
+ REM shuffle sore
REM 00S 3.3 stuff
2 REM around (First
RUN only!} to make it work.
60 A2=11PEEK (49641 ]+PEEK( 48642] #255
62 AL=AZ+10 = REM fish out ProDUS adrs
REN (58E20) +1
70 REM 2-nyte pokes adrjvalue
72 POKE Al+L,VI/256 = POKE AL,V1-(PEEK(AL+1] #256)
74 POKE A2+1,VZ/256 > POKE A2,V2-(PEEK(AZ+1] #256)
80 ONERR GOTO 200
100 GOTO 160 : REM lockup
200 PRINT “ERROR W; PEEK(222); ~ IN LINE “;
PEEK(218) + PEEK(219)#256
Run the program (nothing will seem to happen—it
locks up in tine 100) and press Reset. Line 200's mes-
sage should appear on your screen. Since the illegal
direct error won't ever occur naturally inside a pro-
gram, you can always be sure its appearance means
somebody pressed the Reset key.
Delete line 80's ONERRand RUN the program again.
Now Applesoft's built-in message center will print
illegal direct error in 100.
If you haven't saved the program to disk yet, do it
now. Put line 80 back in and add 210 RESUME. RUN
and press reset. You'll find yourself in an eternal cycle
oferrors. Too many things get changed when Resets
pressed to simply resume execution. Instead, warm-
Start your program with a GOTO. Inthis case, use 210
GOTO 100.
RUN again and try pressing Control-C as well as
Reset. That, Dennis, is how you direct a program to
line xafter Reset has been hit. The only way to get out
of our sample program now is with a hard Reset
(control-open-apple-reset or turn the computer off).
Sure hope you saved it like you were supposed to.
Remember that Reset tums off graphics and 80-
column displays, reconfigures memory, and makes
other subtle system changes. Your ONERR routine (or
your warmstart) may have to take special steps to set
these things aright again.
The modifications we made here should never be
permanently added to DOS. They cause a lot of trou:
ble if you don't want Reset trapped. DOS 3.3's INT
command could jam and 5D0G does strange stuff.
Since this seems to have turned into a definitive
explanation of Reset, let's mention a couple more
things. If you ignore my advice and try to change the
soft-entry vector (instead of leaving it pointing to the
DOS warmstart routines), CALL 64367 (SFBGF) after
the change to correct the power-up byte. If youdon't,
the disk will boot when you press Reset. On the other
hand, if that’s what you want to happen, just poke a
zero into the power-up byte (POKE 1012.0).