# Atari Microsoft BASIC

The Atari Microsoft BASIC and Atari Microsoft BASIC II variants of the 6502-version of Microsoft BASIC ported to the Atari 8-bit computers. The first version, released 1981, required 32 KB of RAM and was supplied on floppy disk. The second version, released the next year, had most of the code on a ROM cartridge with additional functions on an optional floppy.
Atari Microsoft BASIC was highly compatible with contemporary BASICs like Applesoft BASIC and Commodore BASIC, in contrast to their own Atari BASIC which was a somewhat different dialect and incompatible in many ways. Like Atari BASIC, Atari Microsoft BASIC included a number of new commands and features to take advantage of the Atari platform. These were only partially compatible with the similar features of Atari BASIC.

## History

When Microsoft ported their originally Intel 8080-based BASIC to the 6502, they took the time to expand the floating-point format from the original 32-bit format to an optional 40-bit format for improved accuracy. Both versions could be compiled from the same code by providing compiler flags; if the 32-bit format used the resulting code was just under 8 KB in length, if the 40-bit format was used, it was closer to 9 KB.
The Atari 8-bit home computers were designed with a slot for an 8 KB ROM cartridge. Atari's programmers struggled to fit Microsoft's BASIC into a single cartridge while also adding features to take advantage of the platform. In the summer of 1978, Atari decided to outsource the porting effort so that BASIC would be ready in time for the 1979 launch of the system, and this led them to Shepardson Microsystems Inc. (SMI). SMI quickly decided the job was impossible, and instead proposed creating an entirely new version of BASIC. This became Atari BASIC and was released with the Atari 400 and 800 in 1979.
Atari continued working with the MS code and released a version of it on floppy disk in 1981. In addition to the extended range of standard commands in MS compared to Atari BASIC, the new version added a number of additional commands for graphics and sound and other features of the platform. It also included integer variables and a complete integer math package which offered improved performance. However, as it required at least 32 KB of RAM and only ran from a disk, it was never particularly popular.
A second release, Atari Microsoft BASIC II, moved most of the code onto an expanded 16 KB cartridge and placed an additional 11 KB of more rarely used code on disk, meaning that many programs intended for cross-platform use could now be run from the cartridge alone. Released in 1982, BASIC II also saw little real-world use.

## Details

The underlying interpreter was based on the same 9 KB MOS 6502 code that also formed the basis of Commodore BASIC and AppleSoft BASIC, and was largely compatible with them. A key aspect of this was the string handling system, which was based on the same code as those platforms. In contrast, Atari BASIC used an entirely different system that treated strings as arrays of characters and was not compatible with, nor easily ported from, most other systems.
It retained the original 40-bit format floating-point arithmetic library that replaced the notoriously slow one in the system's operating system ROMs, and thus ran math code at the same speed as other platforms, and much faster than Atari BASIC. It also included an additional integer math package for added performance. The integer math system was triggered when the assignment was to an integer variable, or the literal values were all integers. If either was not true, the integer values would be converted to floating-point, use the floating-point code for the calculation, and then be converted back to integer for storage.
Examples :
| Division with two integers | Division with integer and floating-point |
| PRINT 3/2 1 | PRINT 3/2.0 1.5 |
Another notable performance-related improvement was related to FOR...NEXT loops. Atari BASIC performed these by placing the line number of the FOR on the execution stack, so when the associated NEXT was encountered it could find which line to loop back to. In contrast, MS BASIC had always placed the memory location of that line on the stack, allowing it to jump back to the FOR without having to search through the entire program for the matching line. This oddity in Atari BASIC is one of the primary reasons for its slow performance, and because this was not true in Atari Microsoft BASIC, it generally ran much faster than Atari BASIC.
In contrast to Atari BASIC, which parsed and tokenized entire lines when they were typed in, MS BASICs only partially tokenized the source code. When a line was entered, the line number was converted from ASCII to a 16-bit integer, the first program statement was tokenized to a single-byte value, and then the rest of the line was left as text format. The last character had its high-bit set to indicate the end of the line. Depending on the use-case, Atari BASIC's complete tokenization of the line could result in less memory being used to store the program. This difference also meant that many syntax errors would only be noticed at runtime in the MS code, unlike the Atari version where the entire line was checked at edit time. In theory, edit-time compilation should have made Atari BASIC much faster than MS, which re-tokenizes the line every time it is encountered, but this advantage was washed away by the other performance issues noted above.
MS BASIC did not include a system for entering short forms of keywords, unlike Atari BASIC which allowed them to be abbreviated with a period during entry. When the program was LISTed, the keywords would be expanded out. Commodore's version which added control-character completion to the same end.
Atari Microsoft BASIC added a number of new features to take advantage of the platform. One interesting addition is AFTER (600) GOTO 100 which waited for the specified number of "jiffies", 1/60ths of a second, and then performed the FOR. It also included the WAIT which instead paused while awaiting a memory address to change before proceeding to the next line. WAIT had been part of the earliest versions of MS BASIC but not widely used.
Atari Microsoft BASIC included most of the graphics and sound commands from Atari BASIC. Oddly, the original DRAWTO was merged into PLOT using the optional PLOT...TO... format. This means graphics code for Atari BASIC was not compatible. Atari Microsoft BASIC added a number of additional commands for handling player/missile graphics and user-defined character sets that were not available in Atari BASIC.
Atari Microsoft BASIC came in two packages:
* Floppy disk – CX8126
* ROM cartridge – RX8035. Since the cartridge could only hold 16 KB, the remaining 11 KB file was included on an "extension" disk. The cartridge version was called Atari Microsoft BASIC II.
Although more feature-filled than Atari BASIC, Microsoft BASIC never had the popularity that Atari BASIC had. The biggest problems were:
* increased memory needed (at least 32 KB)
* disk drive required
* performance (faster than Atari BASIC, but slower than Turbo-Basic XL and BASIC XL)
* not compatible with Atari BASIC
* added cost
The cartridge version eliminated the first two requirements, but a disk drive was needed for all of its features.