[an error occurred while processing this directive] [an error occurred while processing this directive] PDP-8 Console Teletype Instructions [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]
[an error occurred while processing this directive] (none)
   [an error occurred while processing this directive]

The Digital Equipment Corporation PDP-8

[an error occurred while processing this directive]

Console Teletype Instructions

[an error occurred while processing this directive] Part of [an error occurred while processing this directive] the PDP-8 Programmer's Reference Manual
[an error occurred while processing this directive] See also [an error occurred while processing this directive] (none)
[an error occurred while processing this directive] [an error occurred while processing this directive] (none) Douglas W. Jones [an error occurred while processing this directive] (none)
[an error occurred while processing this directive] (none)
THE UNIVERSITY OF IOWA Department of Computer Science [an error occurred while processing this directive] and (none) [an error occurred while processing this directive]

(none) [an error occurred while processing this directive]

Copyright © (none) This work may be transmitted or stored in electronic form on any computer attached to the Internet or World Wide Web so long as this notice is included in the copy. Individuals may make single copies for their own use. All other rights are reserved.

[an error occurred while processing this directive]
[an error occurred while processing this directive]

This document describes the console teletype interface of early PDP-8 models, the KL8E (M865 and M8650) asynchronous interface, and the KL8JA (M8655) asynchronous interface. The console terminal and asynchronous line interfaces on the VT78 were upward compatable from the interface described here. The LC8E (M8329) parallel DECwriter interface is also compatable.

Index


Device Registers

The console teletype interfaceand other asynchronous device interfaces consist of two largely independent devices, described conventionally as the keyboard input device and the teleprinter output device. The computer interacts with these devices through 16 IOT instructions; these instructions, in turn, reference the registers described below.

Note: Most of these registers are accessed via the accumulator; such registers are illustrated as their contents appears when loaded in the accumulator.

Keyboard Buffer

            00 01 02 03 04 05 06 07 08 09 10 11
            ___________________________________
           |  |  |  |  |  |  |  |  |  |  |  |  |
           |__|__|__|__|__|__|__|__|__|__|__|__|
           |           |                       |
           |ER PE FE OE|    Keyboard Buffer    |
           |  Status   |                       |
The keyboard buffer register holds the character most recently read from the asynchronous input channel. While a character is being read, the contents of this register are unpredictable.

The status field is only supported by the KL8JA (M8655) asynchronous interface, and then, only if the SWD jumper is present and if the device control register is set to enable status reporting. The status bits are:

If the status field is not present or status reporting is disabled, these bits are zero.

Keyboard Flag

The keyboard flag bit is set when a character has been read into the keyboard buffer. The console-reset or power-on operation clears this flag. If interrupts are enabled, this flag generates an interrupt request when set.

Teleprinter Buffer

            00 01 02 03 04 05 06 07 08 09 10 11
            ___________________________________
           |  |  |  |  |  |  |  |  |  |  |  |  |
           |__|__|__|__|__|__|__|__|__|__|__|__|
           |           |                       |
           |  Ignored  |    Keyboard Buffer    |
The teleprinter buffer register holds the character that is to be output to the asynchronous interface. Modifying this register while it is being used to generate output may produce unpredictable results, but on early models of the asynchronous interfaces (prior to the M8655), repeatedly writing zero to this register was an effective way to emulate the pressing of the break key on a teletype.

Teleprinter Flag

The teleprinter flag bit is set when the character most recently loaded in the teleprinter buffer has been output. The console-reset or power-on operation clears this flag. If interrupts are enabled, this flag generates an interrupt request when set.

Device Control Register

            00 01 02 03 04 05 06 07 08 09 10 11
            ___________________________________
           |  |  |  |  |  |  |  |  |  |  |  |  |
           |__|__|__|__|__|__|__|__|__|__|__|__|
           |                             |     |
           |           ignored           |SE IE|
