The Atari 850 Interface Module: Ports, the R: Handler and XIO Commands

A beige Atari 850 Interface Module seen from the front, with power jack, power light, switch and two SIO sockets

The Atari 400 and 800 had no standard serial or parallel ports, just the SIO bus and joystick jacks. The 850 Interface Module (1980) was Atari's answer: an SIO box with four RS-232-C serial ports and one Centronics-style parallel printer port. For years it was how Atari owners connected modems, serial printers, plotters and other computers. Its software side, the R: device, became the standard that later interfaces and modern devices still imitate. If you write or run comms software today, you're programming the 850's interface even if the hardware is a FujiNet or an emulator.

What you'll learn: what the ports provide, how the R: handler gets from the 850 into memory, the XIO commands that set baud rate, translation and control lines, concurrent mode and its pitfalls, a short BASIC terminal program, and today's alternatives.

What you need: an 850 (or a compatible device or emulator), Atari BASIC, and for a real modem a CX87-type cable. For the background on CIO and XIO, see CIO and IOCBs first.

1. The hardware

Feature Details
Serial ports Four DE-9 female sockets, RS-232-C, wired as terminal equipment (DTE), Atari-specific pinouts
Port 1 Full set: XMT, RCV, DTR, RTS, DSR, CTS, CRX (carrier detect)
Ports 2 and 3 XMT, RCV, DTR, DSR
Port 4 XMT and RCV only; also usable as a 20 mA current loop for teletypes
Printer port DA-15 female, 8-bit parallel, driven by the OS's own P: handler
Inside 6507 processor, two 6532 RIOT chips, 4K ROM holding the R: handler
Power 9 V AC adapter, the same type as the 810 drive and other peripherals

Speeds run from 45.5 to 9,600 baud. Atari sold three cables: CX86 (printer), CX87 (850 to a standard DB-25 modem) and CX88 (850 to another computer or terminal). Early 850s came in a black aluminium case; most are beige plastic.

The printer port needs no extra software, because P: is built into the OS. The serial ports do: the OS has no R: device, so a handler must be loaded into RAM, about 1.7K of it, which raises MEMLO.

2. Getting the R: handler loaded

The handler lives in the 850's ROM and is sent to the computer when asked. There are three ways:

  1. No disk drive. Switch the 850 on, then the computer, with no drive 1 powered. The 850 pretends to be disk drive 1 and the OS "boots" the handler from it. You'll hear a longer-than-usual beep. This is how cartridge-based terminals like TeleLink worked, and it also works with cassette-loaded programs.
  2. With DOS. If a drive is present, it answers the boot and the 850 is ignored. DOS then has to fetch the handler, usually with a small AUTORUN.SYS. Atari DOS 2.0S, DOS 3, DOS 2.5 and DOS XE include this. Turn on the disk drive and the 850 before the computer. On MyDOS 4.53 and later, autorun files are named *.AR0, *.AR1 and so on, and some MyDOS archives include an RS-232 loader.
  3. From a program after boot. Many terminal programs and DOS utilities can request the handler themselves. Altirra's Additions disk has BOOT850.COM for this. It works around the fact that the 850 only answers its poll request once, and skips loading if R: is already installed.

To check, type OPEN #2,13,0,"R:". Error 130 (nonexistent device) means R: isn't loaded.

The handler is incompatible with the original DOS 1. Port configuration survives SYSTEM RESET, but a cold start returns everything to the defaults: 300 baud, 8 data bits, 1 stop bit, no parity checking, light translation, DTR and RTS off.

3. Opening and configuring a port

R: means port 1; R2: to R4: select the others. OPEN's first auxiliary value sets the direction:

AUX1 Meaning
5 input only (concurrent mode)
8 output only (block mode)
9 output only (concurrent mode)
13 input and output (concurrent mode)

Configuration is done with XIO. You may configure a port through an unopened channel, but if a channel is already open to that port you must use it. All configuration must happen before concurrent mode starts.

