Apple I

How to make a personal operating system ?

in
Comment from E-mail

I have emailed you before, and i got so excited that a major player in the computer world awnsered me. So here goes my question. My friend and I want to make our own computer software, We bought an old computer and scraped it, and made a new computer, but we want to make our own operating system, You said you made basic for the Apple 1 and II. What did you us to make it? what type of software, if any would we need to make it with, and is there any hard ware we might need?

Woz

I don't know if these comments will apply, but here they are.

In high school I fell in love with minicomputers, which were basically small computers equivalent to the microprocessors once they came out. Well, I could never afford a minicomputer but I looked at the programming instructions for machine language and tried to write my own short routines. In college I started trying to figure out how compilers, like Fortran, were written. I knew that the compiler program had to read a line at a time and figure it out and convert it to code that the computer could run. So I started writing a routine in assembly language (machine language) that would analyze a line for correctness. But I never could afford a computer to try it on, nor an assembler to type it into. It was just a personal program that nobody else knew about.

After I'd designed a computer, before Apple was even conceived, I decided to write a BASIC for real. I'd never studied how to do this, but I had self trained myself a bit back in college as I described above. I'd never used BASIC but I knew that this was the popular language for games and that was too important to ignore. The first thing I did was get a BASIC manual at Hewlett Packard, where I was working. I read it and made notes and pretty much learned what commands it had. Of course this was Hewlett Packard BASIC. It differed from the Digital Equipment BASIC, that Bill Gates' first BASIC was based on, mostly in some string manipulation. This later turned out to be the greatest difference between my BASIC and theirs. I was tired of MID$, LEFT$, RIGHT$ type functions so I preferred the HP BASIC better (A$(5,7) meant the 5th through 7th characters of A$).

I'd never formally educated myself in the area of compilers and interpreters (compilers translate a program to machine code to run rapidly later, interpreters scan the program and figure it out as it's being run, which results in much slower execution--BASIC is an interpreted language). But I knew how Syntax charts defined the structure and words of a programming language, as you find these in programming manuals. I decided to write down a full Syntax description of my BASIC to begin. I'd never done such a thing, but it wasn't hard and was modeled after others that I could find.

I next decided that I'd actually put this syntax list into memory as part of my BASIC interpreter. It was stored character by character. I figured that I'd just scan the input line, after the user hit Return, character by character, tracing a path through the syntax table and backing and retrying things. If the line made it through the Syntax table then it was good, otherwise it was in error.

The unexplainable part is how I came up with the way my BASIC would actually do what it was supposed to. As BASIC elements were found in the Syntax Table, I generated tokens (codes) for these elements. For example, a left parenthesis might generate token #87. But in another usage, a left parenthesis might generate token #115. It depended on where it was encountered in my Syntax table in memory, the one I was traversing character by character and matching the input line. In an inefficient effort to make my BASIC very tiny and save every possible byte (even the minimal amount of memory for a computer language was very expensive in 1975) I actually counted how many BASIC symbols the 'matched' one was from the start of the syntax table, and used that count as it's token value.

After this step, I generated a line that didn't have to go through the Syntax evaluator again. The Syntax evaluator could be very tiny and run slowly, as it only ran once per line, which took only a fraction of a second for a typical line. When the program ran, it was already half in shape for speed.

Now comes a less explainable part. I had read and heard some things about compilers but I still don't know to this day if what I did was good or bad. As a line executed in a running program, it consisted of numbers (precompiled into constants I think) and variable names and grammar elements like a plus sign token or a left parenthesis token. When, during execution, the BASIC encountered a 'noun' (number or variable) it was pushed onto a noun stack, ready for retrieval. This was like our HP calculators where I worked.