This register is not present in PDP-8 console interfaces prior to the PDP-8/E and the KL8E (M865 and M8650) only supports the IE bit, while the KL8JA (M8655) supported both bits.

Instruction Format and Device Addresses

            00 01 02 03 04 05 06 07 08 09 10 11
            ___________________________________
           | 1| 1| 0|  |  |  |  |  |  |  |  |  |
           |__|__|__|__|__|__|__|__|__|__|__|__|
           |        |                 |        |
           |  IOT   |      Device     |   Op   |
The console teletype is usually connected as devices 03 and 04, however, the KL8/E (M8650) interface common on the PDP-8/E and later models could be jumpered to support any two device codes. The following table lists the most commonly used device codes for serial interfaces:
                          |  input | output |
                          |   xx   |   yy   |
           ---------------|--------|--------|
           Console TTY    |   03   |   04   |
           Second TTY     |   40   |   41   |
           Serial printer |   65   |   66   |
           ---------------|--------|--------|
           VT78 serial #1 |   30   |   31   |
           VT78 serial #2 |   32   |   33   |
           ---------------|--------|--------|
           DECmate printer|   32   |   33   |
By convention, no matter what device codes are used, the input device code x is always one less than the output device code y. The serial printer port at address 66 is a special case; 66 is the address commonly used for the parallel printer interface, and by a combination of luck and crafty design, the commonly used coding conventions for output to a parallel printer happen to work for a serial interface.

Input Instructions

6xx0 - KCF Keyboard Clear Flags

	KCF

The keyboard flag, signalling input data ready, is cleared. This operation is not supported by the console interfaces on PDP-8 models prior to the PDP-8/E, and thus should be avoided in portable code.

6xx1 - KSF Keyboard Skip if Flag

	KSF

If the keyboard flag is set, indicating that input data is ready, the next instruction in sequence is skipped. All PDP-8 console interfaces support this operation.

On the DECmates, this operaton resets the flag, and the flag cannot be set again until the character has been read out of the keyboard buffer. This is a source of some compatability problems!

6xx2 - KCC Keyboard Clear and read character

	KCC

The keyboard flag is reset, the accumulator is cleared, and the process of reading the next character of input is initiated (in those cases where the interface is connected to a paper-tape reader). All PDP-8 console interfaces support this operation.

6xx4 - KRS Keyboard Read Static

	KRS

The 8-bit character in the keyboard buffer is ored with the accumulator. All PDP-8 console interfaces support this operation.

6xx5 - KIE Keyboard Interrupt Enable

	KIE

The accumulator is loaded into the device control register (the interrupt enable and status report control bits). This operation is not supported by the console interfaces on PDP-8 models prior to the PDP-8/E, and thus should be avoided in portable code.

6xx6 - KRB Keyboard Read and begin next read

	KRB

The 8 bit character in the keyboard buffer is transferred to the accumulator, and the keyboard flag is cleared, allowing the reading of the next character to begin. In effect, this operation combines the KCC and KRS operations; in early PDP-8 models, this was implemented as a microcoded combination of these operations. All PDP-8 console interfaces support this operation.

Output Instructions

6yy0 - TFL Teleprinter Flag set

	TFL

The printer flag, signalling output complete, is set. This operation is not supported by the console interfaces on PDP-8 models prior to the PDP-8/E, and thus should be avoided in portable code.

6yy1 - TSF Teleprinter Skip if Flag

	TSF

If the printer flag is set, indicating output is complete, the next instruction in sequence is skipped. All PDP-8 console interfaces support this operation.

6yy2 - TCF Teleprinter Clear Flag

	TCF

The printer flag is reset. All PDP-8 console interfaces support this operation.

6yy4 - TPC Teleprinter Print Character

	TPC

The least significant 8-bits of the accumulator is copied to the print buffer, initiating output. All PDP-8 console interfaces support this operation.

6yy5 - TSK Teleprinter Skip

	TSK