XIO 36: baud, word size, stop bits, handshake checking. XIO 36,#ch,AUX1,AUX2,"Rn:". AUX1 is the sum of a baud code, a word-size value and an optional stop-bit value:

Baud code Rate Baud code Rate
0 or 8 300 11 1,800
5 110 12 2,400
6 134.5 13 4,800
7 150 14 or 15 9,600
9 600 1–4 45.5, 50, 56.875, 75 (teletype rates)
10 1,200

Add 0 for 8-bit words, 16 for 7 bits, 32 for 6 or 48 for 5, and add 128 for two stop bits. AUX2 asks the 850 to check incoming lines before sending: add 4 for DSR, 2 for CTS and 1 for CRX (carrier). XIO 36,#2,10,0,"R:" sets 1,200 baud, 8 bits, one stop bit, no checks. Words shorter than 8 bits can only be sent in block mode, and only received at 300 baud or below.

XIO 38: translation and parity. AUX1 is the sum of:

  • Translation: 0 = light (the default), 16 = heavy, 32 = none. Both light and heavy turn ATASCII EOL (155) into ASCII CR (13) on output and CR into EOL on input, and clear the top bit. Heavy translation also replaces anything that isn't printable ASCII with a "won't translate" character, which is set by AUX2.
  • Input parity: 0 = leave alone, 4 = check odd, 8 = check even, 12 = just clear the parity bit.
  • Output parity: 0 = leave alone, 1 = odd, 2 = even, 3 = set the bit to 1.
  • Append LF: 64 sends a line feed after every CR.

So XIO 38,#2,32,0,"R:" gives a binary-clean channel for file transfers, and XIO 38,#2,64,0,"R:" is light translation with CR/LF line endings.

XIO 34: control lines. Add one value per line: DTR 128 = off, 192 = on; RTS 32 = off, 48 = on; XMT 2 = space, 3 = mark (0 leaves a line unchanged). XIO 34,#2,192,0,"R:" raises DTR, which many modems need before they answer. Holding XMT at space for a moment, then mark, sends a BREAK.

XIO 32: force short block. In block mode, output collects in a 32-byte buffer and goes out when the buffer is full, when a CR is buffered, or when you CLOSE. XIO 32 sends what's there now.

4. Concurrent mode: XIO 40

Block mode can only send. To receive, you must start concurrent mode: OPEN the port with 5, 9 or 13, configure it, then:

XIO 40,#2,0,0,"R:"

With both AUX values zero, the handler uses its own 32-byte input buffer. (The 850 manual also shows how to supply a bigger buffer by POKEing the IOCB and calling CIO through a USR routine.) From then on, incoming characters land in the buffer while your program carries on, and GET, INPUT, PUT and PRINT work on the channel. STATUS #2,S then leaves the number of characters waiting in locations 747–748, and the number waiting to be sent in 749.

The rules are strict, because concurrent mode takes over the serial bus:

  • No other SIO I/O while it runs: no disk, no printer, not even another 850 port. The keyboard and screen are fine.
  • CLOSE the R: channel first. CLOSE is the only way to end concurrent mode from a program. If BASIC closes channels for you at END, it may close another one first, and the computer hangs.
  • STOP and BASIC errors don't end concurrent mode. Press BREAK.
  • INPUT waits for an EOL, so keep translation on (or use GET) when the other end sends CR line endings.
  • BASIC is slow. Read whole lines with INPUT where you can. At 300 baud up to 30 characters arrive per second; at 4,800 baud it's 480.

5. A minimal terminal in BASIC

This program turns the Atari into a dumb terminal on port 1 at 1,200 baud. Characters from the modem or remote computer are printed; keys you press are sent.

