Close

Command line parameters OS-9

A project log for 6809/6309 Eurocard CPU System

A retrosystem based on the elegant 8/16 bit 6809 processor capable of running UniFLEX and OS9 level II multiuser/multitasking OS

roelof4roelof4 4 days ago0 Comments

In OS-9 for the 6809, command line parameters are passed to a program through a specific convention using the process's data area and registers at startup.

At Program Entry, the CPU Registers Contain:

The Parameter String

The parameter string is a raw text buffer containing everything typed after the command name on the shell line. For example, typing:

myprogram foo bar -x

...results in X pointing to foo bar -x, with D holding its byte length.

Key characteristics of the parameter string:

Memory Layout at Entry

Low address
┌─────────────────────┐  ← U (data area base / stack bottom)
│   Program Stack     │
│         ↓           │
│    (grows down)     │
│                     │
│   Static Data       │
└─────────────────────┘  ← Y (top of data area)
High address

Separately, in system buffer:
┌─────────────────────┐  ← X
│  "foo bar -x\r"     │  (D bytes long)
└─────────────────────┘

Parsing Responsibility

OS-9 does no parsing for you. Unlike Unix which gives you argc/argv, OS-9 hands you the raw string and leaves tokenization entirely to the program (or to a library like the one in the C runtime). You walk the string byte by byte, using the length in D as your bounds, splitting on spaces or other delimiters as needed.

Standard I/O

At entry, the program's standard I/O paths are already open:

These are inherited from the shell and ready to use via OS-9 I$Read / I$Write system calls.

This convention is quite minimal and low-level compared to later systems, which is typical of OS-9's design philosophy of keeping the kernel small and fast on 8/16-bit hardware.

Discussions