QDOS Internals

Internal I/O Memory Map

On the original QL, there is an area from $18000 to $1BFFF in the memory map set aside for internal I/O. These memory addresses and decoded by the hardware devices attached and used to control these devices. The following gives details of which 'port' is used and for which device. Be aware that all ports are byte sized (unless I tell you diffferent) and that reading and writing them directly can cause problems.

PortQDOS MnemonicSMS MnemonicDescription
$18000 PC_CLOCK Real-time clock (Long word)
$18002 PC_TCTRL Transmit control register
$18003 PC_IPCWR IPC port - write only
$18020 PC_IPCRD IPC port - read only
$18020 PC_MCTRL Microdrive control register - write only
$18021 PC_INTR Interrupt register
$18022 PC_TDATA Transmit register - write only
$18022 PC_TRAK1 Read microdrive track 1
$18023 PC_TRAK2 Read microdrive track 2
$18063 MC_STAT Master chip status register

Problem areas

OK, I have a couple of problems with this documentation.

The first is, if these ports are mapped onto a memory address, how come PC_CLOCK is a long word (4 bytes) and yet is mapped to 2 bytes $18000 and $18001 ?

The second may be explained by this. Note that PC_TDATA and PC_TRAK1 share an address. Is this the reason why you cannot use the serial ports when a microdrive is running ?

You will note that although only a few addresses are used for the hardware ports, the entire block of memeory from $18000 to $1BFFF is set aside - what has happened to the other (nearly) 16Kb of RAM ?

The answer is simple, in order to keep costs down, less address lines that were required were used to decode the port address and this causes 'shadows' to appear all through this 16Kb of RAM. The RAM is unusable as it will inflict serious hardships on the devices.

Using the hardware

The hardware ports cannot really be used from within a user program. At least, not usefully (according to Andy Pennell).

There are of course, a couple of exceptions.

The clock long word can be read and contains the date and time in seconds as a 32 bit integer. Zero represents January 1 1961 at 00:00:00.

If you attempt to write to the clock port, you will effectively reset it to zero. Use the proper QDOS routine, manager trap (MT_SCLCK), to set the clock.

The other exception is the master chip status port which you can only write to. This controls the screen and the data written is as follows :

Bit Purpose
1 0 = Screen on
1 = Screen off
3 0 = 4 colour (mode 4)
1 = 8 colour (mode 8)
7 0 = Use screen 0 (allegedly at $20000)
1 = Use screen 1 (allegedly at $280000)

A copy of this register is stored at affset $34 in the system variables