10 REM MINIMAL 850 TERMINAL
20 OPEN #1,4,0,"K:"
30 XIO 36,#2,10,0,"R1:"
40 XIO 38,#2,0,0,"R1:"
50 OPEN #2,13,0,"R1:"
60 XIO 40,#2,0,0,"R1:"
70 PRINT "ONLINE - BREAK TO QUIT"
80 STATUS #2,S
90 IF PEEK(747)=0 THEN 120
100 GET #2,C
110 PRINT CHR$(C);
120 IF PEEK(764)=255 THEN 80
130 GET #1,K
140 PUT #2,K
150 GOTO 80

Lines 30–40 configure port 1 through channel 2 before it's opened: 1,200 baud (code 10), 8 bits, one stop bit, light translation. Line 50 opens it for full duplex, and line 60 starts concurrent mode. The loop asks for STATUS. If location 747 shows characters waiting, it fetches and prints one. Location 764 (CH) holds 255 when no key has been pressed, so the keyboard is only read when there's a key to send. Light translation turns the remote CR into an Atari EOL. The program doesn't echo your typing, so remote systems that echo (most BBSes) will show it for you. Press BREAK to quit, which also ends concurrent mode.

In the atari800 emulator, run with -rdevice, lines 20–70 execute without error. Its simulated R: device, however, reports line states in 747 instead of a buffer count, so the receive loop needs a real 850 or a fuller 850 emulation. Use a terminal program such as those below for real work. They use machine language to keep up at higher speeds.

6. Modern alternatives

  • ICD P:R: Connection (1986): a compact SIO box with two 850-style serial ports (R1:, R2:) and a printer port. Its R: handler is in ROM and largely 850-compatible. ICD's MIO board also has an 850-compatible port.
  • R-Verter (1984) and its SupraVerter successor: a cable straight from SIO to a modem, with software R: handlers. Several modern Wi-Fi modems, such as SIO2WiFi, are R-Verter-compatible.
  • FujiNet: emulates the 850's R: modem device, including the poll that loads the handler, connects "calls" over Wi-Fi, and adds commands such as listening on a TCP port and locking the baud rate for BBS use.
  • APE and SIO2PC-type cables: APE answers the 850 handler request and provides an R: modem on the PC while still serving disk images during concurrent I/O.
  • Altirra: emulates the 850 at three levels. None and Minimal use a built-in high-level R: handler that costs no Atari memory. Full emulates the 850 itself, with its 6502 handler booted over SIO. The emulated port has a Hayes-style modem: ATDI hostname port makes a TCP connection, with optional Telnet handling, and an option enables the extra 57,600–230,400 baud XIO 36 codes that atari800 also understands.
  • A real 850 with a modern "modem": a serial-to-Ethernet device server, such as the Lantronix UDS series, plugged into a CX87 cable acts as an Internet modem.

Troubleshooting

  • ERROR 130 on OPEN "R:". The handler isn't loaded. Check the power-on order, your AUTORUN.SYS, or run a handler loader.
  • Machine hangs when the program ends. Concurrent mode was still active when another channel closed. Always CLOSE the R: channel first.
  • Garbage on screen. The baud rate or word size doesn't match the other end. Check XIO 36.
  • INPUT never returns. No EOL is arriving: switch translation on, or use GET.
  • Modem ignores commands. Raise DTR with XIO 34,#2,192,0,"R:", check the CX87 cable is on port 1, and make sure the modem's DSR, CTS and CRX settings match your XIO 36 checks.

Further reading

  • Atari 850 Interface Module Operator's Manual (1980 edition, about 100 pages): the full XIO tables and appendices on concurrent mode, plus sample programs including a Baudot terminal.
  • Atari 850 Interface Module Technical Manual (1982).
  • Ian Chadwick, Mapping the Atari: locations 746–749 (DVSTAT) and the IOCB command table.
  • comp.sys.atari.8bit FAQ, sections 5.1.4–5.1.5 and 5.2.1–5.2.2.
  • On this site: CIO and IOCBs, SIO Explained, FujiNet Setup Guide.

Credits