1
0
mirror of https://github.com/PDP-10/its.git synced 2026-02-09 18:01:01 +00:00

KCC - C compiler.

Binary-only compiler and library, plus documentation and include files
for compiling new programs.
This commit is contained in:
Lars Brinkhoff
2017-02-15 13:54:43 +01:00
parent c2242636b6
commit 53f2a2eba9
47 changed files with 15667 additions and 3 deletions

59
src/c/c.defs Executable file
View File

@@ -0,0 +1,59 @@
/*
C Standard Definitions
*/
# define ITS ITS
/* data types */
struct _filespec {int dev, fn1, fn2, dir;};
# define filespec struct _filespec
# define channel int
struct _cal {int year, month, day, hour, minute, second;};
# define cal struct _cal
struct _tag {int *pc, *fp, *ap, *sp;};
# define tag struct _tag
/* common values */
# define TRUE 1
# define FALSE 0
# define OPENLOSS -1 /* returned by COPEN if lose */
# define EOF_VALUE 0 /* returned by CGETC if EOF */
/* C interrupts */
# define INT_DEFAULT 0
# define INT_IGNORE 1
# define realt_interrupt 0
# define mpv_interrupt 1
# define ioc_interrupt 2
# define ilopr_interrupt 3
# define mar_interrupt 4
# define utrap_interrupt 5
# define pure_interrupt 6
# define wiro_interrupt 7
# define sys_down_interrupt 8
# define clock_interrupt 9
# define timer_interrupt 10
# define pdlov_interrupt 11
# define ttyi_interrupt 12
# define cli_interrupt 13
# define overflow 14
# define float_overflow 15
# define channel0_interrupt 16
# define inferior0_interrupt 32
# define ctrls_interrupt 41
# define ctrlg_interrupt 42

7
src/c/clib.stinkr Executable file
View File

@@ -0,0 +1,7 @@
; xfile for loading basic C library
; this file must be loaded first
; segment 0 must start at 100
s 100,n,p,n
i sinit
l c;[crel] >

15
src/c/ctype.h Executable file
View File

@@ -0,0 +1,15 @@
#define _U 01
#define _L 02
#define _A 03
#define _N 04
#define _S 010
extern char _ctype[];
#define isalpha(c) (_ctype[c]&_A)
#define isupper(c) (_ctype[c]&_U)
#define islower(c) (_ctype[c]&_L)
#define isdigit(c) (_ctype[c]&_N)
#define isspace(c) (_ctype[c]&_S)
#define toupper(c) ((c)-'a'+'A')
#define tolower(c) ((c)-'A'+'a')

61
src/c/nc.insert Executable file
View File

@@ -0,0 +1,61 @@
; C;NC INSERT
; THIS FILE IS NEEDED TO ASSEMBLE MIDAS PROGRAMS PRODUCED BY
; THE C COMPILER AS WELL AS HAND-CODED MIDAS PROGRAMS DESIGNED
; TO BE LOADED WITH C PROGRAMS
RELOCATABLE
.INSRT SYSENG;MULSEG INSERT
.MSEG 200000',600000',700000'
IF1,[
.MLLIT==1
A=1
B=2
C=3
D=4
P=15.
.CCALL=1_27.
GO=JRST
EQUALS ENTRY .GLOBAL
EQUALS EXTERN .GLOBAL
DEFINE .IDATA
.SEG 0
TERMIN
DEFINE .UDATA
.SEG 1
TERMIN
DEFINE .CODE
.SEG 2
TERMIN
DEFINE .PDATA
.SEG 3
TERMIN
; STACK HACKING FOR VARIABLE REFERENCES
%P==0
DEFINE PPUSH [A]
PUSH P,A
%P==%P+1
TERMIN
DEFINE PPOP [A]
POP P,A
%P==%P-1
TERMIN
DEFINE CCALL N,F
.CCALL N,F
%P==%P-N
TERMIN
];END IF1
IF2,[IFDEF FS1,[
.KILL %A,%P,A,B,C,D,P,GO,.CCALL
]]

21
src/c/stdio.h Executable file
View File

@@ -0,0 +1,21 @@
/* STDIO.H for DEC20 implementation */
/* actual code is in <C.LIB>C20STD.C */
# define BUFSIZ 512 /* this number is irrelevant */
# define FILE int /* the actual structure is irrelevant */
# define NULL 0 /* null file pointer for error return */
# define EOF (-1) /* returned on end of file */
# define peekchar pkchar /* rename to avoid name conflict */
# define fopen flopen /* " */
# define getc fgetc /* " */
# define getchar fgeth /* " */
# define fprintf ffprintf /* " */
# define calloc fcalloc /* " */
# define feof ceof /* direct translation */
# define putc cputc /* " */
# define fputc cputc /* " */
extern FILE *stdin, *stdout, *stderr;

104
src/kcc_sy/fsdefs.h Executable file
View File