When the BASIC encountered a 'verb' (a token that called for an operation) it would be evaluated in comparison to a verb stack. This was the way of reading a human-written expression from left to right, but doing the operations in a different order (2+3*4 does the multiplication first in most computer languages, even though the plus sign appears first). For each token I assigned 2 priorities. One was the priority to push preceding tokens off the stack for execution. For example, 3 + 7 * 5 would push 3 on the noun stack, + on the verb stack, then 7 on the noun stack (where it's ready to be the first element removed from this first-in last-out stack). When the * is encountered, it had a higher execution priority than + so it didn't pull the 7 and 3 off and add them yet. Instead it pushed the * onto the verb stack and then the 5 onto the noun stack. The end of line was a token with priority to push everything off.

So at this time the * is the 'topmost' token on the verb stack. It comes off and runs a prewritten multiply routine that pulls two items off the noun stack, adds them, and pushes the result back on that noun stack.

Any token that causes others to be executed immediately off the verb stack would keep looking at token priorities until it's own priority was such that it would merely be pushed onto the verb stack and await later execution.

Parentheses bring another factor into play. A left parenthesis is always pushed onto the top of a verb stack, hiding the execution priority of the preceding operator token until a right parenthesis, with extremely high execution priority, causes all tokens to be executed until the left parenthesis is encountered. At that time the right parenthesis has found it's mate and stops forcing ops (tokens) to execute. This is a sort of exception to the concept of a single priority. In addition, the left parenthesis forces no ops off the verb stack, acting as though it has extremely high priority. But no ops force it off, until the right parenthesis, as though it had an extremely low execution priority. So I actually had two priorities for each token, a 'push' tendency and a 'pull' tendency. A verb (token) would only push other verbs off the verb stack and execute them if it's push priority was greater than their pull priority.

I have no idea where these sorts of ideas came from. They just came to me as I needed an elegant solution.

A table held bites with 2 one of zixteen priorities for each token that might be in the interpreted BASIC program. Another table held an address pointer for each token, that pointed to the routine to run when that token was forced to execute. So for each of the dozens of tokens, I had to only write a short routine. This kept the program less complicated and easier to add new commands to.

I couldn't afford an assembler. I wrote the entire program on paper, assigning memory addresses for each program instruction. When I shortened a routine, it was too much trouble to re-write (by hand) a few K-Bytes of code just to shrink the space. So there were many cases of short empty spaces in my BASIC. When a routine needed to expand, I'd usually jump to a patch area where it's latter part was. None of this would have happened if I could have afforded an assembler, which would have packed things properly.

PC '76

in
Comment from E-mail

I was in Atlantic City in 1976 for the PC Expo show at the Shelburne Hotel. I had a SWTPC 6800 so I had no real interest in Apple at the time, but I remember seeing the Apple 1 on display. Were both you and Steve Jobs there? I know I met one of you, but I can't remember who! (or whom LOL). I'd like to be able to tell people who I met. Was this the same one I saw with Lisa Lo*op at VCF 3.0?

Woz

Steve and I were both at PC '76. I mostly stayed in our room, adding to the BASIC. Steve and Daniel Kottke ("Dan" in "Pirates of Silicon Valley") manned the booth, so you could have spoken to either of them. One night Steve and I brought down the very newly built Apple ][ breadboard and hooked it up to the first color projector that we'd ever seen and it worked. The technician at the projector was the only one who saw it and he said that was the computer he was getting, with all the other early computers of the day in the same room. It was a real complement.

The Apple ][ colour controller

in
Comment from E-mail

I was reading slashdot.org today and I saw someone had posted this comment. Is this true? > "Actually, the Apple ][ color controller was an accident! They didn't know it was generating colour until one day they connected it to a colour monitor, rather than a Black&White one, and to their surpise, it was colour...so Woz had to reverse engineer his system to figure out how to control it's colour capabilities."

Woz

That is so so untrue. I dreamed up the method of using pixels on a color TV screen, based on an exact multiple of the color subcarrier frequency, while constructing a [hardware] game for Atari around 1974. I based my [monochrome] 1975 Apple I design on this frequency, intending to add color ability to it later. When I got down to adding the color, I came up with so many circuit optimizations that I designed the Apple ][ instead.

I used such a simple, patented, scheme to generate color that the circuitry doesn't show any direct evidence. It's as though you'd have the same number of chips to generate the video, even without color. But you'd have a tough time explaining a chip or two that gated the color subcarrier frequency during part of the horizontal blanking. It can't be passed off as an accident. Not to mention that you could never even 'see' color on a TV without this subcarrier reference.

Why didn't Apple make the Mac Apple // compatible?

in
Comment from E-mail

Hi Woz! My first experience with computers was in 1982 when I was 12 years old. Shortly after that my Dad bought me an Apple // clone (sorry :) ... The Franklin Ace 1000. I kept that until the ][GS came out and drewled over it (and bought one). I still have it (Woz limited edition). Between 1983 and 1991, my life revolved around the Apple // (I've grown up now and have more important goals in life, such as my wife and children), but at the time, every waking moment was spent hacking my clone or my GS... discovering different softswitches, entry points into ROM, etc... When Apple started wayning in its support the the Apple //, it was extremely discouraging to me and my fellow Apple // "buddies". It seemed that they couldn't actively kill the // line for fear of loss of loyalty, but that they made every effort to let it die a slow death and that it continued to out-sell the Mac for years with absolutely no marketing for the // line. I've always wondered since then what was the reasoning for letting the Apple // die instead of continuiing that line with upgrades so that today, the current Mac would actually be the latest version of the Apple //? I had been hearing rumors at the time that Steve Jobs didn't like the "game" reputation the Apple // had and wanted a "business" competitor and that you were actually more of a // fan and you were the only reason the // line lasted as long as it did. What's the real story behind that? Why didn't Apple make the Mac Apple // compatible? Thanks,Michael Q. (previous graphics editor for GS+ magazine... If you remember that mag?)

Woz

The Apple ][ certainly was an excellent machine to get into the hardware and software and the basic levels of the computer. It made a lot of what a computer is understand to very many like yourself. But Apple's leadership had a very strong direction toward making the geeky parts as hidden as possible. That has it's benefits but it also takes away a very fun part of our lives, figuring out how to do our OWN things.

Apple never was very good at carrying on two lines at one time. Apple actually totally ditched the Apple ][ from 1980 to 1983. Every ad was for the Apple ///. But the Apple ][ was the best selling PC in the world in those years. It was also ignored when the Macintosh arrived because it was not the future and we can't have two high priorities at once. It's just too bad. Even though the Macintosh platform has a low market share, we keep supporting it enough to keep it working. But we didn't do the same for the Apple ][.

I don't have a strong personal 'side' on this issue. But I do receive continual email talking about how much the Apple ][ meant to people that could play with software and entry points and the like.

I don't like Mac programing

in
Comment from E-mail

Well i've been interested in computers since my dad first bought a 386 and at the time it was the most up to date thing available. I never knew much of the history of computers (well not the time of the movie was based). I mastered the BASIC language (seems like ages ago) and have moved on to much more advanced languages.I'm sorry i do tend to drag on. But i just want to say i don't like mac programing but i love the hardware and from what i understand your the man behind it and i just want to say that I can't express in words what i think you've done for the world and inderectly for me. So thank you for your genius. I just want to ask you if you've had an active part in the designing of the new macs. and if you ever had any idea that computers, software, and the internet would ever amount to what it is now.Thank you on behalf of me and everyone at www.archaic.net (still getting out the kinks) :)

