Microsoft Open-Sources GW-BASIC

The Source

These sources, as clearly stated in the repo’s readme, are the 8088 assembly language sources from 10th Feb 1983, and are being open-sourced for historical reference and educational purposes. This means we will not be accepting PRs that modify the source in any way.

GW-BASIC was a BASIC interpreter derived from IBM’s Advanced BASIC/BASICA, which itself was a port of Microsoft BASIC.

Microsoft’s various BASIC implementations can trace their origins all the way back to Bill Gates & Paul Allen’s implementation of Microsoft’s first product – a BASIC interpreter for the Altair 8800.

During the late ’70s and 80s, Microsoft’s BASIC was ported to many OEM’s specific platform and hardware needs, and for several processors popular at that time, including the 8088, 6502, 6809, Z80, and others.
This source was ‘translated’?

Each of the assembly source files contains a header stating This translation created 10-Feb-83 by Version 4.3

Since the Instruction Set Architecture (ISA) of the early processors used in home and personal computers weren’t spectacularly different from one another, Microsoft was able to generate a substantial amount of the code for a port from the sources of a master implementation. (Alas, sorry, we’re unable to open-source the ISA translator.)


A welcome development! About the name:

After Bill Gates realized the CompuColor was running code derived from ALTAIR BASIC, from there he tracked down Greg Whitten, who had re-vamped the code for the CompuColor. Instead of suing them, he felt that the enhancements were significant enough that he just wanted the rights to use it. So that became the basis of GW-BASIC in DOS.

From the previous thread
Bill Gates and BASIC Easter Eggs


It’s a bit of a shame they don’t provide the “master” source instead of the just the 8088 translator output. Based on comments in the code and general structure it’s pretty clear the “master” is a mildly marked-up version of the 8080 code. The comments refer to BC, DE and HL. Read a few and the mapping becomes apparent:

BC -> CX
DE -> DX
HL -> BX

It seems it may go a little deeper as SI and DI are used here and there. And some facility must be there for conditional code as if you look at SYNCHR you can see that most of it is DB statements to generate the necessary 8088 instructions.

Obviously Z-80 output is pretty trivial. Intel touted source-level compatibility with 8080 as a feature of the 8088 so it’s fun to see it in action.

I’d suspect that the 6502 and 6809 versions were not based on this common code but ported by hand.


Well, I think it’s great that they released this, whatever state it’s in. Arguably, this is the “last” of the 8-bit BASICs, even though it’s been extended to work on MS-DOS.

I think the later BASICs were first class citizens of the newer 16/20b systems and were more likely a complete rewrite rather than a lineage port from a 1975 code base.

But as I recall GW-BASIC did have lots, like 63K, of “free RAM”, so they managed to get most of the code out of workspace and usable for programs.

Now lets move to ‘DISK BASIC’.