You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A text-mode Microsoft BASIC interpreter rebuilt from the 1983 GW-BASIC sources specifically for FCB DOS and CP/M-86 family:
graphics and PC hardware removed, tokens and behaviour aligned on MBASIC 5.28/ MBASIC-86 5.22.
one source tree producing an MS-DOS .COM and a CP/M-86 .CMD.
A similar but far more advanced approach can also be found at gw-basic-2026. If you intent to work on *nix and more recent ms-dos environment, have a look at it.
1. Why and what
Why
Fun, nostalgia and history: get a working, buildable Microsoft BASIC-86 back from published source
MBASIC 5.50: everything MBASIC 5.28 does, nothing PC specific, Works on both DOS and CP/M
Rule
May do more than 5.28 / 5.22, never less
Manual
docs/basic-5.0.pdf: BASIC-80 5.0 reference manual, also valid for this version (5.50 follows the 5.x language)
The family, as far as the sources tell
Product
Year
CPU / OS
Relation
Altair BASIC
1975
8080
Origin of BINTRP ("Bill Gates and Paul Allen", Monte Davidoff math)
BASIC Rev. 4.51 [CP/M Version]
1977
8080 / CP/M-80
Earlier CP/M release (banner: "Copyright 1977 (C) by Microsoft"), before the 5.x line and MBASIC.COM naming; not part of these sources, binary kept in ref/
BASIC-80 (MBASIC) 5.21
~1981
8080 / CP/M-80
Disk BASIC 5.x, the language MBASIC users know
BASIC-86 5.22
1982
8086 / CP/M-86
5.x mechanically translated from 8080 to 8086 (headers: "translation created … by Version 4.3")
MBASIC 5.28
1983
8086 / MS-DOS
Same 5.x line on MS-DOS; adds BLOAD/BSAVE, CALLS, DATE$, TIME$
GW-BASIC core minus PC specifics, 5.28 tokens and behaviour, teletype console
2. Runs on
Quick start-up checks (banner, FILES, program entry) on PCE/ibmpc; not an extensive test.
PC-DOS 1.10 (.EXE) · CP/M-86 1.1 (.CMD) Concurrent DOS 4.1 (.CMD) · DOS Plus 1.2 (.CMD)
Platform
Status
Notes
MS-DOS / PC-DOS 1.10+
✔ checked on PC-DOS 1.10
Only DOS 1.x calls (00h–2Eh), FCB files, 8.3 names, no paths
MS-DOS 2.x–6.x
✔ checked on MS-DOS 6.22
Same binary
CP/M-86 1.1 (BDOS 2.2)
✔ checked
DATE$/TIME$ → "Illegal function call" (no clock)
CP/M-86 Plus, Concurrent CP/M / DOS, DOS Plus (BDOS 3.x, 4.1)
✔ checked on Concurrent DOS 4.1 and DOS Plus 1.2 (.CMD)
DATE$/TIME$ via BDOS 155/104
Any 8086/8088 machine
✔
No BIOS, video or port access by the interpreter
emu2-cpm86 (DOS and CP/M-86)
✔ fully tested
All tests/ run here
Binary
Size
Memory
build/dos/mbasic86.com
~34 KB
64 KB data segment
build/cpm/mbasic86.cmd
~35 KB
code group + data group up to 64 KB
3. Command line
mbasic86 [file] [options]: the optional program file is loaded and run, options start with / and may come before or after the file name (only one file name allowed). Anything else gives "Error detected in command line".
Option
Effect
/F:n
Number of files: accepted for compatibility, ignored (files are dynamic)
/S:n
Maximum record size: accepted for compatibility, ignored (records are dynamic)
/M:n
Limit the data segment to n bytes (decimal or &H hex), e.g. /M:&HC000 leaves 46922 bytes free instead of 63290; more than is available is refused
/NOB[ANNER]
No banner and no "Bytes free" message (5.50 extension)
/NOR[UN]
Load the program but do not run it, stay at Ok (5.50 extension)
Option names are case-insensitive and may be abbreviated down to three letters (/NOB, /NOR). Examples: mbasic86 pspdump, mbasic86 /nob /nor pspdump, mbasic86 prog /m:&HC000.
✔ (/F:/S: accepted, ignored: files and records are dynamic)
Command line /NOB[ANNER] (no banner, no "Bytes free"), /NOR[UN] (load the program, don't run it)
✘
✘
✘
✔ before or after the file name, e.g. mbasic86 /nob pspdump (5.28 accepts options only after the file name)
Graphics, sound, CLS/LOCATE/COLOR/SCREEN, KEY
✘
✘
✔
✘ removed
COM:, light pen, joystick, cassette, events (ON KEY…)
✘
✘
✔
✘ removed
CHDIR/MKDIR/SHELL/ENVIRON, VARPTR$, Kanji
✘
✘
✔
✘ removed
Verification: identical to 5.28 (DOS) and 5.22 (CP/M-86) on all tests/
scripts except the reviewed extras in tests/accept/dos and tests/accept/cpm;
both builds identical to each other except ERR 57's wording and an emulator
limit (tests/accept/parity).
interpreter (MASM 5.10), oem.inc switches, cfg.inc generated per target
giotty.asm, oemio.asm
teletype console, line editor, OS primitives
tools/
runbas.py test driver, mkcom.py EXE→COM, mkcmd.py EXE→CMD, normout.sh
tests/
scripts (\k ^C, \e ESC, \^X control keys, first line #args: = command line, NAME.bas companion file), accept/ reviewed differences
examples/
ivtdump.bas: 8086 interrupt vector table (DEF SEG=0, PEEK); pspdump.bas: MS-DOS PSP / CP/M-86 base page at BASIC's DS:0 (DEF SEG, PEEK); beep.bas: PC speaker beep (OUT, INP, PC hardware only). emu2 shows placeholder vectors; real values on real hardware
7. Possible evolution
Idea
Note
Extensive testing on real DOS 1.10 / CP/M-86 1.1 / Concurrent DOS
start-up checked, full tests/ not yet run there
LINK 5.10b
currently rejects the object set; LINK 3.65a used
Exact file lengths on CP/M 3 (LRBC)
binary files end on 128-byte records today
8087 support, more devices
only if it stays OS-generic
8. Fun facts and quirks (found in the 1983 code)
Finding
Where
Machine-translated 8080 code: every module says "translation created … by Version 4.3", and 8080 tricks survive, e.g. DB 271O (the 8080 LXI B opcode) to jump over the next two bytes
gwmain.asmSNERR…TMERR
SAVE ,P "encryption" is two XOR passes keyed on the floating-point coefficient tables of EXP and LOG ($EXPCN, $LOGP, comments say ATNCON/SINCON)
giodsk.asmPENCOD/PDECOD
It was once "GW-CPM BASIC": the switch file is titled "Common file to produce 2-segment 8086 GW-CPM BASIC", and half-finished CP/M-86 date code (BDOS 155) was left in
oem.h, gwsts.asm
OEM ghosts: switches for MELCO, ZENITH, SIRIUS, TSHIBA, PC8A (NEC)…, and a CLD ;Because of Melco BIOS Bug
gwmain.asm, gwsts.asm
Exit to DOS by pushing segment:offset and doing a far RET, because the "translator can't handle JMPI ,adr yet"; many instructions are hand-assembled in octal with the INS86 macro
giodsk.asmSYSTME, oem.h
Credits in the header: "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"
gwmain.asm
Generated switch files: "Pascal program HFILE searches for the following line - DO NOT MODIFY"
oem.h
Honest comments: RET ;YOU WOULDN'T BELIEVE IT IF I TOLD YOU, RET ;THIS IS A KLUDGE TO MAKE CHRGET WORK
gwmain.asm, gwdata.asm
GW-BASIC still thinks it is MBASIC: "FIX … SO THAT IF ^C DURING MBASIC FOO, WONT EXIT TO SYSTEM"
dskcom.asm
Typing fossils: literal backspace characters in comments (EXPECT USUALL^H NUMBERS), and files padded with NULs / ^Z to 128-byte CP/M records
gwmain.asm, bimisc.asm, all .h files
The DOS critical-error handler (INT 24h) never returns with IRET: it discards 20 bytes of DOS stack and jumps straight into BASIC's ERROR
gio86.asmDSKERR
"8086 versions force stack entries to be an even length": every FOR entry carries an extra padding byte on the stack
gwmain.asm
The USR "undefined slot" check is hand-assembled in octal (INS86 203,372 + DB 377O = CMP DX,-1); BASIC-86 5.22 got it wrong as a byte compare (80 FA FF)
gweval.asmUSRFN
NULL n still sends n NUL characters after each line — padding for mechanical teletypes that need time to return the carriage