If either the print flag or the keyboard flag are set, the next instruction in sequence is skipped. This operation is not supported by the console interfaces on PDP-8 models prior to the PDP-8/E, and thus should be avoided in portable code.

6yy6 - TLS Teleprinter Load and start

	TLS

The least significant 8 bits of the accumulator are copied to the print buffer, initiating output, and the printer flag is reset. In effect, this operation combines the TCF and TPC operations; in early PDP-8 models, this was implemented as a microcoded combination of these operations. All PDP-8 console interfaces support this operation.

Programming Conventions

Typical PDP-8 assembly language programs begin by defining the necessary IOT instructions. In the case of console terminal input-output, most PDP-8 assemblers predefine these symbols appropriately, as follows:
	KSF=	6031	/ Keyboard Skip if Flag
	KCC=	6032	/ Keyboard Clear and read Character
	KRS=	6034	/ Keyboard Read Static
	KRB=	6036	/ Keyboard Read and Begin next read
	TSF=	6041	/ Teleprinter Skip if Flag
	TCF=	6042	/ Teleprinter Clear Flag
	TPC=	6044	/ Teleprinter Print Character
	TLS=	6046	/ Teleprinter Load and Start

One problem with the design of the TTY interface is that the teleprinter flag, like all device flags, is cleared on reset and powerup, but for many purposes, it would be better to have this flag set, indicating that, at startup time, the teleprinter buffer register is ready to receive one character of output. The traditional startup code accomplishes this by outputting a null:

	/ initialize the teletype for output
		CLA
		TLS		/ output null
On the PDP-8/E and more recent machines, the need to output a character as part of the startup sequence was eliminated by the introduction of the TFL instruction. This can be substituted for the above in code intended only for use only on the PDP-8/E and later machines.

Given this initialization, the following two subroutines (or variations on them) are commonly used in most PDP-8 programs for polled console input-output:

	TTYIN,	.-.		/Read from TTY
	/			  returns character in ac
	TTYILP,	KSF		/ await input ready
		JMP	TTYILP
		KRB		/ read character
		JMP I	TTYIN

	TTYOUT,	.-.		/Write to TTY
	/			  given character in ac
	TTYOLP,	TSF		/ await input ready
		JMP	TTYOLP
		TLS		/ write character
		JMP I	TTYOUT
When writing programs to support multiple I/O ports, the following alternative definitions for devcde I/O instructions and device addresses are appropriate:
	KSF=	6001	/ Keyboard Skip if Flag
	KCC=	6002	/ Keyboard Clear and read Character
	KRS=	6004	/ Keyboard Read Static
	KRB=	6006	/ Keyboard Read and Begin next read
	TSF=	6011	/ Teleprinter Skip if Flag
	TCF=	6012	/ Teleprinter Clear Flag
	TPC=	6014	/ Teleprinter Print Character
	TLS=	6016	/ Teleprinter Load and Start

	TTY=	0030	/ the console TTY
	LPR=	0650	/ the printer port
These definitions allow coding an operation for a particular device as, for example, KSF+TTY to check the console TTY keyboard input flag, and they allow use of reasonably clear self-modifying code for general-purpose I/O routines, as is illustrated in the following variation on the teletype output routine previously given:
	TTYOUT, .-.             /Write to TTY
	/                         given character in ac
	/			  device address inline
		DCA	TMP	/ set aside the character
		TAD I	TTYOUT	/ get the device address
		TAD	(TSF)	/  fix a TSF instruction
		DCA	TTYOLP	/  plant it in the code
		TAD I	TTYOUT	/ get the device address
		TAD	(TLS)	/  fix a TLS instruction
		DCA	TTYTLS	/  plant it in the code
		ISZ	TTYOUT  / advance over param
	TTYOLP, TSF             / await input ready
		JMP     TTYOLP
		TAD	TMP	/ recover character
	TTYTLS, TLS             /  and write it out
		JMP I   TTYOUT