Read the Blog, then check out the Preview, which highlights a few of the original Demos.
Project Status
BASIC-DOS began as a technology demo: a reimagining of what the first IBM PC operating system could have been, with a unified DOS and BASIC command interpreter, preemptive multitasking sessions, and other features that PC DOS wouldn’t offer for years (if ever). The goal now is to turn it into a usable product.
This section tracks what’s been completed ([x]) and what remains ([ ]). Items marked partial work, but with known gaps.
Boot and System Configuration
Boot sector that loads the BASIC-DOS drivers, kernel, and interpreter
Boot prompt when a hard disk is detected (press Esc to boot from it)
CONFIG.SYS support for BOOTKEY, CONSOLE, DEBUG, FILES, MEMSIZE, SESSIONS, SHELL, SKIP, and SWITCHAR
SKIP= lists built-in drivers (by their exact device names, separated by commas) that should not be loaded (eg, SKIP=CON,FPU$); a skipped driver is never initialized, and its memory is reclaimed
CON, with multiple console contexts (one per session)
COM, AUX, LPT, PRN, NUL, CLOCK$, and PIPE$ devices
Interrupt-driven, asynchronous I/O for CON and COM
Floppy disk reads, including multi-track requests and requests that cross 64K boundaries
Floppy disk writes
Media check and BPB rebuilds (reads PC DOS 1.x and 2.x diskettes)
partial: Hard disk reads and writes (HDC$), for the FAT12 primary partitions of up to two PC XT hard disks, which become drives C:, D:, etc. (drives A: and B: are always reserved for diskettes)
Write-with-verify (DDC_WRITEV), formatting, and FAT16 hard disks
“Popup” and background console contexts
Kernel: Processes, Memory, and Sessions
COM and EXE program loading, PSPs, EXEC, and exit codes
Memory allocation (MCBs), including per-program heap requests
Preemptive multitasking of multiple sessions
CTRL-C/CTRL-Break handling, and CTRL-ALT-DEL session aborts
Session STOP/END operations (currently TODOs)
TSR support (INT 27h and INT 21h function 31h)
Environment segments for EXEC (EPB_ENVSEG)
Kernel: File System
FAT12 file reading
Handle-based open, read, seek, IOCTL, and close
Find first/next, disk info (free space), and current drive/DTA
Handle-based file creation (function 3Ch) and writing (function 40h)
File deletion (function 41h) and renaming (function 56h)
FAT cluster allocation and freeing
Write-back of modified FAT and directory buffers (every FAT copy is updated), including when the buffer is reused, on file close, disk reset, and restart
partial: FCB support (open, close, and reads only; no create, write, delete, or rename)
Truncating/extending a file with a zero-length write
Enforcing the read-only attribute on open, and getting/setting file attributes (function 43h) and date/time (function 57h)
Subdirectories (MKDIR, RMDIR, CHDIR, and paths); for now, subdirectory entries are ignored (they can’t be opened, deleted, or overwritten)
Absolute disk reads and writes (INT 25h and INT 26h)
FAT16, extended partitions, and a larger buffer cache (there are currently only two sector buffers: one for FAT sectors and one for directory sectors)
Command Interpreter: DOS Commands
COPY, DATE, DEL, DIR, EXIT, HELP, KEYS, MEM, RESTART, TIME, TYPE, and VER
Running COM, EXE, BAT, and BAS files, and loading programs into other sessions
BAT and BAS files can run other BAT and BAS files and then continue (no CALL command required); a nested BAS file gets its own variables
Pipes (|) and output redirection (> creates or truncates the output file, >> appends to it), including redirection at the end of a pipeline (eg, DIR | CASE > TEST)
COPY creates (or truncates) the output file, and refuses to copy a file onto itself
DEL/ERASE
Resident and transient portions: before running a COM or EXE file, COMMAND.COM frees idle variable blocks and discards its transient portion (about 23K), reloading it from COMMAND.COM when the program ends; MEM includes the transient portion in its free memory total
Input redirection (<)
REN/RENAME, and SAVE (for BASIC programs)
Disk utilities (eg, FORMAT, CHKDSK, SYS)
Command Interpreter: BASIC Language
32-bit integer variables, constants, and expressions (including AND, OR, XOR, EQV, IMP, NOT, MOD, and shifts)
Type suffixes (% for integers, # or ! for doubles, and $ for strings), where the type is part of a variable’s identity (eg, after DEFINT A-Z and then DEFDBL A-Z, A is a new variable, separate from A%)
String pool management: temporary strings are released as soon as they’re consumed, strings are compacted (and empty string blocks freed) when space runs out, and runtime string errors (eg, “String too long”) abort the program cleanly
CLS, COLOR, DEF FN (including string functions and parameters), DEFDBL, DEFINT, DEFSNG, DEFSTR, ECHO, GOTO, IF/THEN/ELSE, LET, PRINT, REM, and RETURN
Assignments without LET in BAS and BAT files (LET is still required on the command line)
LOAD, LIST, NEW, and RUN
Functions: ERR, ERRORLEVEL, MAXINT, PEEK, RND, and RND%
Arrays of integers, doubles, and strings, with up to 255 dimensions: DIM, ERASE, OPTION BASE, automatic dimensioning (with a largest subscript of 10) of arrays used without DIM, and “Subscript out of range” and “Duplicate definition” errors
Control flow: END, FOR/NEXT (with STEP, and integer or double loop variables), GOSUB/RETURN, ON … GOTO/GOSUB, STOP, and WHILE/WEND
Memory management that’s forgiving of low or fragmented memory: code, text, variable, and string blocks are modest (4K) blocks that are chained together as needed (generated code continues in another code block via a far JMP), no block type takes more than a quarter of the largest free block, and smaller blocks (down to 512 bytes) are used when necessary
Limitations: a DEF function’s code must fit in a single block, and each array requires a single block (64K max)
Specific error messages for compile-time errors (eg, “NEXT without FOR” and “WHILE without WEND” are currently reported as syntax errors)
STOP’s “Break” message (STOP is currently the same as END)
INPUT, LINE INPUT, READ, DATA, and RESTORE
The MID$ statement (ie, MID$(A$,N[,M]) = B$)
&H and &O prefixes in VAL
Comma print zones in PRINT (commas currently print a tab)
partial: Error handling (ON ERROR GOTO, RESUME line, ERROR, and ERR; see the DONKEY.BAS checklist)
Runtime error messages for numeric errors
Floating-Point
BASIC-DOS will support only one floating-point type: IEEE 754 64-bit (double-precision) values. It won’t use any MBF (Microsoft Binary Format) code.
Parser support for floating-point constants (CLS_FLOAT tokens)
Numeric variables default to doubles (unless DEFINT is used), and DEFSNG is treated as DEFDBL
MBF-based MSLIB option removed
FPU$ device driver, which detects an 8087 at boot and provides a table of floating-point functions (IOCTL_GETFPU)
8087 functions: arithmetic (including ^), comparisons, conversions between longs and doubles, ABS, INT, FIX, and SQR
Software emulation of all FPU$ functions for systems without an 8087
The interpreter reports at startup whether floating-point uses an 8087, emulation, or is disabled (no FPU$ driver); when disabled, variables default to integers and “/” and “^” are integer operations
String-to-double (FPU_ATOD) and double-to-string (FPU_DTOA) conversions, and %f support in sprintf
Expression generator support for mixed integer/floating-point operations (promotion and demotion rules), using FPU$ calls
Floating-point constants and PRINT output in BASIC programs
BASIC math functions: ABS, ATN, COS, EXP, FIX, INT, LOG, SIN, SQR, and TAN
FPUTESTS, run with and without an 8087 by tools/tests/quick.sh
Saving and restoring 8087 state on session switches (FPU$ functions currently disable interrupts instead), and better error reporting for FPU exceptions
Utility functions DOS_UTL_ATOF64, DOS_UTL_I32F64, and DOS_UTL_OPF64 (still stubs; possibly superseded by FPU$)
DONKEY.BAS
DONKEY.BAS, from the original IBM PC DOS 1.00 diskette, is a good test of BASIC-DOS’s compatibility with IBM PC BASIC programs. These are the items it needed, followed by related work that remains. Since BASIC-DOS compiles an entire program before running it, every statement must at least be recognized, even ones that DONKEY.BAS rarely or never runs (eg, PLAY and CHAIN).
SCREEN 0, 1, and 2 (text, 320x200, and 640x200 modes), WIDTH 40 and 80, and LOCATE (row, column, and cursor visibility)
CON driver IOCTLs to get and set the video mode and cursor position; a mode change (whether by IOCTL or by INT 10h directly) turns the console into a full-screen, borderless context that uses INT 10h passthrough, so text output and CLS work in graphics modes
COLOR with blinking foregrounds (16-31), omitted arguments (eg, COLOR ,1), and SCREEN 1’s background and palette
KEY ON and KEY OFF (accepted, but no-ops, since BASIC-DOS doesn’t display function keys)
DEF SEG, PEEK, and POKE (DEF SEG alone selects BASIC-DOS’s own data segment, so DONKEY.BAS’s POKE 106,0 is harmless)
RND as a floating-point function (0 <= RND < 1); RND% still returns an integer
String constants with no closing quote at the end of a line
ON ERROR GOTO (and GOTO 0), RESUME line, ERROR, and ERR, with MSBASIC’s error numbers for runtime errors
PLAY (notes, N, O, <, >, L, P, T, MN/ML/MS, and dots; MF/MB are ignored, since music always plays in the foreground)
SOUND frequency,duration
CHAIN file (runs the BAS file, then ends the program; the line number is ignored)
PSET, PRESET, LINE (including LINE -(x,y), B, BF, and an omitted color), PAINT, and DRAW (U, D, L, R, E, F, G, H, M, B, N, C, and S), drawing directly into CGA memory in modes 4-6
GET and PUT (PSET, PRESET, XOR, OR, and AND), using integer arrays (passed by name) in BASICA’s image format, with one 16-bit word per element, so programs that build images by hand (like DONKEY.BAS’s B%) work
Syntax errors report the program’s line number (eg, “Syntax error in line 1160”) instead of the line’s position in the file
Performance: PUT and GET copy whole bytes (shifting and masking each row in registers), horizontal lines, BF, and PAINT fill whole bytes, and the video mode is cached, so graphics statements make no driver or BIOS calls; SOUND returns immediately (as in MSBASIC, the next SOUND waits for it to finish, and the CLOCK$ driver turns it off), so DONKEY.BAS is paced at one loop per tick, like MSBASIC
CIRCLE (for CIRCLE.BAS, one of the other PC DOS 1.00 samples on the demo disk), using MSBASIC’s algorithm and integer math (angles and aspects are converted from doubles without FPU$), so it draws the same pixels as MSBASIC, about twice as fast
CLEAR (resets variables and erases arrays; its sizes are ignored)
PAINT scans rows a byte at a time (using a table of each byte’s boundary pixels), so it’s faster than MSBASIC’s
A BASIC keyword typed alone that isn’t a valid statement (eg, CIRCLE) runs the program with that name (eg, CIRCLE.BAS)
More performance: diagonal lines (and DRAW) still work a pixel at a time, and text output in graphics modes goes through the CON driver and the BIOS
Graphics features that the samples don’t use: STEP coordinates, POINT, DRAW’s A, TA, X, and “=variable” commands, and GET/PUT with floating-point arrays
RESUME and RESUME NEXT (which need the location of the error), and ERL
When a BAS program ends (or is aborted), its video mode is restored (undoing any SCREEN or WIDTH), and when a console returns to its original mode, its original geometry (eg, its border) is restored, too
Keeping other sessions on the same adapter from writing to the screen while it’s in another mode; also, the CON driver restores the BIOS’s video data after every INT 10h call, so programs that read the BIOS’s video mode (0:449h) may see a stale value
Build, Tests, and Documentation
Builds with MASM 4.0 using mk.sh (PC.js), which also updates the BASIC-DOS demo disks after a successful build
STRFUNCS and STRPOOL: BASIC string function tests, and string pool stress and leak tests
ARRAYS: BASIC array tests (including leak tests)
FLOW: BASIC control flow tests
Unattended test runs using tools/tests/quick.sh (boots BASIC-DOS with and without an 8087, runs FPUTESTS, DOSTESTS, STRFUNCS, STRPOOL, ARRAYS, and FLOW, and reports whether the tests passed)
tools/tests/chkdsk.sh runs MS-DOS 3.20 CHKDSK on a diskette image saved by a test session (see QUIT /S in pc.js)
More tests (eg, BASIC language and CMD command tests)
HELP for commands, functions, and constants (eg, HELP MID$), found by searching HELP.TXT, so new entries need no other changes