3-The Apple II

CONTENTS
Hardware and Firmware
Memory Map
Notes

 

Apple II, Panasonic RQ-2102 cassette, and TV

Apple II, Panasonic RQ-2102 cassette, and TV – Photo credit: Carl Knoblock, Phil Pfeiffer

HARDWARE AND FIRMWARE

No hacker is completely satisfied with a project he is working on as long as it is possible to make improvements that make it better in some way. After Wozniak had completed design on the Apple-1, he already had in mind 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 Apple-1 by moving the display into main memory, allowing instant screen changes. None of these modifications were made specifically to make it a better product, or to make it more attractive for a customer to purchase. Wozniak stated:

A lot of features of the Apple II 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 Apple II. 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 Apple II 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 available Apple II computers 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 Apple II 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.

Apple II RAM array

Apple II standard RAM array — Photo credit: Scot Krayenhagen

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 Apple II, 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 Apple II from the beginning was designed with expansion in mind.[3]

The row of eight expansion slots was another feature about the Apple II that was a strong selling point. Unlike the TRS-80 or PET, you could easily expand the Apple II 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]

Sup'R'Mod

Sup’R’Mod

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 Apple II 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 Apple II. Dealers would sell an Apple II 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 Apple II 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 Apple II 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 Apple-1 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 Apple-1 from $800 to $9D8 and the routine could be executed from the monitor. This early code was quite similar to the disassembler that was later included in the Apple II ROM.[6]

Having an expanded Monitor program in ROM and color graphics were not the only features in the Apple II 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 Apple II 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 Apple II’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]

There never was an official source code listing of Integer BASIC at Apple. One of the few errors 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] Another error involved a FOR – NEXT loop too deeply nested (that is, having a FOR – NEXT loop within another FOR – NEXT loop). If the program repeatedly entered the beginning of the loop without hitting the NEXT statement, it would eventually cause a crash.[9]

MEMORY MAP

To understand the memory layout of the Apple II, consider this analogy: Imagine a cabinet with sixteen shelves, and sixteen separate slots or pigeonholes 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 top 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 down 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, and the value that is at that location (in this example) is “6F”.

Page 00
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 . . . . . . . . . . . . . . . .
1 . . . . . . . . . . . . . . . .
2 . . . . . . . . . . . . . . . .
3 . . . . . . . . . . . . . . . .
4 . . . . . . . . . . . . . . . .
5 . . . . . . . . . . 6F . . . . .
6 . . . . . . . . . . . . . . . .
7 . . . . . . . . . . . . . . . .
8 . . . . . . . . . . . . . . . .
9 . . . . . . . . . . . . . . . .
A . . . . . . . . . . . . . . . .
B . . . . . . . . . . . . . . . .
C . . . . . . . . . . . . . . . .
D . . . . . . . . . . . . . . . .
E . . . . . . . . . . . . . . . .
F . . . . . . . . . . . . . . . .

 

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 Apple II 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 Apple II, we can refer to pages of memory with a hexadecimal two-digit number for shorthand if we wish. The general layout of the Apple II memory is as follows:

RAM Organization and Usage
Page #
Dec Hex
Used for:
0 $00
System Programs
1 $01
System Stack
2 $02
Input Buffer
3 $03
Monitor Vector Locations
4 $04
5 $05
6 $06
7 $07
Text/Lo-Res Graphics
Primary Page Storage
8 $08
9 $09
10 $0A
11 $0B
Text/Lo-Res Graphics
Secondary Page Storage
FREE RAM
12 $0C
through
31 $1F
FREE RAM
32 $20
through
63 $3F
Hi-Res Graphics
Primary Page
Storage
FREE RAM
64 $40
through
95 $5F
Hi-Res Graphics
Seconary Page
Storage
FREE RAM
96 $60
through
191 $BF
FREE RAM
192 $C0
I/O and softswitches
193 $C1
through
199 $C7
I/O shared ROM space

 

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 Apple II 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 $08-$0A as a secondary text and lo-res graphics page (although it was not easy to directly use, as the firmware did not support it), pages $20-$3F for hi-res “page” one, and pages $40-$5F for hi-res “page” two.
Page $C0: internal I/O and soft-switches
Pages $C1-$C7: ROM assigned to each of the seven peripheral cards
Pages $C8-$CF: switchable ROM available for each 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 Apple II 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.) The remainder of the memory locations for $C100 to $CFFF was reserved for use with the peripheral cards plugged into the slots. Each card was assigned 256 bytes that were unique for the slot in which the card was plugged; that is, a card in slot 1 used $C100-$C1FF, a card in slot 2 used $C200-$C2FF, and so on, up to slot 7 using $C700-$C7FF. Code written on a card was ordinarily written in such a way as to not make direct reference to the $Cx address, so it would work in any slot in which the card happened to be used.

Therefore, each slot had an additional 2K of ROM space to use, the space from $C800 to $CFFF was switched in for each card when it was being used. A hardware flag on each card could be set to indicate that code in that memory space would be used for that card. This hardware flag is set when the input/output line on that card is selected (though it does not apply to a card used in slot 0). When the address $CFFF is accessed, this hardware flag is reset, making the $C800-$CFFF space available to other cards. Often, code on a card would be written to hit this memory location before trying to use it, to be sure it had been disabled from the last card that used that space.

The memory from $D000 to $D7FF and $D800 to $DFFF was empty on all early Apple II 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 Apple II 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.

Programmer’s Aid ROM #1 manual – Photo Credit: Yuki Takahashi’s Apple-II Tree

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 these 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 instead of entering the program byte by byte in the monitor. (These mnemonics were the three letter codes that referred to a specific type of operation; for example, “LDA #” represented the 6502 opcode $A9.) The $F689-$F7FC space contained Woz’s SWEET 16 interpreter. Wozniak wrote SWEET 16 to simulate a 16-bit processor; it simplified some routines he wrote for the Apple II 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 SWEET 16 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.[10],[11],[12]

The last part of the Apple II memory, from $F800-$FFFF, contained Wozniak’s Monitor program which has already been discussed above.

NOTES

  1. [1] Connick, Jack. “…And Then There Was Apple.” Call-A.P.P.L.E. Oct 1986: 24.
  2. [2] —–, “Memory Organization”, Apple II Reference Manual. Cupertino, CA, Apple Computer, Inc., 1979, 1981: 70-73.
  3. [3] Golding ,Val J. “Applesoft From Bottom To Top.” Call-A.P.P.L.E. In Depth #1 1981: 8.
  4. [4] Moritz, Michael. The Little Kingdom. New York, William Morrow and Company, Inc, 1984: 157.
  5. [5] Levy, Steven. Hackers: Heroes Of The Computer Revolution. New York, Dell Publishing Co., Inc, 1984: 260-261.
  6. [6] Wozniak, Steve and Allen Baum. “A 6502 Disassembler From Apple.” Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia Sep 1976: 22-25.
  7. [7] Connick, Jack: 23.
  8. [8] Volpe, Christopher. “Beep: A Tale of (T)ERROR.” Call-A.P.P.L.E. Mar 1983: 114.
  9. [9] Aaronson, Tim. Email, 8 Nov 1999.
  10. [10] —–. Programmer’s Aid #1 Cupertino, CA, Apple Computer, Inc., 1978.
  11. [11] Sedgewick, Dick. “SWEET 16 – Introduction.” Merlin Users Manual San Diego, CA, Southwestern Data Systems, 1982: 103-109.
  12. [12] Aaronson, Tim. Email, 8 Nov 1999.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

12 Responses

  1. 1
    Henry Heffner August 4th, 2010 at 12:25 pm

    As a researcher, I started using the Apple II around 1980. I still use it in my lab at the University of Toledo–2010. I have 3 workstations, each with two Apple II computer to control experiments.
    Program Line Editor was a god-send. My programs are in Integer Basic because it runs faster–I have speedup (Zip) chips in most of my computer. Some computer use the 16-bit pin-for-pin compatible chip.
    I modify my old programs that were written over 20 years ago–yes, there is some dead code in my current programs.
    I should write a history of it all some day, complete with photos.

  2. 2
    Greenmachine October 8th, 2011 at 5:04 pm

    The reason I live in Silicon Valley today can be directly traced to the fact that in 1979 my Dad brought home for the weekend an Apple II and the Basic manual. I was 10 years old, and lived in South Africa. It had come alongside some Varian analytical chemistry equipment he was working with. Most of those machines used mini-computers the size of small refrigerators, but one of the newer ones was controlled by an Apple II.

    I had never seen anything like it. You could not buy such things in South Africa. It did absolutley nothing, so I opened the manual and wrote a basic program that looped “Hello, world.” endlessly on the screen. I spent the weekend going through the manual and trying out every function possible. Later he brought home some of the storage units, and shortly after we got the first floppy disk and you could get some games like flight simulator.

    Because Pixar and the iXxx products are more recent, most of the reminiscing is about Steve Jobs’ later work. But for us old timers, the Apple II was revolutionary. It’s like telling the story of Alexander Graham Bell’s later life and forgetting to mention he invented the telephone. Apple II was the first viable home computer. Although many of the elements were already there as shown by this wonderful website, Woz and Jobs somehow put it all together and made the first viable practical home computer, what later came to be called the PC. Everyone seems to forget that the PC was developed by IBM in a rush program in response to the success of the Apple II.

    Steve Jobs should be remembered first and foremost as the co-inventor of the PC, and everything that came after such as the internet, facebook, mobile computing, messaging, graphics were all natural evolutions once you put a computer in every household. It is one of the seminal inventions of the last 200 years of human history, alongside the lightbulb, telephone, telegraph, airplane and transistor. And in a rare case where the reality lived up to the legendary show-man’s hype, it truly was “Revolutionary”.

  3. 3
    Michael Mileham October 8th, 2011 at 6:27 pm

    How many original 4k apple ][s were sold?

  4. 4
    Steven October 8th, 2011 at 7:54 pm

    Unfortunately, Apple has never released any sales figures in detail for those early years, so it would be a guess to come up with a total.

  5. 5
    Dowe Keller December 19th, 2011 at 5:18 am

    I may be miss-remembering, but to toggle a soft-switch all you had to do was access the location, not necessarily write to it. In the case of toggling the speaker, storing would often produce no sound, where as loading would generate a click every time.

  6. 6
    Steven December 19th, 2011 at 10:26 am

    With the $C030 soft-switch for the speaker, reading this address would cause a click on the speaker, but writing to the address would give a slightly different effect. This was because when a memory write happens, it first reads the address, and then writes to it.

  7. 7
    John January 13th, 2012 at 5:22 pm

    @Greenmachine – all true, but how about some love for the Woz?

  8. 8
    Alexander March 30th, 2012 at 7:40 pm

    Can you believe now we have GIGABYTES of storage space on our hard drives, while in the olden days they had bytes and kilobytes!

  9. 9
    Simon July 7th, 2013 at 3:40 pm

    I have never found any info about the first Apple II factory or assembly line. Al the books end the chapter with the famous Wst Computer Faire 16 april 1977 and the problems with the plastic case, but nobody tells anything about how they began making the first 1.000 units, 10.000 units, etc.

    Any idea or reference, please?

    Thank you very much!

  10. 10
    Steven July 7th, 2013 at 9:05 pm

    Sorry; information about the actual factory manufacture of the Apple II models is something I don’t have.

  1. 11
    Apple II | Skeptical Humorist (via Pingback)

    [...] technical history is here, and in the comments a researcher says that he is still using 3 Apple IIs for experiments as of [...]

  2. 12
    A Survey of the Apple II Series (via Pingback)

    […] Barely a year after he had provided technology company Apple Inc. with its first product (then known as the Apple Computer, but retroactively known as Apple I) Steve Wozniak was already thinking of a follow-up. The company’s co-founder envisioned a computer that would be faster, more powerful, and better looking than its immediate predecessor. And that computer would be the Apple II. […]

Make a public comment


7 × two =

Protected by WP Anti Spam