January 3, 2018

Question from E-mail

Recently I’ve heard that Apple licensed floating point BASIC from Microsoft. As I had programmed in microsoft BASIC on the IBM PC-XT as well I saw no simularities to the Applesoft BASIC on my ][e so which is the truth? Can you elaborate on how much Microsoft provided to AppleBASIC?


I wrote the original Apple Integer BASIC. I had wanted it to be the very first BASIC for the 6502 microprocessor. I might then have something to be recognized for. I decided that it had to play games and let me solve engineering problems. I first wrote out a syntax with floating point but then figured that it might be done a few weeks sooner with just integers. I had to write it in the evenings as I worked at Hewlett Packard then. So I cut back to an integer BASIC that I called “Game BASIC”.

I’d never programmed in BASIC. My college had encountered Fortran, several machine languages, Algol, and a couple of special languages. But you could buy a book called “101 BASIC Games”. Plus, the Gates/Allen BASIC was becoming the standard thing to get for your Altair computer, although very few people had these computers yet.

I’d never writting a computer language or taken a course in it, although I’d studied books on my own touching on the topic. I have no idea to this day if I wrote it as anyone else would. I broke the entire language down into a syntax table that was stored in memory, in modified text form. A word like “PRINT” was stored as the 5 letters. If you were allowed an unsigned expression after some word, I stored a pointer to the syntax of that type of expression, which specified what it could be made of. Each line was compared, letter by letter, through this syntax table to see if there was any valid BASIC statement.

I gave each symbol in the syntax table a particular code as on operator. The word “PRINT” might be operator number 5 and “FOR” might be operator number 13, etc. A plus sign had it’s code too. A symbol like a minus sign might have two different codes depending on whether it was prefix (like -5) or infix (like 9-6). A variable or a number was an operand. I pushed the operand references onto one stack and operator codes onto another. But the operator codes each had 2 different priorities telling my BASIC whether to push them on top of the topmost operator already on the stack, or to pop that one off and generate the output program from it. Each operator had a value for it’s tendency to push others off, and a value for it’s resistance to being pushed off. For example, plus tends to push divide off, causing the division to happen first. Strangely all this works.

Then I had to write one short routine for each of perhaps 100 operators. These included keywords like “PRINT”, mathematical operators like ‘plus’, parenthesis, and other grammar symbols of BASIC.

It took a couple of months to get the BASIC to this shape, with an engine that ran the whole thing. Then I would define a Syntax sentence in the syntax table, along with any routines for any new operator symbols. I would test it, get it working, and move on to the next syntax sentence for the next BASIC statement. From this point on, things were very modular and I was only writing very short programs.

Well, the BASIC was a very big success. Especially when I was able to easily add statements and corresponding routines for color graphics and game commands in the Apple ][.

We shipped some apps with our early Apple ][‘s. Apps like ColorMath (a flashcard program) and Breakout (a game I’d designed the hardware version of for Atari). These apps were on casette tapes in 1976, before floppy disks. Mike Markkula, who was our third and equal partner, was running marketing for us (and much more!). He, and some young programmers, and anyone else he could find, wrote our first checkbook program. It led to two items heading our ‘projects to do’ list at a staff meeting. This sort of program wanted floating point numbers (or a programmer like myself who would have preferred integers) and also a floppy disk for speed. These became my top two projects.

I rushed and got one of my favorite and most famous designs ever done in 2 weeks, working every day of Christmas vacation, 1977, including Christmas and New Years day. I’d never designed a floppy disk interface nor worked with one. Nor did I have a clue what was in them. I set out this blind and started designing stuff that would efficiently read and write floppy disks with the new Shugart 5″ mechanism. I wound up with 5 chips one day doing the job, along with some low level 6502 software of my own. Randy Wigginton helped me with this project. My motivation was that Mike Markkula said that if we had the floppy ready to demo at the first CES show that was to permit personal computers to be a part, in Las Vegas, in January. I’d never been to Las Vegas, only dreamed of it. Well, I made the trip and the floppy was a success for Apple.

I next started working on a new floating point BASIC. My design style is to spend quite a bit of time thinking out every angle in my head and in rough sketches, and then to start coding. The first results aren’t visible right away, but at the end they come up very quickly. Steve Jobs got concerned that I wasn’t making enough progress. He even accused me of slacking and coming in at 10 AM in one staff meeting, but I pointed out that I’d been laying out our floppy PC Card (of which I’m extremely proud as I relayed it with one shift register shifting in the opposite direction of my first design after I discovered that would cut the PC board crossovers from 8 to 5, something nobody would ever see but that’s the drive for perfection) and that I’d been leaving at 4 AM every morning, long after even the Houston brothers, Dick and Cliff, had left.

Somehow, we wound up with a Microsoft 6502 floating point BASIC one day. I installed it (which involved a lot back then) and tested it. Since it was already near completion, and only needed some graphics commands added for our Apple, our own effort was best dropped. Mine might turn out better in some regards, but wasn’t worth the risk or effort. I have no idea if this BASIC was written by Microsoft or just found by them. My biggest disappointment was going to the awful string functions like LEFT$ (VAR, 5) and MID$ (VAR2,5,3) instead of my own, which were written VAR (1:5) and VAR2 (5;8) for the first 5 characters and characters 5 through 8 of a variable.

I forget how much we paid Microsoft for this BASIC.