1. Directory
  2. Apple II Textfiles
  3. aht.03.v1.1
===== == =======

Compiled and written by Steven Weyhrich
(C) Copyright 1991, Zonker Software

[v1.1 :: 12 Dec 91]


     Moving our time machine on to 1977, we can now look at Steve Wozniak's next generation Apple.  Even as the AppleI was completed and was slowly selling, Wozniak was already working on making enhancements that would make his computer faster and more functional.  He wanted to make it display in color.  He worked to combine the terminal and memory functions of the AppleI by moving the display into main memory, allowing instant screen changes.  Many of his changes were not added with the end user specifically in mind.  Wozniak stated:

"A lot of features of the AppleII went in because I had designed Breakout for Atari.  I had designed it in hardware.  I wanted to write it in software now.  So that was the reason that color was added in first--so that games could be programmed.  I sat down one night and tried to put it into BASIC.  Fortunately I had written the BASIC myself, so I just burned some new ROMs with line drawing commands, color changing commands, and various BASIC commands that would plot in color.  I got this ball bouncing around, and I said, 'Well it needs sound,' and I had to add a speaker to the AppleII.  It wasn't planned, it was just accidental... Obviously you need paddles, so I had to scratch my head and design a simple minimum-chip paddle circuit, and put on some paddles.  So a lot of these features that really made the AppleII stand out in its day came from a game, and the fun features that were built in were only to do one pet project, which was to program a BASIC version of Breakout and show it off at the club."<1>

     Wozniak added other features that he felt were important for a computer that was useful, one that he would want to own.  Since the 6502 processor could address a total of 64K of memory, he designed the computer with the ability to use either 4K RAM chips, or the newer (and more expensive) 16K RAM chips.  The first AppleII's came standard with 4K of memory, and more could be added, to a maximum of 12K (if using the 4K chips) or 48K (if using the 16K chips).  Specially wired strapping blocks attached to the motherboard told the AppleII how much memory was present and where it was.  According to the 1981 edition of the APPLE II REFERENCE MANUAL, the Apple could have memory in the following sizes: 4K, 8K, 12K, 16K, 20K, 24K, 32K, 36K, or a full 48K.  (These sizes were determined by the different ways that three RAM chips, either 4K or 16K, could be installed).  The strapping blocks were even designed with the flexibility of allowing blank spots in memory if there were no RAM chips available to fill those spots.
     The first 4K of memory always had to have RAM present, since it was used by the 6502 processor, the ROM routines, and the text screen display.  If, for example, you only had two other 4K RAM chips to install and you wanted to display hi-res graphics, you could strap one chip to the lower half of hi-res memory from $2000-$2FFF, and the other to the upper half of hi-res memory from $3000-$3FFF.<2>  Since 16K RAM chips cost about $500 when Wozniak designed the AppleII, not many users could afford them.  Whereas the Commodore PET and the Radio Shack TRS-80 could not easily be expanded beyond the 4K they came with, the AppleII from the beginning was designed with expansion in mind.<3>
     The row of eight expansion slots was another feature about the AppleII that was a strong selling point.  Unlike the TRS-80 or PET, you could easily expand the AppleII by simply plugging a card into one of these slots.  This degree of expandability made it more expensive to build, however.  Steve Jobs didn't believe that anyone would ever need more than two slots, one for a printer and one possibly for a modem.  Wozniak knew from his experience with computers at Hewlett-Packard that computer users would always find SOMETHING to fill those extra slots, and insisted that they keep the number at eight.<4>
     One problem Apple had to deal with was getting FCC approval for the computer.  The RF (radio frequency) modulator that had been designed gave off too much interference, and it was probable that the FCC would not approve it.  (The RF modulator allowed a user to attach the Apple to a standard television receiver, instead of requiring the purchase of an expensive computer monitor).  Rather than have the release of the AppleII delayed for re-engineering of the RF modulator to get that FCC approval, Apple gave the specifications for the RF modulator to Marty Spergel.  He ran a small company (called M&R Electronics) that specialized in obtaining hard-to-get parts that electronics and computer hackers wanted for their projects.  Their agreement allowed M&R to make and sell the RF modulators, while Apple could concentrate on making and selling the AppleII.  Dealers would sell an AppleII with a "Sup'r Mod" (costing about $30) if the buyer wanted to see the graphics on their color TV.  Jobs assured Spergel that the item would sell well, maybe as many as fifty units a month.  (Years later Spergel estimated that he had sold about four hundred thousand Sup'r Mods).<5>
     Other features that Wozniak (and Allen Baum, who helped him with the project) included in the AppleII ROMs included the terminal software to do screen text display, expanded Monitor functionality, and cassette input/output routines.  They added the ability to split the screen into different sized windows.  They also wrote a disassembler, which was one of the most important features of the AppleII from the beginning and a significant part of its open design.  It allowed ANYONE to view the 6502 code that ANY program used, and matched the philosophy of the Homebrew Club of making all computer knowledge available to everybody.  In the AppleI days, when Apple was supplying software "free or at minimal charge", Wozniak and Baum published an early version of their 6502 disassembler in a hacker's magazine.  It was designed to be loaded in memory on the AppleI from $800 to $9D8 and the routine could be executed from the monitor.  This early code was quit similar to the disassembler that was later included in the AppleII ROM.<6>
     Having an expanded Monitor program in ROM and color graphics were not the only features in the AppleII that attracted people to it.  Having Wozniak's BASIC language in ROM, available immediately when the power was turned on, made it possible for non-hackers to write programs that used the AppleII's color graphics.
     An interesting bit of trivia about Wozniak's Integer BASIC was that he never had an assembly language source file for it.  He wrote it in machine language, assembling it by hand on paper:

"I wrote this BASIC processor, and I wrote a little ALGOL simulator and got it simulated.  It looked like it would work, but I had forgotten to build the machine.  I had no assembler, that was another thing.  To use an assembler, they figured that somebody was going to buy this processor [the 6502] to use for a company, and their company can pay a few thousand dollars in time-sharing charges to use an assembler that was available in time-share.  I didn't have any money like that, so a friend taught me that you just sort of look at each instruction, you write your instructions on the right side of the page, you write the addresses over on the left side, and you then look up the hex data for each instruction--you could assemble it yourself.  So I would just sit there and assemble it myself.  The [Integer] BASIC, which we shipped with the first AppleII's, was never assembled--ever.  There was one handwritten copy, all handwritten, all hand-assembled.  So we were in an era that we could not afford tools."<7>

     Even to this day there is not an official source code listing of Integer BASIC at Apple.  And interestingly, the only error I am aware of in the Integer interpreter is one involving a single byte.  If a line is entered that has too many parentheses, the "TOO LONG" error message is displayed instead of the "TOO MANY PARENS" message.<8>


     I want to take a short break in this discussion of the AppleII firmware to look at some other items that will make further descriptions easier to understand.  If you are a programmer already, you may want to skip this section, since you probably already know this stuff.  First we will examine some definitions of terms that are commonly known to programmers, but possibly not to you.  Next will be a brief excursion into the realm of hexadecimal, and finally a look at the memory map of the original AppleII.
     First, let's look at definitions of some words that I have been loosely throwing around:

BIT            The smallest piece of information that a computer can deal with, it is either a "0" (off, clear) or a "1" (on, set).
BYTE           The most convenient piece of information (for humans) that computers use.  One byte consists of eight bits, and ranges from "00000000" (0 decimal) to "11111111" (255 decimal).
NIBBLE         (also spelled "nybble").  One half of a byte, consisting of four bits, ranging from "0000" (0 decimal) to "1111" (15 decimal).
WORD           Two bytes (or four nibbles, if you prefer), consisting of sixteen bits, and ranging from "00000000 00000000" (0 decimal) to "11111111 11111111" (65535 decimal).  Not used much in microcomputers.
BINARY         A system of counting using only two digits, "0" and "1" (base 2).  Computers speak in binary at their most basic level; anything else is translated into binary, so the computer can understand it.
DECIMAL        A system of counting using ten digits, "0" through "9" (base 10).  Most of the Western world uses this system.
HEXADECIMAL    A system of counting using sixteen digits, "0" through "9" and "A" through "F" (base 16).  Programmers use this system as a convenient way of organizing groups of binary numbers.
KILOBYTE       Abbreviated "K", "KB", or "Kbytes", it refers to 1,024 bytes. A 64K computer has 64 x 1024 = 65536 bytes.
MEGABYTE       Abbreviated "M", "MB", or "meg", it refers to 1,024 Kbytes, or 1,024 x 1,024 = 1,048,576 bytes.  A 32 MB hard disk, the largest size volume that ProDOS can handle, holds 32 x 1,024 = 32,768 Kbytes, or 32 x 1,024 x 1,024 = 33,554,432 bytes.
GIGABYTE       Abbreviated "G", "GB", or "gig", it refers to 1,024 MB, or 1,048,576 Kbytes, or 10,737,441,824 bytes.  The AppleII Smartport (which will be mentioned later in this history) can handle disk devices up to 4 gig in size (although the software to handle that type of size has yet to be written).
RAM            Random Access Memory.  Any data stored in this memory disappears when the computer is turned off.
ROM            Read Only Memory.  Data cannot be stored in this type of memory, but instead it usually contains programs or other information that does not disappear when the computer is turned off.
HARDWARE       The physical electronic components and mechanical parts that make up a piece of computer equipment.  Examples would be the keyboard, disk drive, or television monitor (also called CRT, or Cathode Ray Tube).
SOFTWARE       The digital instructions executed by the computer in RAM.  They may act on the hardware that is attached to the computer.  Examples would be a BASIC or Pascal program, an assembly language routine to read a clock, or a disk operating system.  Since software is executed in RAM, it disappears from memory when the computer is turned off.
FIRMWARE       The same as software, except it is executed from ROM, and does not disappear when the computer is turned off.  Almost any software could be in ROM, except programs that modify themselves as they run.

     Next, let's look at hexadecimal numbers in more detail.  Since computers deal in binary (base 2), the true language of computers is either in terms of "0" (off) or "1" (on).  However, it quickly becomes cumbersome to refer to large numbers in binary; the base 10 number "458" is "111001010" in binary.  So programmers have decided to group numbers in such a way as to make it easy to convert part or all of that number to binary if necessary, but still have numbers (almost) as easy to deal with as our standard base 10 system.
     Now, in the familiar base 10 system there are ten digits, 0 through 9.  When counting, after you pass 9, you add one to the digit to the left of the 9, change the 9 to a 0, and continue.  So, "09" becomes "10", "19" becomes "20", and so on.  However, in the base 16 system there are sixteen digits, 0 through 9, and then A through F (representing decimal 10 through 15).  When counting, then, you go 7, 8, 9, then A (not 10), B, C, D, E, F, 10, 11, 12, and so on.  In the Apple world we have traditionally used a preceding dollar sign to signify a hexadecimal number, so "25" means twenty-five, but "$25" means thirty-seven (2 x 16, plus 5).  To translate a hexadecimal number to decimal, use powers of 16:

   $B65F = (11 x 16^3)  +  (6 x 16^2)  +  (5 x 16^1)  +  (15 x 16^0)
         = (11 x 4096)  +  (6 x 256)   +  (5 x 16)    +  (15 x 1)
         = 45056        +  1536        +  80          +  15
         = 46687

     The same thing can be done in reverse to convert base 10 to hexadecimal, starting by dividing the number by 4096, then the remainder by 256, then 16.  If the number is greater than 65536, you need a bigger power of 16 (and you are probably not dealing with an 8-bit AppleII!)  Or you can just get a programmer's calculator like mine that automatically does the conversion for you...
     When dealing with memory addresses on an AppleII, we usually designate them as four digit hex numbers (such as the $B65F example above).  Numbers less than $1000 often are printed without the leading blank ($400 instead of $0400), and numbers less than $100 are treated the same way ($32 instead of $0032).


     To understand the memory layout of the AppleII, consider this analogy:  Imagine a cabinet with sixteen shelves, and sixteen separate slots or pigeon holes on each shelf (similar to those found in old roll-top desks).  Each slot refers to a specific address in memory on the computer, and each slot can hold a number between 0 and 255.  (Since a byte is eight bits wide, the largest number that can be represented by eight binary bits is 255).  The bottom shelf is row "0", and the leftmost slot in that row is slot "0".  The address of that slot, then, is $00.  As we move to the right, the addresses increase, $01, $02, $03, and so on to $0F at the end.  We then go up to the next row, (row "1"), and the addresses continue in the same fashion with $10, $11, $12, and so on as before.  The sixteenth row is row "F", the rightmost slot in that row is slot "F", and the address of that slot is $FF.  This cabinet has, then, 256 slots (16 x 16), and represents what is called a "page" in the Apple memory.  The cabinet itself has an address (since computers need addresses for everything), and this one's address is "00".  The full address of row "5", slot "A" on cabinet "00" is $005A.
     Only the Altair 8800 came with just 256 bytes of memory, so we have to account for the entire 64K memory space that the 6502 chip in the AppleII can handle.  There is a cabinet sitting on top of cabinet "00", and it is laid out in the same fashion with its 256 slots in sixteen rows.  This is cabinet "01", and on top of that one is cabinet "02"; this continues on up until we reach cabinet "FF" way up at the top.  Apple programmers refer to these cabinets as "pages" of memory.  There are 256 pages of memory, each with 256 bytes on a page, making a grand total of 256 x 256 = 65536 bytes of memory (or slots that can hold a number, if you prefer the analogy).
     In discussing the memory map on the AppleII, we can refer to pages of memory with a hexadecimal two-digit number for shorthand if we wish.  The general layout of the AppleII memory is as follows:

     Page $00: used by the 6502 processor for storage of information that it can access quickly.  This is prime real-estate that is seldom available for general use by programmers without special care.
     Page $01: used by the 6502 for internal operations as a "stack."
     Page $02: used by the AppleII firmware as an input buffer when using the keyboard from BASIC, or when a program uses any of the firmware input routines.
     Page $03: general storage area, up to the top three rows (from $3D0 through $3FF) which are used by the disk operating system and the firmware for pointers to internal routines.
Pages $04-$07: used for the 40 column text screen.
Pages $08-$BF: available for use by programs, operating systems, and for hi-res graphics.  Within this space, Woz designated pages $20-$3F for hi-res "page" one, and pages $40-$5F for hi-res "page" two.
     Page $C0: internal I/O and softswitches
Pages $C1-$C7: ROM assigned to each of the seven peripheral cards
Pages $C8-$CF: switchable ROM available for any of the seven cards
Pages $D0-$D7: empty ROM socket #1
Pages $D8-$DF: empty ROM socket #2
Pages $E0-$F7: Integer BASIC ROM
Pages $F8-$FF: Monitor ROM

     The memory space on the AppleII between $C000 and $CFFF was assigned to handle input and output.  From $C000 to $C0FF the space was reserved for various soft-switches used to control the display, and various built-in I/O devices, such as the keyboard, paddles, annunciators, and the cassette port.  (A soft-switch is simply a memory location that, when a number is stored there, changes something in the computer--such as switching on graphics mode).  From $C100 to $CFFF the space was reserved for ROM on the plug-in peripheral cards for each of the seven slots.  Slot 1 was given the space from $C100 to $C1FF, slot 2 from $C200 to $C2FF, and so on.  The $C800 to $CFFF space was special slot-selectable ROM that was uniquely available for each of the seven peripheral cards.  For example, a program running on the card in slot 6 to control a device could use the $C800-$CFFF space for its own purpose.  When control passed to the card in slot 3, that card could use a program of its own that ran in the same $C800-$CFFF space.  This was accomplished by allowing each card to have ROM code that covered pages $C8-$CF, and making that space "switchable", depending on which card wanted to use it.  Having this space available made writing ROM code simpler, since it would not have to be capable of running at various memory locations (depending on which slot a card was plugged into).
     The memory from $D000 to $D7FF and $D800 to $DFFF was empty on all early AppleII computers.  On the motherboard were two empty sockets that were available for the user to plug in their own ROM chips.  The $D000-$D7FF space was most often used by a plug-in ROM chip sold by Apple, known as "Programmer's Aid #1."  It contained various utilities for Integer BASIC programmers, including machine language routines to do the following:

     Renumber BASIC programs
     Append one BASIC program to the end of another
     Verify a BASIC program that had been saved on tape (to confirm it was an accurate save)
     Verify non-program data that had been saved on tape
     Relocate assembly language routines to a different location in memory (most would only run in one place in memory)
     Test the AppleII RAM
     Generate musical tones through the built-in speaker
     Handle hi-res graphics from BASIC, including code to clear the hi-res screen, set colors, plot points and lines, draw shapes, and load shapes from tape.

     All the routines on the Programmer's Aid #1 ROM were written by Wozniak between June 1977 (the RAM test routine) and April 1978 (program renumber and append), except for the music routine, which was written by Gary Shannon.
     The other empty ROM socket (covering memory from $D800 to $DFFF) was never filled by Apple.  Various third-party vendors sold ROMs for that socket (or for the $D000-$D7FF socket used by the Programmer's Aid #1 ROM), but none made enough of an inroad to be preserved in the INTBASIC file that would later be included on the DOS 3.3 System Master disk.  In fact, the $D800-$DFFF space in the INTBASIC file on that disk contains an image of that same space taken directly from the Applesoft ROM!  It is completely useless to Integer BASIC, of course, but disk files being what they are, Apple had to fill that space with SOMETHING!
     The Integer BASIC interpreter lived in the ROM space between $E000 and $F7FF.  However, BASIC only used the space up to $F424.  Between $F425-$F4FB and $F63D-$F65D could be found a floating-point math package that was not used by Integer BASIC, but was available for BASIC programmers who were astute enough to figure out how it worked.  (An early Apple user group, the Apple Pugetsound Program Library Exchange, or A.P.P.L.E., sold a tape and notes by Steve Wozniak they called "Wozpak", that documented some of the secrets of the Integer BASIC ROM).  Between $F500-$F63C there was code that was known as the "miniassembler", which was executed starting at the ominous address $F666.  The miniassembler allowed you to enter short machine language programs using the standard 6502 mnemonics (the three letter codes that referred to a specific type of operation; for example, "LDA #" represented the 6502 opcode $A9) instead of entering the program byte by byte in the monitor.  The $F689-$F7FC space contained Woz's SWEET16 interpreter.  Wozniak wrote SWEET16 to simulate a 16-bit processor; it simplified some routines he wrote for the AppleII ROMs, including the Programmer's Aid #1 renumber, append, and relocate routines.  Simply put, he took a series of hex bytes, defined them as "opcodes" the way HE wanted them to function, and when executing the code used his SWEET16 interpreter to translate the code into legal 6502 operations.  It ran slower than standard 6502 code, but when memory space was at a premium it was better to have a slow program than to not have enough room for the program at all.
     For those who are keeping count, there are a few unreferenced bytes in the latter part of the Integer ROM.  Those bytes contained filler bytes that were not used as any program code.<9>,<10>,<11>
     The last part of the AppleII memory, from $F800-$FFFF, contained Wozniak's Monitor program which has already been discussed above.


NEXT INSTALLMENT:  The Apple II, cont.



     <1> Jack Connick, "...And Then There Was Apple", CALL-A.P.P.L.E., Oct 1986, p. 24.

     <2> -----, "Memory Organization", APPLE II REFERENCE MANUAL, 1979, 1981, pp. 70-73.

     <3> Val J. Golding, "Applesoft From Bottom To Top", CALL-A.P.P.L.E. IN DEPTH #1, 1981, p. 8.

     <4> Michael Moritz, THE LITTLE KINGDOM, p. 157.

     <5> Steven Levy, HACKERS: HEROES OF THE COMPUTER REVOLUTION, pp. 260-261.

     <6> Steve Wozniak and Allen Baum, "A 6502 Disassembler From Apple", Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Sep 1976, pp. 22-25.

     <7> Jack Connick, p. 23.

     <8> Christopher Volpe, "Beep: A Tale of (T)ERROR", CALL-A.P.P.L.E., Mar 1983, p. 114.

     <9> Bob Bragner, "Open Discussion", SOFTALK, Nov 1983, pp. 51-52.

     <10> -----, PROGRAMMER'S AID #1, 1978.

     <11> Dick Sedgewick, "SWEET 16 - Introduction", MERLIN USER'S MANUAL, 1982, pp. 103-109.


AAAAH! MY EYES! Click here if you prefer a black and white color scheme.