Atari Microsoft BASIC: A Guide for Atari BASIC Programmers
Atari sold two Microsoft BASICs for the 8-bit line. Atari Microsoft BASIC (CX8126, manual © 1981) loaded from disk. Atari Microsoft BASIC II (spring 1983) put the interpreter on a 16K cartridge, with an Extension Diskette for extra commands. Both belong to the same Microsoft family as the Apple II, TRS-80 and Commodore PET BASICs of the day, which made the flood of Microsoft-dialect listings in books much easier to bring across. This guide is for people who know Atari BASIC and want to read, convert or write Microsoft BASIC programs. For the product history, see the software entry Atari Microsoft BASIC.
What you'll learn: what you need to run each version, the big differences in strings, numbers and variables, the control-flow extras (ELSE, AFTER, ON ERROR), how graphics and sound commands map across, how to convert an Atari BASIC program, and how the 2025 open-source release of Microsoft's 6502 BASIC relates to the Atari versions.
What you need: the disk version and an Atari 800 with at least 32K and a disk drive (all cartridges removed), or the Microsoft BASIC II cartridge, which runs on 16K. The Extension Diskette needs an 810-compatible drive and Atari DOS 2.0S. In an emulator, use disk or cartridge images of the originals. The examples below were checked against the manual; no Microsoft BASIC image was available to run them.
1. Getting started
The disk version boots straight from its write-protected master disk. Its setup routine has you format a working disk and copy DOS, MEM.SAV and the support files to it. MEM.SAV matters: when you type DOS, it saves part of BASIC and your program, so that both come back when you return. BASIC II starts as soon as the cartridge is in, and its DOS menu option B ("run cartridge") takes you back to BASIC. With the Extension Diskette in drive 1 at power-on, it loads the extra commands too. Its prompt is > rather than Atari BASIC's READY.
Programs are saved and loaded with SAVE/LOAD (disk) and CSAVE/CLOAD (cassette). SAVE "D:PROG" LOCK stores a program in a form that can't be listed or edited, and LOCK, UNLOCK, KILL and NAME … TO handle files without visiting DOS. Editing aids include AUTO line numbering, RENUM, DEL, MERGE and TRON/TROFF. Line numbers run up to 63999, compared with 32767 in Atari BASIC.
2. Strings work the Microsoft way
This is the biggest change. In Microsoft BASIC a string variable is dynamic: you just assign to it, and it can hold up to 255 characters. There is no DIM A$(20). In fact DIM A$(35) means something completely different: an array of 35 string elements. Strings join with +, and the familiar functions are all there:
| Microsoft BASIC | Atari BASIC equivalent |
|---|---|
LEFT$(A$,3) |
A$(1,3) |
MID$(A$,5,5) |
A$(5,9) |
RIGHT$(A$,4) |
A$(LEN(A$)-3) |
A$+B$ |
A$(LEN(A$)+1)=B$ |
INSTR(1,A$,B$) |
a FOR loop comparing substrings |
STRING$(20,"*") |
a FOR loop, or the self-copy trick |
INKEY$ |
PEEK(764) and a lookup table |
TIME$ |
arithmetic on RTCLOK |
INSTR(start,A$,B$) returns the position of B$ in A$ or 0. INKEY$ returns the last key pressed, or an empty string. It trims spaces, so it can't detect the space bar. TIME$ returns "HH:MM:SS" and keeps counting once you set it. A doubled quote ("") puts a quote mark inside a string.
10 DEFINT I
20 DIM N$(3)
30 FOR I=1 TO 3: READ N$(I): NEXT I
40 DATA RED,GREEN,BLUE
50 A$=N$(1)+","+N$(2)+","+N$(3)
60 PRINT A$;" HAS";LEN(A$);"CHARACTERS"
70 P=INSTR(1,A$,"GREEN")
80 IF P>0 THEN PRINT "GREEN STARTS AT";P ELSE PRINT "NO GREEN"
90 PRINT LEFT$(A$,3);" ";MID$(A$,5,5);" ";RIGHT$(A$,4)
It prints RED,GREEN,BLUE HAS 14 CHARACTERS, then GREEN STARTS AT 5, then RED GREEN BLUE. Notice the spacing: Microsoft BASIC prints positive numbers with a leading blank and a space after them, so " HAS";LEN(A$);"CHARACTERS" needs no extra spaces. Unquoted words in DATA statements are read as strings, unless they contain a comma.
3. Numbers and variables
Atari BASIC has one number type: six-byte BCD floating point. Microsoft BASIC has three, chosen by a suffix or a DEF statement:
| Type | Suffix | Storage | Range or precision |
|---|---|---|---|
| Integer | % |
2 bytes, binary | −32768 to 32767 |
| Single precision (default) | none | 4 bytes | about 6 significant figures, exponent ±38 |
| Double precision | # |
8 bytes | 16 digits (constants written with D, e.g. 45D5) |
| String | $ |
up to 255 characters |
DEFINT I-N makes every variable starting with I to N an integer. DEFSNG, DEFDBL and DEFSTR work the same way, and a suffix always overrides the DEF rule. Integers are stored as 2-byte binary values, which suits loop counters and array indexes.
Variable names can be up to 127 characters long and may contain underscores (AN_ARRAY). Hexadecimal constants start with & (&D40B) instead of Atari BASIC's decimal-only numbers.
Arrays don't need a DIM for up to 10 elements, can have many dimensions, and start at element 0 unless you write OPTION BASE 1. Comments can follow a statement with ! or ' as well as REM.
4. Control flow extras
- IF … THEN … ELSE on one line:
250 IF R<Y THEN 450 ELSE 200.GOTOafter THEN is optional. - ON ERROR GOTO, with
ERR,ERL,RESUMEandERROR n, replacesTRAP. - AFTER (jiffies) GOTO line sets a timer in sixtieths of a second (up to 24 hours) that jumps to a line when it runs out.
CLEAR STACKcancels it. - WAIT address,mask,value pauses until a memory location matches. The manual's example waits for the vertical blank:
WAIT &D40B,&FF,110.
A five-second timed prompt shows AFTER and INKEY$ together:
10 AFTER (300) GOTO 100
20 PRINT "PRESS A KEY WITHIN 5 SECONDS"
30 K$=INKEY$: IF K$="" THEN 30
40 CLEAR STACK
50 PRINT "YOU PRESSED ";K$: END
100 PRINT "TOO SLOW!"
110 END
5. Graphics, sound and I/O
The graphics and I/O commands are where conversions take most work. From the conversion table in the original manual:
| Atari BASIC | Atari Microsoft BASIC |
|---|---|
DRAWTO x,y |
PLOT x,y TO x,y |
XIO 18 fill |
FILL x,y TO x,y |
LOCATE x,y,v |
v=SCRN$(x,y) |
POSITION x,y : PRINT #6 |
PRINT #6, AT(x,y) |
SETCOLOR 0–4 |
SETCOLOR 4–8 (0–3 now set the player colours) |
ADR(A$) |
VARPTR(A$) |
CLR |
CLEAR |
LPRINT |
OPEN #7,"P:" OUTPUT then PRINT #7 |
TRAP n |
ON ERROR GOTO n |
USR(addr,a,b,…) |
USR(addr,pointer): one argument only |
SOUND v,p,d,vol |
SOUND v,p,d,vol,duration (duration in jiffies) |
STICK, STRIG, PADDLE, PTRIG |
PEEK the OS shadow locations |
POP, DEG |
not available |
Files open with a mode word: OPEN #1,"D:DATA" INPUT. NOTE survives, and INPUT #1,AT(sector,byte) replaces POINT. MOVE from,to,count copies memory, and the manual suggests it for player/missile work. OPTION PLM1 (1,280 bytes) or OPTION PLM2 (640 bytes) reserves player/missile memory after a GRAPHICS statement, and OPTION CHR1/CHR2 reserve 1,024 or 512 bytes for a RAM character set.
6. Converting programs
Atari BASIC's tokenised SAVE files mean nothing to Microsoft BASIC. Bring programs across as text instead: LIST "D:PROG.LST" in Atari BASIC, then LOAD the listing in Microsoft BASIC. The manual promises that it "should run" after "a few changes". In practice:
- Delete string DIMs, or they become arrays. Then rewrite substring references such as
A$(3,5)asMID$(A$,3,3). - Rework the commands in the table above, especially SETCOLOR numbers and joystick reads.
- Add
RANDOMIZEif you want RND to behave like Atari BASIC's, as the manual advises. - Watch line numbers: anything above 63999 needs renumbering.
The original manual also has appendices on converting from Commodore PET, TRS-80 and Applesoft BASIC, which shows who the product was aimed at.
7. The open-source connection
On 3 September 2025 Microsoft published the source of BASIC M6502 8K Version 1.1 on GitHub under the MIT licence. It is a close relative of the Atari products rather than their source: the code assembles for the Apple II, Commodore PET, Ohio Scientific and KIM-1, plus a PDP-10 simulation, but has no Atari target. This is the BASIC Atari licensed in 1978 for the cancelled "Atari Disk BASIC" before Atari BASIC was chosen. The news item Microsoft Open-Sources 6502 BASIC tells the story. Michael Steil's msbasic project, which rebuilds the code for many machines with the cc65 assembler, is the place to start if you want to experiment.
Troubleshooting
- "Out of memory" with a modest program. The disk version loads the whole interpreter into RAM next to DOS. 32K is the official minimum, but a 48K machine leaves far more room, and high-resolution graphics modes eat into it.
- A converted program prints garbage strings. A leftover
DIM A$(n)created an array: delete it. - Colours come out wrong. SETCOLOR register numbers moved up by four.
- Joystick code never responds. There are no STICK or STRIG functions, so
STICK(0)is just an element of an undimensioned array. PEEK the OS shadows instead: 632 for stick 0, 644 for trigger 0. - Can't get back from DOS. MEM.SAV is missing or was invalidated (DOS's duplicate-disk function asks permission to overwrite it). Reboot from the working disk.
Further reading
- Atari Microsoft BASIC Instruction Manual (Atari, 1981), especially Appendix J, "Converting Atari 8K BASIC to Atari Microsoft BASIC".
- Atari Microsoft BASIC II Reference Manual, User Guide and Quick Reference Guide (Atari / Microsoft, 1982–83).
- The microsoft/BASIC-M6502 and mist64/msbasic repositories on GitHub, and Michael Steil's pagetable.com article on Microsoft BASIC.
- On this site: the software entry Atari Microsoft BASIC, Atari BASIC String Handling and Tricks, BASIC XL and BASIC XE: A Programmer's Guide and Atari BASIC Essentials.
Credits
- Picture: The Atari Microsoft BASIC II reference manual. The original disk version had its own instruction manual (CX8126). — Cover of the Atari Microsoft BASIC II Reference Manual (Atari, Inc.; scan from a local manual collection)
- Atari Microsoft BASIC Instruction Manual (CX8126, Atari 1981) — loading instructions, constants and variables, strings, arrays, statements, AFTER/CLEAR STACK, WAIT, OPTION PLM/CHR, SAVE...LOCK, Appendix J (converting Atari 8K BASIC) — Internet Archive, 1981
- comp.sys.atari.8bit FAQ (Michael Current) — Atari history timeline (Microsoft BASIC licence 1978, Atari Disk BASIC cancelled, Atari Microsoft BASIC shipped early 1982, Microsoft BASIC II spring 1983) — Michael Current (comp.sys.atari.8bit FAQ), 1978
- GitHub — microsoft/BASIC-M6502 README (Version 1.1, REALIO targets) and licence (MIT) — GitHub project authors
- AtariAge — Microsoft's 6502 BASIC is now Open Source (no Atari target) — AtariAge forum members
- Mapping the Atari (revised) — 632 STICK0, 644 STRIG0, 764 CH — AtariArchives.org
