APPLE II HISTORY ===== == ======= Compiled and written by Steven Weyhrich (C) Copyright 1991, Zonker Software (PART 16 -- LANGUAGES) [v1.0 :: 22 Jan 92] PROGRAMS "R" US Nearly everyone reading this is already a programmer, on one level or another. Even if you don't know a "GOTO" from a "STA $C030", you already know how to program something. For the act of "programming" is nothing more than giving instructions to a non-human device to have it carry out what you want it to do. The device that most of you already know how to program is your automobile. The act of giving those instructions may not seem like programming to you; nevertheless in its strictest sense, programming it is. You want the car to go forward? Set the transmission to "D". Go in reverse? Use "R". Of course, the programming needed to operate an automobile is quite simple, and cannot be done in more than one step at a time. An example of a device that is more complicated to program but does let you store up several instructions in advance is a VCR. On the VCR you instruct it to record a television broadcast that starts at 7:00 pm and ends at 8:30 pm, on channel 6. The more sophisticated VCR's can have several programs set up in advance. If you can operate a VCR in this fashion (which is, admittedly, not always as easy as I have described), you are a programmer. When it comes to the microcomputer, the process of programming (giving it instructions on how to carry out a task) is somewhat more complicated. This is primarily because the computer is far more flexible in its ability to accept instructions and carry them out than is an automobile or VCR. Devices attached to a computer can be manipulated by a program to do something useful (print a letter several times, or perhaps read the outside temperature and sound an alarm if it drops too low). This flexibility, plus the speed at which a computer can execute its instructions, makes it a powerful tool for doing things that have previously taken much more effort and time. And as a project becomes more sophisticated, so also must the programming acquire a similar level of sophistication. The rate at which computers, including the AppleII, have increased in capacity during the past fifteen years has made it possible to design programs that can do things that were not even dreamed possible back in the days of the 4K Integer BASIC machine. An example of programming evolution on the AppleII was given during Kansasfest in July of 1991. To fully appreciate this narrative, you need to know a little about an old Integer BASIC program, APPLEVISION. This was found on the DOS 3.2.1 System Master disk, and was a fun little display that showed off the use of hi-res graphics. It began by creating a simple line drawing of a room, with a picture on the wall ("HOME SWEET HOME") and a television set. On the screen of the TV appeared a man who danced to the tune of "Turkey In The Straw", which sounded on the built-in speaker. It ran repeatedly, until the user interrupted the program. It was fascinating at the time, since there was nothing in the program text that showed off exactly how the hi-res effects were accomplished. But things have gotten a bit more complex as time has gone by: "Roger Wagner's keynote address featured a history of hypermedia which Roger set into action and left to run as he wandered offstage. The history began with Bob Bishop's classic AppleVision, done in black and white on the original AppleII. Progressive screens enhanced the AppleVision image using subsequent incarnations of AppleII graphics (single hi-resolution, double hi-resolution, and the IIGS's Super Hi-Resolution modes). Finally, thanks to a laserdisc player under HyperStudio's control and a video overlay card, Roger's image appeared within the television's screen and spoke to the audience, completing the introduction before turning the presentation back to Roger (returning from offstage)."<1> To follow the programming progress that has made such magic possible, we will begin with the first two built-in high-level languages for the AppleII, Integer BASIC and Applesoft, and move on to a briefer discussion of some of the other languages that have been available over the years. Next will be a summary of various 6502 and 68816 assemblers that Apple programmers have used over the years. Finally, I will present an introduction to "hyper-programming". FUNDAMENTALS OF PROGRAMMING A programming language has the standards to translate "what I want" into commands that the computer understands. To do so, it must take some human language and convert it into the binary dialect of the computer on which it is executed. Computer languages usually come in one of two different types: "interpreted" and "compiled". A language that functions as an interpreter takes the text of the program and translates it at the time of execution into commands the computer can understand. A compiled program, on the other hand, has already had the program text translated into executable code before it is run, usually including some extra code needed to carry out necessary functions of input, output, and calculations. As such, an interpreted program usually runs more slowly, but has the advantage of being easier to modify and re-run without the delay of first re-compiling. A compiled program will ordinarily run faster, but may use more memory than an equivalent interpreted program. Languages are also given the designation of being "high-level" or "low-level", depending on how close they are to the base language of the computer on which they run. The lowest level of computer programming is at the level of the bytes understood as commands by the microprocessor. This "machine language" is typically not very understandable to humans. A low-level language more often used by programmers is "assembly language". This uses commands somewhat more understandable ("LDA $24" means "load the accumulator with the contents of memory location $24") and are then assembled (actually compiled) it into machine-readable code. Assembly language is very powerful, since it works on the byte level of the computer. However, as a low-level language it can be very complicated and requires an intimate understanding of the function of the computer. As a language becomes more "high-level", it is easier for humans to read, but requires more effort from its interpreter or compiler to translate it into the native language of the computer. INTEGER BASIC This was the first language available for general use on the AppleII (aside from assembly, which will be dealt with later). Most of the details concerning its development have already been covered in Part 3 of this History. It was a quick, compact language, and its creation was an example of programming directly in machine language (since Steve Wozniak, the author, had no assembler available to use). Its disadvantage was the lack of easy access to floating point operations, and it lacked some string handling functions. AppleII users, especially those who wanted to produce programs that could be used in business applications, wanted something more powerful to use. Despite its limitations, Integer BASIC was a language that had a fanatically loyal following. For those thousands who purchased AppleII's from June 1977 to June 1979, this was the only programming language available, and it took on a status similar to that of a beloved first-born child. Games, utilities, and even some simple business-use programs were written using Wozniak's hand-assembled masterpiece, and those who followed the pages of Call-A.P.P.L.E. magazine learned much about the internals of the language. With the disassembler built into the Monitor, people tore Integer BASIC apart to learn how it worked, and to make it work better. Val Golding, the editor of Call-A.P.P.L.E., even wrote a series of columns in 1979 entitled "So Who Needs Applesoft?" These articles showed how to simulate some of the more advanced features of Applesoft in this older BASIC. A.P.P.L.E. even sold (under license agreement with Apple Computer) "Integer BASIC +", a relocatable RAM version of the original ROM BASIC. It had all the features of the original language, plus a "USER" command, the ability to easily do four direction scrolling on the text and lo-res screens, easy printing of ASCII characters, and improved error handling.<2> Apple never released a comprehensive reference manual for Integer BASIC. The only manual available for it was primarily a tutorial (and a general introduction to using a computer). The "AppleII BASIC Programming Manual" didn't even call it "Integer BASIC", but referred to the language as "Apple BASIC". It gave most of its programming examples in the form of segments of a graphics and sound demo that created a lo-res ball bouncing off the sides of the screen.<3> With the many programs available that were written in Integer BASIC, it was almost a necessity for Apple to offer a means for AppleII Plus users to be able to run the older software. The Integer Firmware card made this "backward compatibility" possible. This was especially important in the early days of the II Plus, when there was little new software available to use with Applesoft. APPLESOFT I Although Wozniak had written some floating point routines into the Integer Basic ROM, AppleII users needed a version of Basic that would make floating point math easier to do, particularly for business use (where the number to the right of the decimal point is as important as the one to left). Apple decided to license a 6502 version of a floating point BASIC from Microsoft Corporation. Back in 1977, Microsoft was producing BASIC interpreters for nearly every microcomputer that was produced. The version Apple purchased was almost identical to the MITS extended BASIC that Microsoft had previously written for the Altair 8800.<4>,<5> This BASIC was named "Applesoft", and was released in November of 1977 on cassette. It was loaded as a 10K program that looked to the computer just like an Integer BASIC program, though only a small part of it really was. To make it easy to load and start from cassette, the Applesoft interpreter was attached to the end of a short Integer BASIC program. When the Integer program was run, it poked some values into memory and jumped to the start of the machine language section, which relocated the Applesoft interpreter to the lower part of memory (at $800), just after the memory that held the screen display. Using this version of Applesoft (which later became known as ApplesoftI) could be frustrating. It took several minutes to load from the cassette tape, and it was not dependable. If the wrong key was pressed while entering or running an Applesoft program, the program that was being run could be wiped out, and the Applesoft interpreter itself would have to be reloaded from cassette. However, few users knew how to make use of the floating point routines that Wozniak had written into the Integer ROM, so this unreliable Applesoft BASIC became the only practical means of doing floating point math on the AppleII. Aside from the reliability issue, another difficulty with Applesoft involved hi-resolution graphics. Although the AppleII was capable of displaying it, the Applesoft interpreter extended up into the memory used by the hi-res screen, and so prevented its use. Furthermore, this early version had no built-in commands to manage hi-res graphics.<5> ApplesoftI came with a manual that was 8 1/2 inches by 11 inches in size, and sported a blue cover with square glued binding.<6> This came to be known as the "blue book" (recall that the reference book for the computer itself was affectionately known as the "red book"). When starting the interpreter after loading it from the cassette, a screen was display announcing that Applesoft was copyright 1977 by Apple and Microsoft. It then asked the user for the memory size of his computer, and gave options of allowing either LET and REM statements or the use of lo-res graphics. The names of the lo-res graphics commands were very different from those that existed in Integer BASIC (and in the later versions of Applesoft). The commands were: PLTG = Go to lo-res graphics mode TEX = Go to text mode PLTC N = Set color to N (0-15) PLTP X,Y = Plot square at X,Y PLTH X1,X2,Y = Plot horizontal line from X1 to X2 at Y PLTV Y1,Y2,X = Plot vertical line from Y1 to Y2 at X There was a note about these commands in the reference card included with ApplesoftI that warned about using graphics coordinates only between 0 and 39, or a program could "self-destruct". Apparently it lacked the error checking that could prevent the plotting of lines from spilling over into the text of the Applesoft program itself.<6>,<7> The A.P.P.L.E. user group published a patch in 1978 that allowed programmers to avoid the question about using LET and REM statements versus lo-res graphics, and use the graphics only. The author of the patch pointed out that the LET statements were not necessary ("A = 3" worked just as well as "LET A = 3"). The REMark statements could be simulated by putting them at the end of a GOTO line (where they were ignored by the interpreter), and the GOTO could just jump to the following line: 530 GOTO 540: REM LINE 540 SETS VARIABLE N. 540 N = 2 Additional patches were made available for some of the other bugs found in ApplesoftI.<8> APPLESOFT II In spring 1978, Randy Wigginton and some others at Apple made some needed revisions to Applesoft. Using a cross-assembler running on a North Star Horizon (Z-80) microcomputer, they fixed the known bugs and added other commands to control features unique to the AppleII. These commands included the ones needed to draw and manipulate hi-res graphics. Also, the lo-res graphics commands were renamed to be more consistent with the equivalent commands in Integer BASIC (GR, HLIN, VLIN, etc.) This version was called "ApplesoftII", and eventually it was available in five forms: Cassette RAM and Diskette RAM (which loaded to the same memory locations that interfered with hi-res graphics as did ApplesoftI), Firmware card ROM, Language card RAM, and finally main board ROM (in the AppleII Plus). When ApplesoftII was started up from cassette or diskette versions, the display screen now showed a copyright date of 1978 by Apple Computer, Inc., and 1976 by Microsoft (which may be either their copyright date for the original Microsoft BASIC, or possibly for Microsoft's first 6502 version).<6> This RAM version of ApplesoftII used memory from $800-$2FFF, and the Applesoft BASIC program itself was loaded beginning at $3000. When the versions that came on ROM and for the Language Card RAM were released, the BASIC program could load at $800, and much more memory was available for it. Some of this extra space (in high memory) was reclaimed by DOS when the Disk II was released, however.<5> Applesoft in the original IIe was unchanged from the II Plus version. When the IIc was introduced in 1984, however, Apple programmers had cautiously made a few useful changes to the language: o Input processing was changed to allow lowercase entry of Applesoft commands (they were translated into uppercase) o Screen output commands (PRINT, TAB, HTAB, etc.) were modified to more properly handle the 80-column screen o Program lines (when LISTed) were changed to begin in column 2, making screen editing easier o All of the cassette tape routines (LOAD, SAVE, SHLOAD, STORE, and RECALL) were removed, since the hardware did not support cassette I/O. The keywords were still in the token table, but now pointed to the same memory vector as the ampersand ("&") command. o Patches were made to the lo-res graphics commands (GR, HLIN, VLIN, PLOT, and SCRN) to work with double lo-res graphics. However, a bug was introduced that allowed PLOTting vertically to areas outside of the double lo-res graphics screen, which would land right in the beginning of the $800 space where the Applesoft program text was located (similar to the "plot" bug in ApplesoftI). When the AppleIIe Enhanced ROMs were made available, Applesoft in those ROMs had undergone some similar modifications. All the above IIc changes were added, with the exception that double lo-res graphics capability was not added (lack of ROM space), and the cassette I/O commands were not removed (since the cassette input and output port was still present). The version of Applesoft on the AppleIIGS closely resembled the AppleIIc variant, the only exception being a fix of the double lo-res PLOTting bug. However, a bug in the SCRN function that applied to double lo-res mode was not fixed. No changes to Applesoft from the IIc version appeared in the AppleIIc Plus.<9> The manuals written for ApplesoftII were far more comprehensive than either the older "Blue book" or the Integer BASIC manual. It gave not only programming examples for each of the commands, but included much more information about the various ways in which each Applesoft statement could be used. It also mentioned some of the differences between Applesoft and Integer (for those who wanted to convert their older programs), and gave a little information about the internals of Applesoft to aid in creating machine language additions to the language. Curiously, the manuals that have been reprinted even as late as 1990 by Addison-Wesley have included an odd cautionary note to programmers. In a section in the index about "reserved words" (words reserved as Applesoft commands), it advises against using "XPLOT" as a variable name, stating that "it is a reserved word that does not correspond to a current Applesoft statement." What is apparently meant by this comment is that at one time Apple intended to extend the language and add another command "XPLOT" to it, probably working with HPLOT in the same way that XDRAW complements DRAW in doing hi-res graphics. Examination of the command table within the Applesoft interpreter shows thereis no entry labeled "XPLOT", and a disassembly of the interpreter shows no preliminary code to support the command. Somehow this precaution persisted to the present day and has never been removed, even though it is extremely unlikely that Applesoft will ever be upgraded.<10> Particularly helpful for programmers was the foresight to include a simple extension called the "ampersand hook". If Applesoft came across the "&" symbol while interpreting a line, it jumped to a known location in memory and left it to the programmer to insert the correct code to add a machine language extension to the language. With the publication of important information about the internals of Applesoft in 1980, assembly language programmers could now add statements to do things that could not be done with the language as it was originally created. Music, extended graphics, IF-THEN-ELSE logic, and even the missing "XPLOT" command could be added to the language. The only limits were the author's imagination (and available memory). The importance of Applesoft as an influence to productivity on the AppleII cannot be overstated. Since the release of the AppleII Plus in 1979, every variety of AppleII has contained Applesoft in virtually an unchanged form. This has made it possible for anybody to write programs that all other AppleII users will be able to use, since the language does not have to be purchased or added. If there were thousands of Integer BASIC programs from the two years when Integer AppleII's were produced exclusively, there are hundreds of thousands of Applesoft programs that appeared over that subsequent thirteen years. Even today, it is not uncommon for an applications program to include a configuration module written in Applesoft using the disk commands available with BASIC.SYSTEM in ProDOS. It is often faster to write such a program in BASIC, and the author knows without a doubt that his customer will be able to run it. APPLESOFT 3 (?) In 1979 there were rumors at the West Coast Computer Faire about an enhancement to ApplesoftII that was in the works at Apple. It would possibly be called Applesoft3, and would be as much of an enhancement over ApplesoftII as that version was to ApplesoftI. Supposedly it was intended to merge DOS and BASIC, and would include such powerful functions as IF-THEN-ELSE, PRINT USING, WINDOW, and VIEW PORT. It was predicted to be a RAM version only, and would be about 24K in size. Knowing the events that actually followed, this rumored BASIC was probably the "Business Basic" released with the AppleIII, rather than an enhancement for the AppleII.<11> +++++++++++++++++++++++++++++++++++ NEXT INSTALLMENT: Languages, cont. +++++++++++++++++++++++++++++++++++ NOTES <1> Doms, Dennis. "KansasFest 1991", A2-Central, Sep 1991, p. 7.57. <2> -----. (ad), PEEKing At Call-A.P.P.L.E., Vol 2, 1979, p. 62. <3> -----. AppleII BASIC Programming Manual, 1978, 1979, 1980, 1981. <4> Chien, Philip. "The First Ten Years: A Look Back", The AppleII Review, Fall/Winter 1986, p. 12. <5> Golding, Val J. "Applesoft From Bottom To Top", Call-A.P.P.L.E. In Depth #1, 1981, p. 8. <6> Bernsten, Jeff. GEnie, A2 Roundtable, Apr 1991, Category 2, Topic 16. <7> Arkley, John. (personal telephone call), Sep 9, 1991. <8> -----. "Apple Patches", PEEKing At Call-A.P.P.L.E., Vol 1, 1978, p. 40. <9> Weyhrich, Steven. "Applesoft Miscellaneous Information", Applesoft Concordance v1.0, Dec 1989. <10> Kamins, Scott. "Appendix D Reserved Words", Applesoft BASIC Programmer's Reference Manual, 1982, 1983. <11> Aldrich, Darrell. "The Computer Faire And The Apple", PEEKing At Call-A.P.P.L.E., Vol 2, 1979, p. 158.