Microsoft Open-Sources GW-BASIC

Avatar

Rich

We are excited to announce the open-sourcing of Microsoft GW-BASIC on GitHub!

Yes, seriously 😀

Why?

Since re-open-sourcing MS-DOS 1.25 & 2.0 on GitHub last year, we’ve received numerous requests to also open-source Microsoft BASIC.

Well, here we are! 😁

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.

A little historical context

The GW-BASIC source code being published is dated Feb 10th 1983. That was quite a while ago, so just to set a little historical perspective:

The week this source was created Men At Work topped the US and UK singles charts with “Down Under”, Dustin Hoffman starred in the #1 US box-office movie, “Tootsie”. In 1983, “Star Wars Episode VI – Return of the Jedi” was released, as was “War Games”! And, Emily Blunt, Kate Mara, Jonah Hill, Chris Hemsworth, and Henry Cavill, were born! Ronald Reagan was President of the USA, and Margaret Thatcher was the UK’s Prime Minister.

That same year, Bjarne Stroustrup was in the middle of developing the first version of the C++ programming language, ARPANET standardized TCP/IP. Borland announced Turbo Pascal, created by Anders Hejlsberg (who went on to join Microsoft, and create J++, C# and TypeScript).

1983 was also the year AT&T released UNIX System V R1, and BSD 4.2 was released, introducing the pseudoterminal for the first time (the progenitor to Windows’ ConPTY we introduced to Windows in 2018 😁)

I was 13, and spent every spare second that I wasn’t finishing my homework or doing my chores, writing BASIC and assembly code on one of the hottest home computers of the time – the BBC Micro sporting 32KB RAM (yes, 32,768 bytes, total!), powered by a 6502 processor running at a BLAZING 2MHz. When not coding, I was usually playing one of the most groundbreaking games of all time: “Elite” by David Braben & Ian Bell.

In 1983, Apple launched the 1MHz 6502-powered Apple IIe for US$1,395 (> $3,500 in 2020). Apple also launched the first retail-available computer with a GUI – the Apple Lisa. The Lisa contained a staggering 1MB RAM, and ran the awesome Motorola 68000 processor at an astounding 5MHz, but it cost $9,995 (> $25,000 in 2020 dollars), so all I could do was peer at it through the window of the one computer store in our town authorized to sell Apple’s products … and dream.

And, in 1983 Microsoft released MS-DOS 2.0 (source here), and GW-BASIC for the IBM PC XT and compatibles.

What IS GW-BASIC?

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.

FAQ

Wait – where’s the C source code?

There is no C source code!

Like much software from the 70s and 80s, and just like the source for MS-DOS, the source code of GW-BASIC is 100% assembly language.

Why assembly? Why didn’t developers use higher-level languages like C, or Pascal?

When developing on/for mainframes and minicomputers of the day, developers were sometimes able to use higher-level languages like FORTRAN, LISP, COBOL, RPG, CPL/BCPL, C, etc. but the compilers for such languages were often hugely expensive, rarely generated efficient code, and were generally unavailable for the space and performance constrained home and personal computers of the day.

When writing software for early PCs, every single byte and every single instruction mattered, so developers often wrote code entirely in assembly language simply to be able to physically fit their software into the available memory, and to be able to access the computer’s resources and internal workings.

Thus, all the source code for GW-BASIC is pure assembly code, translated on a per-processor/per-machine basis from core/master sources.

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.)

What about other ports?

Many have asked if we can also open-source implementations for processors other than the 808x. Alas, we’re unable to provide sources for these ports and/or customizations.

Enjoy!

We hope you enjoy exploring this fascinating snapshot of what software development looked like during the glorious, exciting, heady days of the ’70s and early ’80s at the dawn of “the personal computer” 😁

Many thanks to Amy, Julia Liuson, Amanda Silver, and our awesome CELA team for their approval and help finding, reviewing, and open-sourcing GW-BASIC.

69 comments

Comments are closed. Login to edit/delete your existing comments

  • Avatar
    Sam Lees

    What does the GW stand for? When I was at school my teacher told me it stood for Graphics With Basic. Yes I still remember that lesson in the 80’s. So glad Microsoft has released this as Open Source.

    • Avatar
      Rich TurnerMicrosoft employee

      The jury is out on the GW – it’s either short for “Gee Whizz” or “Greg Whitten” who was one of the early devs who worked on Microsoft’s BASIC products. However, Greg referred to GW-BASIC as “Gee Whizz BASIC”, so take your pick 🙂

  • Tupynambá Gwyra Bebe Pimentel
    Tupynambá Gwyra Bebe Pimentel

    Aos meus 65 anos, programador ASM, louco por códigos virar imagens pra humanoser, trabalhar e.ver image..nação Ibn desde 11 anos, bom man.

  • Avatar
    Mike Colucci

    GW Basic brings back memories as does looking at the 8088 assembler code. I had a few occasions to work with assembler back in the day. In many ways, those early programs were truly magic. Friends and family were amazed even at “Hello World” or “Hello ” (your name).

    Working in such small memory spaces, allocating and un-allocating memory, moving bits, single letter vars. Sloppy programming meant running out of resources. You didn’t throw stuff in because it was “cool”, unlike today where taxing resource limits is near impossible without some horrendous code.

    Then the thrill of assembling, linking and compiling, virtually blind. Something like test flights of a spacecraft. You did your best at engineering but the outcome, well, your mileage could vary, lol.

    Not the good old days, but surely interesting!

    • Avatar
      Rich TurnerMicrosoft employee

      I still think of those as the good old days that taught the value of discipline, patience, care, careful thought and logic.

      Many developers working today have no idea how a computer works under the hood and are astonished that their JavaScript/node apps consume VAST amounts of memory, and run MUCH slower than natively compiled & optimized code.

      I recently spoke with a recent grad from a top-tier US Uni that there’s no way you could write an entire game that rendered 3D graphics in-app into < 32 KB RAM! imagine his surprise … 😉

  • Avatar
    Crefelean Nicolae

    Great news, thanks! 😀

    Now I can’t help wonder how much time it could take until we see all the MS-DOS versions open sourced, and even Windows, up to 3.x. 🙂 I mean having MS-DOS 6.22 + Windows for Workgroups 3.11 would’ve helped a lot of geeks to go through the quarantine with a huge grin on their faces. :))

      • Steve Nickolas
        Steve Nickolas

        I’m aware of Symantec owning MS-DOS 5’s MIRROR, UNDELETE and UNFORMAT by virtue of them devouring Central Point sometime in the 1990s, as well as a bunch of chunks of 6.x. Also, there might be a snarl for anything past 3.0 because of the IBM deal? I’d like to see 3.3, 4.01 or even parts of 5 opened, but I wonder if IBM is a potential obstacle to that.