SIO Operations
The Atari Serial Input Output interface is the low-level interface between the Atari 8-bit computers and the serial peripherals, like disk-drives and modems.
Overview
SIO (Serial Input/Output) is the protocol used by the Atari 8-bit computers to communicate with peripheral devices such as:
- Disk drives
- Modems
- Printers
- Network adapters (FujiNet)
- Other serial devices
SIO Statement
SIO ddevic, dunit, dcomnd, dstats, dbuf, dtimlo, dbyt, daux1, daux2
Send Any Command Over SIO
This function can be used to send any SIO command to any SIO device. For example, this command is used to read or write one sector in a floppy disk, or send special commands to a FujiNet network device.
Parameters
| Parameter | Description |
|---|---|
| DDEVIC | Device # (e.g. $71) |
| DUNIT | Unit # |
| DCOMND | Command # ($00-$FF) |
| DSTATS | Read($40) / Write($80) |
| DBUF | Target buffer address |
| DTIMLO | Timeout value |
| DBYT | # of bytes in payload |
| DAUX1 | First Aux parameter |
| DAUX2 | Second Aux parameter |
The meanings of each of these is highly dependent on the target device.
Example: Reading a Disk Sector
DIM sector(128) BYTE ' Read sector 360 from drive 1 SIO $31, 1, $52, $40, ADR(sector), 64, 128, 360, 0 IF SERR() <> 1 THEN ? "Error reading sector"
Example: Writing a Disk Sector
DIM sector(128) BYTE ' Write sector 360 to drive 1 SIO $31, 1, $57, $80, ADR(sector), 64, 128, 360, 0 IF SERR() <> 1 THEN ? "Error writing sector"
SERR() Function
SERR() / SE.
Get Last SIO Error Function
This function returns the value in DSTATS, which contains the error of the last SIO operation from the device.
In the context of the FujiNet device, can be used, along with DVSTAT+4 to determine any error from a network operation.
Example:
SIO $71, 1, $FF, $40, ADR(buffer), 64, 0, 0, 0 IF SERR() <> 1 THEN ? "SIO error: "; SERR() ENDIF
Common SIO Commands
Disk Drive Commands
| Command | Value | Description |
|---|---|---|
| Get Status | $53 | Read drive status |
| Read Sector | $52 | Read a sector |
| Write Sector | $57 | Write a sector |
| Write Sector with Verify | $57 | Write and verify |
Device IDs
Common device IDs:
$31- Disk drive (D1:)$71- FujiNet device$50- Printer$60- Modem
Error Handling
Always check SERR() after an SIO operation:
SIO $31, 1, $52, $40, ADR(buffer), 64, 128, 360, 0 IF SERR() <> 1 THEN ? "SIO Error: "; SERR() ' Handle error ENDIF
Timeout Values
The DTIMLO parameter specifies the timeout value. Common values:
64- Standard timeout128- Longer timeout for slow devices32- Shorter timeout for fast operations
Buffer Management
The DBUF parameter must point to a valid memory buffer. Use ADR() to get the address of arrays:
DIM buffer(256) BYTE SIO $31, 1, $52, $40, ADR(buffer), 64, 256, 0, 0
Advanced Usage
Sector Addressing
For disk drives, sectors are typically addressed using:
DAUX1- Sector number (low byte)DAUX2- Sector number (high byte) or additional parameter
Example:
' Read sector 720 (high byte = 2, low byte = 208) SIO $31, 1, $52, $40, ADR(buffer), 64, 128, 208, 2
Multiple Sector Operations
For reading/writing multiple sectors, you may need to call SIO multiple times or use device-specific commands.
FujiNet Integration
SIO is heavily used with FujiNet devices. See FujiNet for more details on network operations.
Example:
' FujiNet status command SIO $71, 1, $E0, $40, ADR(status), 64, 4, 0, 0
Best Practices
- Always check errors - Use
SERR()after every SIO call - Use appropriate timeouts - Adjust
DTIMLOfor your device - Validate buffer sizes - Ensure
DBYTmatches your buffer - Handle device-specific behavior - Different devices interpret parameters differently
- Test thoroughly - SIO operations can be device-dependent
Troubleshooting
SIO fails immediately:
- Check device ID is correct
- Verify device is connected and powered
- Check unit number is valid
Timeout errors:
- Increase
DTIMLOvalue - Check device is responding
- Verify cable connections
Data corruption:
- Verify buffer address is correct
- Check buffer size matches
DBYT - Ensure buffer is not overwritten during operation
Related Topics
- FujiNet - Network operations with FujiNet
- CIO Reference - Higher-level I/O operations
- XIO Reference - Extended I/O commands
- Low-Level Programming - Memory operations