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:
graphics and PC hardware removed, tokens and behaviour aligned on MBASIC 5.28,
one source tree producing an MS-DOS .EXE and a CP/M-86 .CMD.
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$
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, 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
6. 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
.COM build for DOS
like 5.28 (31,744 B .COM); saves the 512 B .EXE header, but the start-up segment setup must change
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
7. 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