The source code behind Microsoft BASIC for 6502 comes to light

You can now look at one of the oldest existing pieces of source code written by Bill Gates

If you love seeing source code for classic software then you’ll be excited to hear about some historic code that surfaced last week: the source code behind Microsoft BASIC for the 6502 microprocessor. The code was posted on a Korean-language site and, subsequently, a nice analysis and breakdown was provided by Michael Steil, a self-described operating system hacker and CISC enthusiast. Steil wrote that the code is “the oldest publicly available piece of source written by Bill Gates.”

Microsoft BASIC for 6502 was based on Altair BASIC, which Bill Gates and Paul Allen famously created for the MITS Altair 8800 (which used Intel’s 8080 CPU) in 1975, writing it in a motel in Albuquerque, New Mexico. That same year, MOS Technology created the 6502 microprocessor as a cheaper alternative to other microprocessors of the day. The 6502 would eventually be used in a number of popular computers, such as the Apple I, the Apple II, Commodore VIC-20 and 64 systems, as well as gaming consoles such as the Atari 2600.

Initially, MOS created their own computer board using the 6502, called the KIM-1, which hobbyists could use to build their own system. Microsoft then used Altair BASIC as the basis for a new implementation that could run on the 6502. When Commodore bought MOS in 1976, they used the KIM-1 as the basis for their PET computer and licensed Microsoft BASIC for 6502 for a one-time payment and called it Commodore BASIC.

Microsoft BASIC for 6502 is not to be confused with another BASIC implementation created for that processor by Apple’s Steve Wozniak. Woz’s Integer BASIC was created for the Apple I and and included with Apple II computers. Starting with the Apple II Plus, though, Apple moved away from Integer BASIC, since it didn’t support floating point numbers, and instead licensed Microsoft BASIC, calling it Applesoft BASIC.

In his analysis of the 6502 code, Steil concludes the source of it was someone at Apple, and that based on the change log and the comments, this was version 1.1 and was last updated in July, 1978. Steil also points out many interesting things about the code, such as:

  • This version was version was written on a PDP-10, using the MACRO-10 assembler.
  • Based on comments in the Altair BASIC and 6502 code, he concludes that Bill Gates wrote the runtime parts, such as all BASIC commands, functions and operators, while Paul Allen wrote non-runtime bits, such as the 6502 simulator and the tokenizer/detokenizer. Monte Davidoff is credited with writing the math functionality (e.g., handling floating point numbers).
  • This code contains the Bill Gates’ famous WAIT 6502 Easter Egg, which would replace COMMODORE on the screen with MICROSOFT when a certain string was entered.

Steil also points out that source code could be compiled into 6 different versions of BASIC, including Commodore and Applesoft BASIC. He also provides great detail on the code structure and many other interesting finds. It’s a must read for any historic source code nerds, so, if you’re one of those people, have at it!

See also:

Exposing the source: 16 pieces of classic software whose code is now accessible

REM 14 historic BASIC implementations

GOTO 50: 7 ways to celebrate BASIC’s golden anniversary

15 geeky places to visit before you die

This story, "The source code behind Microsoft BASIC for 6502 comes to light" was originally published by ITworld.

Copyright © 2015 IDG Communications, Inc.

It’s time to break the ChatGPT habit
Shop Tech Products at Amazon