1
0
mirror of https://github.com/PDP-10/its.git synced 2026-03-23 17:22:35 +00:00
Files
PDP-10.its/c20/cc.hlp
2018-05-15 07:06:17 +02:00

140 lines
4.6 KiB
Plaintext

C Info (30 July 1979)
--- C ---
C is an implementation language, similar to BCPL except with data
types. It is the primary language used in the Unix operating system.
This implementation runs on the ITS and TOPS-20 operating systems.
(The ITS implementation exists only on DM.) This implementation is
moderately compatible with the Unix C implementation. The Unix
system calls are NOT implemented. Some implemented library routines
are described below.
Further information is available from Eliot Moss (EBM@XX).
--- Compiling ---
CC is the C compiler command. Usage is
:cc file1.c file2.c ...
where the arguments are the path names of C source files which are to
be compiled. Each file will be compiled in turn, and if the compilation
is successful, the resulting relocatable file will be placed in the file
"file*.stk". [The ITS compiler currently produces "file*.rel". This will
soon be changed.] Arguments beginning with the '-' character are taken
to be compiler options. Available options include:
-c compile only, do not assemble
-g do not delete MIDAS file
-x syntax check only
-s produce a symbol table listing
-b compile big function (FUNCTION TOO LARGE)
For example, the command
:cc foo.c
would compile the C program in the file "foo.c" ("FOO C" on ITS) in the
current directory, and place the resulting relocatable program in the file
"foo.stk" ("FOO STK" on ITS).
--- Loading ---
Relocatable programs produced by the C compiler are loaded together
with the C support routines using the STINKR loader. To load program
files "foo", "bar", and "bletch" and produce a runnable file "foo",
type the following to STINKR:
(TOPS-20: (ITS:
x <c>clib x c/clib
l foo l foo
l bar l bar
l bletch l bletch
o foo.exe o ts.foo
^Z ^@
The ^@ (ASCII NUL) or ^Z terminates the terminal input file.
The ^Z must be followed by a CR. These commands (minus the ^@)
could also be written in a file, say "foo.stinkr" ("FOO STINKR"
on ITS), in which case one could invoke STINKR with "foo" as a
JCL argument and STINKR would read the commands from the
command file.
--- Library ---
The above STINKR commands will load in a set of library routines
for performing I/O, etc. These routines are similar to the
Unix "Portable I/O Library". A brief description of the most useful
routines follows:
char c; /* an ASCII character */
int i, n, cc; /* an integer */
int *p; /* an integer pointer */
int b; /* a boolean */
char *s, *s1, *s2; /* strings */
char *fn; /* an ITS file name or a path name */
int fd; /* a "file descriptor" */
fd = copen (fn, mode, options); /* open file */
char mode; /* 'r', 'w', or 'a' (append) */
char *options; /* 0 (char I/O), "s" (string file), "b" (binary) */
/* for string file, pass string as fn */
/* returns -1 if open fails */
extern int cin; /* standard input - pre-existing */
extern int cout; /* standard output - pre-existing */
extern int cerr; /* standard error ouput - pre-existing */
c = cgetc (fd); /* get character; returns 0 if eof */
c = cputc (c, fd); /* put character */
b = ceof (fd); /* test for end of file */
cclose (fd); /* close file */
c = getchar (); /* equivalent to cgetc(cin) */
putchar (c); /* equivalent to cputc(c,cout) */
gets (s1); /* read string (line) from cin */
puts (s1); /* put string and newline to cout */
cprint (fd, format, arg...); /* formatted print routine */
/* the format is a string which may contain format items
of the form %nf, where n is an optional decimal integer
(the minimum field width) and f is one of the following
characters:
d - print next arg (an integer) in decimal
o - print next arg (an integer) in octal
s - print next arg (a string)
c - print next arg (a character)
The file descriptor FD can be omitted, in which case
COUT is used.
*/
i = cgeti (fd); /* get integer (binary input) */
i = cputi (i, fd); /* put integer (binary output) */
b = istty (fd); /* test if file is a TTY */
c = utyi (); /* read char from TTY (unbuffered, no echo) */
utyo (c); /* output char to TTY (unbuffered) */
tyo_flush (); /* flush TTY output buffer */
cexit (cc); /* terminate job, closing all files */
/* returning from "main" is equivalent */
/* STRING Routines */
i = slen (s); /* find string length */
stcpy (s1, s2); /* copy string from S1 to S2 */
b = stcmp (s1, s2); /* compare strings */
/* storage allocation */
p = salloc (n); /* allocate n words, return pointer to it */
sfree (p); /* free storage allocated by salloc */
s = calloc (n); /* allocate n characters, return ptr to it */
cfree (s); /* free storage allocated by calloc */