#include <keykos.h>Of course, if you use any library functions, the corresponding headers should be included. No global MACLIBs are required for the compilation because the header files are read as individual CMS files, rather than members of a MACLIB.
Header files should not have sequence numbers. Any text in columns 73-80 will be compiled.
Because the Waterloo compiler does not perform updating of files, header files must be updated before they are used in a compilation. The base file for the header AHEADER should be named "AHEADERH HS" (think "Header Source"). The command:
VMFH AHEADER [ctl] [(options]updates AHEADERH HS (using AHEADERH AUX... and AHEADERH update files) to produce an updated file called AHEADER H (note no H in the filename). Columns 73-80 of the updated file will be blank. You then add the following statement to your program:
#include "aheader.h"
To build updated source for a .h file, use the following command:
VMFH fname [ctl] [( HSTYLE [options]] VMFH <name> updates "<name>H HS" to produce "name H".
VMFH <name>(HSTYLE updates "<name> HS" to produce "name H".
The control file used is "ctl CNTRL". If ctl is not specified, "FT CNTRL" is used.
Other options will be documented here at a later date.
VMFC fname [ctl] [(KJUMP otheroptions]
This uses the CMS file "fname C" and its updates, with the control file "ctl CNTRL". If ctl is not specified, the default control file is "FT CNTRL". The KJUMP option specifies the use of the key cache. Other options will be documented here at a later date.
- To run the KCPP preprocessor, enter this CMS command:
KCPP fname [ftype [fmode] ] [( KJUMP ]
This uses the CMS file "fname ftype fmode" as input. The filetype defaults to "C", and the filemode defaults to "*". The KJUMP option specifies the use of the key cache. KCPP expects as input a standard C program with intermixed key invocation statements and KEY and STRING declarations. Any text in columns 73-80 will be removed. The output of KCPP is the CMS file "fnameÊCXÊA1".
- To compile the output of KCPP with the Waterloo C compiler, enter this CMS command:
CW fname CX [fmode] [( options ]
The CWC EXEC can be used to both run KCPP to produce preprocessor output and then run the Waterloo C compiler. If there is an error diagnosed by KCPP, the preprocessor output file is not erased and the C compiler is not executed. Otherwise all intermediate files are erased.
- To run the KCPP preprocessor and compile the result if there are no errors, enter this CMS command:
CWC fname [ftype [fmode] ] [KJUMP] [( options ]
This uses the CMS file "fname ftype fmode" as input. The filetype defaults to "C", and the filemode defaults to "*". The KJUMP option specifies the use of the key cache. The options are described in the Waterloo C User's guide.
- To see a brief list of the Waterloo C compiler options, use this CMS command:
CW ?
GLINK ?After the resulting CMS module is exported to KeyKOS as a segment, the PCS command system's CFACT command is used to produce an object factory. For example:
CFACT <factory_name> <module> <akt> S0=USER.SYS.CDESTROYThe primary reason for using this command is that it builds a virtual copy segment (VCS) for the memory tree of the object. As a result of using the CFACT command, component 9 contains a data key with the time zone and start address of the stack/heap.
The following is an example of how a C object can be linked in KeyKOS using SLOAD and the PCS command system:
KC USER.SYS.SYSPF 0 (,SB,M,SWITCHER) (,SYSP) KC USER.SYS.SLOAD 0 (,SB,M,SB) (,CO) * * Include CSTART to initialize the run-time environment * KC CO 0 (%ECSTART,USER.SYS.KKOSCLIB.CSTART,SYSP) * * Include the C program's text deck * KC CO 0 (%E<name>,USER.<text>,SYSP) * * Include the C run-time stack * KC CO 0 (%ESTACK,USER.CSTACK,SYSP) * * Resolve remaining external references * and finish loading * KC CO 1 (,SYSP,USER.SYS.KKOSCLIB.) (%E%X,LSF,BINDER) KC CO 0 * * Build the factory * FACTORY <factory_name> LSF 99
Link the program using the LC command. The binder may not be used with this environment. Either of the LC commands below is correct. The second LC command has the advantage of having a constant starting address (x'10'). LC is smart enough to generate the correct module name in either case.
LC program CFSTART othertextdecknames LC CFSTART program othertextdecknamesExport the module file and use the FACTORY command to build the object. No components are required and all components are available for to user to specify.
FACTORY Factoryname segmentname AKT [ord] S|H|Fn=
xtype value, address of exit block, ntype value, address of entry block.The bits of the high-order byte of xtype and ntype are set up in the following way: