Atari ST / TOS

68000 assembly

Registers, a stack, and a few TOS calls are enough to greet the ST desktop.

← All programming languages

Speaking to the 68000

Atari ST assembly language works with the Motorola 68000’s data and address registers. It suits routines that need precise control of instruction flow and memory. TOS services let small programs print text and read keys without directly driving the display hardware.

Example: a TOS console greeting

Atari ST 68000 — Motorola/Devpac-style source
section text
start:
        pea     message(pc)
        move.w  #9,-(sp)
        trap    #1
        addq.l  #6,sp

        move.w  #7,-(sp)
        trap    #1
        addq.l  #2,sp

        clr.w   -(sp)
        trap    #1

        section data
message:
        dc.b    "HELLO FROM THE ATARI ST!",13,10,0
        even
Expected result: a TOS console greetingIllustrative preview
HELLO FROM THE ATARI ST!

Shown while GEMDOS is waiting for a key. The key is not echoed; the program then exits to the desktop. This preview uses a monochrome ST console appearance.

Assemble and link this as a TOS executable, with start as the entry point, using an ST assembler such as Devpac. Save the executable with a .TOS extension and launch it from the desktop. It prints the message, waits for a key, and exits.

TRAP #1 calls GEMDOS. Function 9 writes a zero-terminated string, function 7 reads a key without echoing it, and function 0 terminates the process. The stack adjustments remove each returning call’s arguments. Carriage return and line feed are both included in the message.

Reference: Atari GEMDOS programming documentation (PDF).

Reference: The Atari Compendium — GEMDOS call reference.

Assembler choices

ST development environments included Devpac and Atari’s MADMAC, as well as the AS68 assembler in the original developer kit. The processor instructions remain the same, while section declarations, macros, and executable-building commands vary.

Reference: Atari MADMAC manual (PDF).