Woz

I'm glad that you appreciate the Macintosh hardware, but you're wrong to credit me in any way for it. My hardware design talents were applied to the Apple I and Apple ][ computers and related peripherals. This occured long ago. It was the basis for Apple's start and fame. The Apple ][ kicked off the personal computer recognition, and legitimazed the market. Although I was the sole logic designer and programmer and 'inventor' in this sense, the contributions of others, primarily Steve Jobs, were critical to how this computer struck the world. Without a nicely packaged product in an attractive, acceptable plastic case that said "I'm OK in your home" this product would have died like the other hobby computers for Nerds. Apple was successful not just because of a great piece of hardware but because of the right communications and the complete product (including manuals and ads and our employees and priorities) the world got the message that it was time to change a lot of things in our lives. Steve Jobs truly deserves the visionary credit here. The Macintosh came about in later years and it was truly Steve's project. There were actual hardware and software engineers that did the equivalent of what I'd done on the Apple ][ but I was not among them. At that time I'd returned to college and sponsored some huge rock concerts. (Just to set the record straight for you)

How accurate was the movie?

in
Comment from E-mail

How accurate was the movie when it showed the scene where you and Jobs were at a technology convention and when the doors opened and crowed flushed in, crowding yours and job's booth, which was displaying, Apple I, i believe?

Woz

It reminded me of the West Coast Computer Faire where we introduced the Apple ][. We had the best booth space of all, right as you came in. We also had a video projector, which was quite a feat in that year. Our product was the Apple ][. I did pull a rather large prank at this show, distributing thousands of brochures for a non-existant product called the "Zaltaire." But I don't have time to elaborate here...Steve

The "open source" movement

in
Comment from E-mail

I read in your comments that you were giving away your early designs. This seems to fit with the current popularity of the "open source" movement, and I wonder if you feel that the recent opening of the OSX Darwin kernel is a step in the right direction for Apple. Many people develop free software for free operating systems. Do you? If so, does the new Apple initiative inspire you to code for OSX?

Woz

That's a very astute observation. I gave away schematics of the Apple I at the Homebrew Computer Club. I also demoed enhancements to the Apple ][ every 2 weeks at the club. It was the opposite of normal corporate secrecy.

I don't have time to develop now but I appreciate the people who do so in the open source movement. It's been a long time since that was halfway normal. It makes me hopeful because young talented people have a chance to do more than stand by and watch and be paid a salary.

I think that you just got tired

in
Comment from E-mail

I also see in the same book, (Infinate Loop) that you lost your drive and your edge, and that some say you got caught up being the WOZ..... I think that you just got tired.

Woz

It's possible that I lost my drive and edge. But did I lose my drive and then go in other directions because of it, or did I go in other directions and find great satisfaction and let some things, like engineering, slip away? The truth is closer to the latter. My kind of intense, best in the world, engineering was very very hard and I knew that no human could keep it up for long. When I departed Apple a second time it was to start a company and make a small programmable remote control. I did engineering and wrote the code for one of the internal microprocessors myself. I used a Mac, an Apple ][c, and an Apple ][e throughout this development, those were my main tools (the Mac for non-engineering things). The code for the second, and main, microprocessor wasn't coming easily so I flew to Hawaii to work on it for a week without phone calls and interruptions. Every day for a month I loved looking out to the sea. I came back and decided right then to hire other engineers for this task. I looked more at my young children. Other personal changes ensued. I've remained pretty comfortable ever since, although I never have a minute without something to do. But what do you expect with lots of kids still in school.

I do feel more tired today than back 'then' and I do want to take life easy. But I remember while designing the Apple I and Apple ][ explaining to people that I was actually lazy, and designed things with very few chips so I'd have less construction to do and less to debug. I used this 'laziness' excuse with my software being tight also. Maybe I believed in laziness even back then, even while I designed 2 computers and peripherals and wrote BASIC and much more code, all in a year, all while working days at Hewlett Packard.

Does Steve Jobs know how to code?

in
Question from E-mail

I'm a comp sci major (unfortunately not engineering) and a child development minor, so I am a really big fan of everything that you've been doing and am interested in doing similar things some day. I have a few questions that I would love to hear your responses to: - Does Steve Jobs know how to code? Is he an engineer (i.e. did he know what the heck you were doing when you were building the Apple?)

Woz

Steve didn't ever code. He wasn't an engineer and he didn't do any original design, but he was technical enough to alter and change and add to other designs. I did all of the Apple I and Apple ][ myself, including the feature choices. I did all of the BASIC myself (it's in handwriting as I couldn't afford an assembler). The only person who helped write some of the Apple ][ code was Allen Baum, who helped with the 'monitor' program.

Woz, you changed my life.

in
Comment from E-mail

Woz, you changed my life. 
I have a number of motor, cognitive, and learning disorders. 
Growing up, I wanted to be an astronomer, physicist, or automotive engineer. 
Long before I was old enough to go to college I realized I could not go into a technical field. My handwriting was so bad *I* couldn't even read it. And worse, though I became proficient with a slipstick, I seemed to be unable to find the correct place to put the decimal point. 
The truth was, I couldn't even make it through college. I enrolled in, and flunked out of SF State at 17. 
I realized I was a loser. 
I ended up traveling all over the country working as an iron worker or a trucker. 
I missed things about school. I really missed the fun of figuring out things more complex than how to avoid death, dismemberment, or truck scales. I also missed helping people. 
By the time I was 39 I landed a job as a bid estimator. I was up against my old problem again--my inadequate math and handwriting abilities (the skills were there, I just couldn't execute!). 
It was 1989. I decided I needed a computer. I had to decide which computer to buy. I had to learn how to use the thing and make it work for me within weeks. I asked an elementary school teacher friend of mine for advice. He said buy an Apple ][. 
I bought a 5 or 6 year old used ][e for $500. I learned AppleWorks. I started using Quicken. 
I realized that this computer thing changes everything. With my "new" computer, my "old problem" was geography (it was gone). 
At 40 I went back to college. 
I earned a BS in accounting (OK, chalk one up to lowered expectations here). I passed the CPA exam. 
Now, at age 49 I am a senior analyst (I figure out complex stuff!) in a public employee's retirement system (I get to help people). These are all very good things for me and my family. 
Woz, your role in my life is clear. I guarantee none of these good things would have happened if someone had not designed a cheap computer with a keyboard and a monitor in the 1970's (If you had waited until the 1980's, how could I have found a 6 year old used computer in 1989 for $500 as good as the ][e?). 
Even if I had chosen an IBM XT instead of a ][e for my first computer and had actually been able to get some results out of it within a few weeks, you would still be responsible.

Woz

This is the best such story that I've ever heard. I have seen and taught and hired (for my teaching) many learning disabled people that can do amazing things with the computers. Also, the one year that the teachers of the local 5th grade class told me the students were mentally behind and slow, was the most outstanding year for my computer instruction. I'm not just saying this, many many other teachers have seen the same thing with computers in schools.

I have to say that it was just luck that I saw a low cost computer in the keyboard-display paradigm. It was more of building a computer into a TV terminal than of including a TV Terminal in a computer, based on what I'd built just before the Apple I. To be honest, the rest of the world might have figured this out in a lot less time than you're suggesting. But my motivations were to make a usable product for the simplest user at the lowest cost, and that included you. I had to think of what I wanted for myself and keep my head vacant of what a computer was and looked like and how you made it usable. I did that and went for it in the Apple I. The Apple ][ was merely the chance to add to that concept with some great features and good engineering, at very low cost. It was still aimed at normal people, whereas computers before it were primarily targeted at business clients with lots of money.

Again, your story is so good that it makes my eyes water. I hope that many hear it.