@@ -0,0 +1,104 @@
/* -*-C-*-
* ITS filesystem definitions
*
* Defines the format of binary MFDs and UFDs for use by C programs.
*/
/*
** MFD INFO
*/
/* RANDOM INFO IN MFD */
#define MDNUM 0 /* ASCENDING DIR NUM */
#define MDNAMP 1 /* PNTR TO ORG OF USER NAME BLOCK AREA */
#define MDYEAR 2 /* CURRENT YEAR */
#define MPDOFF 3 /* DE-CORIOLIS CLOCK OFFSET */
#define MPDWDK 4 /* PREFERRED WRITING DISK (PHYSICAL DRIVE #) */
#define MDCHK 5 /* THIS WORD MUST BE M.F.D. (FOR CHECKING) */
#define MDNUDS 6 /* NUMBER USER DIRECTORIES (FOR CHECKING ONLY) */
#define LMIBLK 7 /* TOTAL STG USED BY HACKS LIKE THIS */
/* USER NAME BLKS FROM C(MDNAMP) TO END */
#define LMNBLK 2 /* # WDS/BLK */
#define MNUNAM 0 /* 6BIT USER NAME */
/*
** UFD INFO
*/
#define UFDBYT 6 /* SIZE OF BYTES */
#define UFDBPW (36 / UFDBYT) /* NUMBER OF BYTES PER WORD */
/* RANDOM INFO IN UFD */
#define UDESCP 0 /* FS PNTR TO DESC AREA */
#define UDNAMP 1 /* PNTR TO ORG OF NAME AREA */
#define UDNAME 2 /* USER NAME (FOR CHECKING) */
#define UDBLKS 3 /* LEFT HALF HAS AMOUNT OF SPACE ALLOCATED (NOT */
/* USED CURRENTLY BY SYSTEM), RIGHT HALF HAS */
/* NUMBER OF BLOCKS USED. */
#define UDALLO 4 /* IF NONZERO, LEFT HALF HAS DISK NUMBER, RIGHT */
/* HALF HAS AMOUNT OF SPACE ALLOCATED */
#define UDDESC 11 /* FIRST LOC AVAIL FOR DESC */
/* UFD DESCRIPTORS
** 0 => FREE 1-UDTKMX => TAKE NEXT N
** UDTKMX+1 THRU UDWPH-1 => SKIP N-UDTKMX AND TAKE ONE
** UDWPH => WRITE-PLACE-HOLDER
** 040 BIT SET => LOAD ADDRESS. LOWER 5 BITS PLUS NEXT NXLBYT (2)
** CHARS (17 BITS IN ALL)
** 040 BIT & 020 BIT => "FUNNY" BLOCK IF DMDSK. WHAT IS THIS, ANYWAY?
** END BY 0
**
** IF LINK DESCR
** 6 CHAR OR UNTIL ; = SYS NAME. MUST HAVE NO CHAR = 0 IN THIS OR
** NEXT 2 NAMES
** NEXT CHAR QUOTED BY : (FOR NAMES WITH : OR ;)
** NEXT CHAR N1
** NEXT CHAR N2
** END BY 0
*/
#define UDTKMX 12 /* HIGHEST "TAKE N" CODE */
#define UDWPH 31 /* PLACE HOLDER ON WRITE (OR NULL FILE) */
#define UDSKMX (UDWPH - UDTKMX - 1) /* # BLOCKS THAT CAN BE SKIPPED */
#define NXLBYT 2 /* # ADDITIONAL BYTES FOR LOAD ADDR */
/* NAME AREA DATA */
#define LUNBLK 5 /* WDS/NAME BLK */
#define UNFN1 0 /* FIRST FN */
#define UNFN2 1 /* SECOND FN */
#define UNRNDM 2 /* ALL KINDS OF RANDOM INFO */
#define UNDSCP 0001500000000 /* PNTR TO DESC */
#define UNPKN 0150500000000 /* PACK # */
#define UNLINK 01000000 /* LINK BIT */
#define UNREAP 02000000 /* IF 1, DONT REAP FILE */
#define UNWRIT 04000000 /* OPEN FOR WRITING */
#define UNMARK 010000000 /* GC MARK BIT */
#define UNCDEL 020000000 /* DEL WHEN CLOSED */
#define DELBTS 020000000 /* DELETED -- IGNORE */
#define UNIGFL 024000000 /* BITS TO IGNORE FILE */
#define UNWRDC 0301200000000 /* WORD COUNT OF LAST BLOCK MOD 2000 */
#define UNDUMP 0400000000000 /* HAS BEEN DUMPED */
#define UNDATE 3 /* DATE ETC. */
#define UNTIM 0002200000000 /* COMPACTED TIME OF CREATION */
#define UNYMD 0222000000000 /* Y,M,D OF CREATION */
#define UNMON 0270400000000 /* MONTH */
#define UNDAY 0220500000000 /* DAY */
#define UNYRB 0330700000000 /* YEAR */
#define UNREF 4 /* REFERENCE DATE SAME AS LEFT HALF OF UNDATE */
#define UNREFD 0222000000000 /* REFERENCE DATE */
#define UNAUTH 0111100000000 /* MFD INDEX OF AUTHOR, ALL 1=> NO */
/* DIRECTORY */
#define UNBYTE 0001100000000 /* FILE BYTE SIZE AND LENGTH INFO. */
/* LET S=BITS PER BYTE, C=COUNT OF UNUSED BYTES
** IN LAST WD
** 400+100xS+C S=1 TO 3 C=0 TO 35.
** 200+20xS+C S=4 TO 7 C=0 TO 8
** 44+4xS+C S=8 TO 18. C=0 TO 3
** 44-S S=19. TO 36. C=0
** NOTE THAT OLD FILES HAVE UNBYTE=0 => S=36.
*/

11
src/kcc_sy/humble.h Executable file
View File

@@ -0,0 +1,11 @@
/* -*-C-*-
* HUMBLE header file
*/
extern int j_create(), j_kill();
extern int j_read(), j_write();
extern int j_dump(), j_load();
extern int j_vread(), j_vwrite();
extern int j_atty(), j_dtty();
#define SIXBIT(name) (* ((int *) ((_KCCtype_char6 *) name)))