MIT PDP-10 'Info' file converted to Hypertext 'html' format by Henry Baker
Previous
Up
Next
Print the string FOO on the terminal.
TITLE PRINT
A=1 ;Symbolic AC names are defined
CHTTYO==1 ;Channel for output
;== means don't use this symbol
;for symbolic typeout in DDT.
START: ;Open TTY channel.
.CALL [SETZ ? SIXBIT/OPEN/
[.UAO,,CHTTYO] ? [SIXBIT/TTY/] ((SETZ))]
.LOSE %LSFIL
.IOT CHTTYO,["F] ;Print F.
.IOT CHTTYO,["O] ;Print O.
.IOT CHTTYO,["O] ;Print O.
.VALUE ;Halt program.
END START ;Tell MIDAS this is the end of the text
;and specify the address to start execution.
NOTES:
- CHTTYO: All I/O is done by means of I/O channels, of which
there are sixteen, numbered 0 through 17. It is best to make symbolic
names for the channels you use and start them all with CH. Define
these names with the MIDAS operator ==, which is like = except that
symbols defined with == are not used for symbolic typeout by the DDT
debugger. We call this "half killing". In this example, CHTTYO and A
both have the value 1, but CHTTYO is half killed, so 1 will always be
output symbolically as A. This is the desired result, because
references to address or AC 1 are more likely to mean A than CHTTYO.
- .CALL: This is an ITS symbolic system call. Its format is, in
general,
.CALL [SETZ ? SIXBIT/callname/ ? arguments ((SETZ))]
(Note that the value of SETZ is a word with just the sign bit set).
The [ ... ] construct is a literal, and "?" is equivalent to a line
separator. Thus, the .CALL instruction is assembled with an address
field that points at a block of words containing a SETZ, a
SIXBIT/OPEN/, and finally the arguments. ((SETZ)) is a magic
assembler incantation which sets the sign bit of the last argument
word.
The arguments are simply addresses of words containing data for the
system call. There are other kinds of arguments, but we won't get
into that. See .INFO.;.CALLS > for more information on symbolic
system calls.
A symbolic system call skips if it is successful.
- OPEN: This is the name of the symbolic system call used in the
example. The OPEN call is used to open an I/O channel so it can be
used for I/O. It requires two arguments: the first one containing the
channel number and the I/O mode, and the second one containing the
device name in SIXBIT. In this example, the channel is CHTTYO, the
mode is .UAO (unit ascii output), and the device name is TTY, for the
terminal.
Most OPENs will also specify two filenames and a directory name as
additional arguments, but for device TTY they are not necessary.
- .LOSE %LSFIL: This is a system call which prints an error message
and halts. It is designed to be used as the instruction following an
OPEN or other symbolic system call which deals with an I/O channel.
Sophisticated programs can recover from failing system calls, and
sometimes the failure should simply be ignored, but often it is
easiest just to use .LOSE %LSFIL. This instruction is indented
because it can be skipped over.
- .IOT: This is the system call for doing actual I/O. It is an
instruction whose AC field should be the I/O channel and whose address
points to a word containing a character to be output. "F in MIDAS
represents the code for the character F.