Est. 1983 Beginner

GW-BASIC

Microsoft's line-numbered BASIC interpreter for MS-DOS PC compatibles: a self-contained version of IBM's BASICA that came bundled with MS-DOS and taught a generation to program

Created by Microsoft

Paradigm Procedural (unstructured, line-numbered)
Typing Static by variable name: type suffixes (%, !, #, $) or DEFINT/DEFSNG/DEFDBL/DEFSTR; default single-precision
First Appeared 1983
Latest Version GW-BASIC 3.23 (1988)

GW-BASIC is the BASIC interpreter Microsoft supplied with MS-DOS for IBM PC compatibles from 1983 until MS-DOS 5.0 replaced it with QBasic in 1991. It is functionally a self-contained version of IBM’s Advanced BASIC (BASICA). It boots to the familiar Ok prompt, requires a line number on every program line, and has commands for graphics, sound, serial ports and joysticks. BASICA leaned on the Cassette BASIC in the IBM PC’s ROM, which compatibles did not have; GW-BASIC is one executable that runs on any MS-DOS machine. Because it came free with the operating system, it was the first programming language for a very large number of PC owners.

Historian Mark Jones Lorenzo calls GW-BASIC “arguably the ne plus ultra of Microsoft’s family of line-numbered BASICs stretching back to Altair BASIC” (Endless Loop: The History of the BASIC Programming Language, 2017, p. 122).

History & Origins

From Altair BASIC to the IBM PC

Microsoft’s first product was the BASIC interpreter Bill Gates and Paul Allen wrote for the Altair 8800 in 1975. GW-BASIC descends from it directly. The main module of the 1983 source, GWMAIN.ASM, still opens with the original header:

COPYRIGHT 1975 BY BILL GATES AND PAUL ALLEN

ORIGINALLY WRITTEN ON THE PDP-10 FROM
FEBRUARY 9 TO  APRIL 9 1975

BILL GATES WROTE A LOT OF STUFF.
PAUL ALLEN WROTE A LOT OF OTHER STUFF AND FAST CODE.
MONTE DAVIDOFF WROTE THE MATH PACKAGE (F4I.MAC).

Through the late 1970s Microsoft ported that interpreter to the 8080, Z80, 6502, 6809 and other processors. Its disk-based BASIC-80 (MBASIC) reached release 5.x. For the IBM PC in 1981, Microsoft wrote two BASICs: Cassette BASIC, which was in ROM, and Advanced BASIC (BASICA), which loaded from disk and called into the ROM code. BASICA was in effect BASIC-80 5.x plus statements for the PC’s graphics, sound and other hardware.

Compatible machines did not carry IBM’s ROM BASIC, so they could not run BASICA. Microsoft’s answer was GW-BASIC: the same language, packaged as a standalone program that OEMs could ship with their own MS-DOS. Microsoft’s 2020 announcement describes it as “a BASIC interpreter derived from IBM’s Advanced BASIC/BASICA, which itself was a port of Microsoft BASIC”, released in 1983 “for the IBM PC XT and compatibles.”

One master source, many machines

Microsoft did not hand-write each port. All but one of the 35 assembly files in the published source (the exception is MATH2.ASM) start with the line This translation created 10-Feb-83 by Version 4.3. That line records that Microsoft generated 8088 assembly from master sources using an in-house instruction-set translator, which it did not release. The source also has switches for particular OEMs, including Mitsubishi (MELCO), Zenith (ZENITH), Toshiba (TSHIBA) and Sirius (SIRIUS). A KANJ86.ASM module adds Kanji string functions. This fits what Bill Gates wrote in 1989: “Many features that ended up in GWBASIC (short for Gee Whiz) came from our experience writing interpreters for Japanese machines.”

What does “GW” stand for?

The name has never been formally explained, and several stories circulate: “Gates, William”, “Gates–Whitten”, “Graphics and Windows”. The two first-hand accounts agree on Gee-Whiz:

  • Bill Gates, in BYTE (October 1989, “The 25th Birthday of BASIC”), calls it “GWBASIC (short for Gee Whiz)”.
  • Greg Whitten, the early Microsoft employee who set the BASIC language standards in Microsoft’s compiler line, wrote in a 2005 email: “The GW-BASIC name stands for Gee-Whiz BASIC. The GW- name was picked by Bill Gates.” He added that if it was named for anyone, it was probably him, and that “Gee-Whiz” appealed to Japanese OEMs because of the language’s graphics features.

Design Philosophy

GW-BASIC is a late, very complete example of the 1970s microcomputer BASIC design, which put these goals first:

  • Immediacy. The interpreter is the whole environment. Typing a numbered line stores it; typing anything else runs it at once. RUN, LIST, LOAD, SAVE and SYSTEM work both as commands and as program statements.
  • Compactness. Programs are stored tokenized, with each keyword reduced to a byte. They are saved to disk in that binary form by default; ASCII is an option.
  • Direct hardware access. PEEK, POKE, INP, OUT, CALL and DEF SEG give programs full control of the machine. Gates said these features existed “to let people get at the resources of the machine.”
  • Backward compatibility. BASIC-80 programs that do not use PEEK/POKE generally run unchanged, and BASICA programs run on compatibles.

Structured programming was not a goal. That is the main difference from its successors, QuickBASIC and QBasic.

Key Features

Program structure

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
10 REM Temperature table in GW-BASIC
20 DEFINT I
30 DEF FNC(F) = (F - 32) * 5 / 9
40 PRINT "Fahrenheit", "Celsius"
50 FOR I = 0 TO 100 STEP 20
60   PRINT I, : PRINT USING "###.#"; FNC(I)
70 NEXT I
80 INPUT "Your name"; N$
90 IF N$ = "" THEN 80 ELSE PRINT "Hello, "; N$
100 END
  • Line numbers are mandatory. Control flow uses GOTO, GOSUB/RETURN, ON ... GOTO and ON ... GOSUB. The editor has RENUM and AUTO for managing line numbers.
  • IF ... THEN ... ELSE must fit on one line. The only multi-line block is WHILE ... WEND.
  • Functions are one-line DEF FN expressions. There are no local variables and no named multi-line subroutines.
  • Variable names can be up to 40 characters, as in BASIC-80 5.x. OPTION BASE sets the first array index to 0 or 1.

Data types

SuffixTypeNotes
%Integer16-bit
!Single precisionThe default for undeclared variables; uses Microsoft Binary Format (MBF)
#Double precisionMBF; double-precision transcendental functions need the /D startup switch
$StringSpace allocated dynamically

DEFINT, DEFSNG, DEFDBL and DEFSTR set a default type by first letter, so DEFSTR S makes every variable beginning with S a string.

Graphics, sound and devices

  • Graphics: SCREEN, PSET, LINE, CIRCLE, PAINT, GET/PUT, and the DRAW macro language. Gates says Microsoft developed both DRAW and PLAY. Later versions support EGA modes. VGA is not supported.
  • Sound: SOUND frequency, duration drives the PC speaker. PLAY takes a music-macro string such as PLAY "edcdeeL2edfedL4c".
  • Devices: sequential and random-access files, OPEN "COM1:..." for serial ports, joystick and light-pen input, and event trapping with ON COM, ON KEY, ON TIMER, ON STRIG and ON PEN.
  • Protected programs: SAVE "PROG",P writes an encoded file that cannot be LISTed.

The screen editor

GW-BASIC has a full-screen editor in the tradition of Microsoft’s 8-bit BASICs. You move the cursor to any line on the screen, edit it, and press Enter to store it. The bottom row of the screen shows labels for the function-key shortcuts (LIST, RUN, LOAD", SAVE" and so on).

Evolution

Until MS-DOS 3.2 (1986), the first version Microsoft sold at retail, MS-DOS reached users only through OEMs, so GW-BASIC appeared in many vendor variants. Some were named GWBASIC.EXE and others BASICA.EXE. Some had extra hardware support, such as Tandy’s build for the Tandy 1000. Microsoft’s own GW-BASIC User’s Guide and User’s Reference (1987) covers MS-DOS 3.2 and later. Version 3.23, copyright 1988, is generally given as the final release; a 1989 BYTE advertisement still pairs MS-DOS 3.21 with GW-BASIC 3.22.

By the late 1980s, Microsoft’s development effort had moved to QuickBASIC (from 1985), a compiler with an integrated environment and structured SUB/FUNCTION procedures. MS-DOS 5.0 (June 1991) replaced GW-BASIC with QBasic, the QuickBASIC environment without its compiler. QBasic still accepts line numbers, so many GW-BASIC programs could be moved over with little change, but GW-BASIC itself was never developed further.

Current Relevance

GW-BASIC has been historical software for more than three decades. It remains easy to run and study:

  • Source code. On 21 May 2020 Microsoft published the February 1983 8088 assembly source at github.com/microsoft/GW-BASIC under the MIT License. The repository is for historical reference only: it is read-only, and it has no build scripts and no binaries.
  • Emulation. PC-BASIC is a free, GPLv3 reimplementation that aims for bug-for-bug compatibility with GW-BASIC. It reads tokenised, protected and MBF data files, and can be installed with pip install pcbasic. It was still under active development in 2026.
  • Original binaries. These run under DOS emulators such as DOSBox. The interpreter is a 16-bit real-mode program and does not run natively on 64-bit Windows.

Why It Matters

GW-BASIC links Microsoft’s 1975 Altair BASIC to the structured BASICs of the 1990s. The same company that wrote the IBM PC’s ROM BASIC also put BASIC on the compatibles, and with GW-BASIC on every machine, type-in listings, school courses and hobby programs could assume BASIC was available. For a great many users, typing GWBASIC at the DOS prompt was how they first started programming.

Its source code is also a historical record. It shows that Microsoft built its many BASICs by generating machine-specific assembly from master sources. It carries conditional switches for many OEM machines, and its main module still has the 1975 header naming Gates, Allen and Davidoff.

Timeline

1981
IBM ships the IBM PC with Microsoft-written Cassette BASIC in ROM and disk-based Advanced BASIC (BASICA), the dialect GW-BASIC would later reproduce
1983
Microsoft's 8088 GW-BASIC sources are generated on 10 February 1983 ('This translation created 10-Feb-83 by Version 4.3'); that year Microsoft releases GW-BASIC for the IBM PC XT and compatibles alongside MS-DOS 2.0
1987
Microsoft publishes the GW-BASIC User's Guide and User's Reference for MS-DOS 3.2 or later
1988
GW-BASIC 3.23 (copyright 1988) becomes the final release of the interpreter
1989
In BYTE's October 1989 issue, Bill Gates writes that GWBASIC is 'short for Gee Whiz' and that many of its features came from Microsoft's work on interpreters for Japanese machines
1991
MS-DOS 5.0 ships in June 1991 with QBasic, which takes GW-BASIC's place as the BASIC bundled with DOS
2005
Greg Whitten, an early Microsoft employee, writes that Bill Gates picked the 'GW-' name and that it stands for 'Gee-Whiz BASIC'
2020
On 21 May 2020 Microsoft publishes the February 1983 GW-BASIC assembly source on GitHub under the MIT License, for historical reference only

Notable Uses & Legacy

MS-DOS on PC compatibles

OEM versions of MS-DOS shipped GW-BASIC as their BASIC, under the name GWBASIC.EXE or BASICA.EXE depending on the OEM. On machines without IBM's ROM BASIC it gave every buyer a programming environment at no extra cost. A 1989 BYTE advertisement lists 'MS DOS 3.21 & GW-BASIC 3.22' as standard software on an 80286 system.

Zenith Data Systems

Zenith distributed GW-BASIC 2.0 under its own label. The published source has a ZENITH conditional-assembly switch for its 8086 machines.

Tandy 1000

Tandy shipped its own GW-BASIC build that drives the Tandy 1000's enhanced sound and graphics hardware. Emulators still treat it as a separate dialect.

Microsoft BASIC Compiler (BASCOM)

Microsoft sold a BASIC compiler, largely compatible with GW-BASIC programs, for code that needed more speed than the interpreter could give

PC-BASIC

Rob Hagemans' free, GPLv3 interpreter (copyright from 2013, on GitHub since May 2014) aims for bug-for-bug compatibility with GW-BASIC, BASICA, PCjr Cartridge BASIC and Tandy 1000 GWBASIC. It runs tokenised and protected .BAS files on modern Windows, macOS and Linux.

Language Influence

Influenced By

BASICA BASIC-80 (MBASIC) Altair BASIC Dartmouth BASIC

Influenced

QBasic

Running Today

Run examples using the official Docker image:

docker pull
Last updated: