1
0
mirror of https://github.com/PDP-10/its.git synced 2026-01-13 15:27:28 +00:00
PDP-10.its/doc/c/keymac.text
Lars Brinkhoff aec62f3117 Edit SAIL files to be like the originals from ITS.
Rename according to SAIL file C.LIB[C,SYS].  Fix E stuff and remove
trailing ^C and ^@s.
2018-10-30 08:36:56 +01:00

308 lines
14 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Keyword Macros
The keyword macros of the intermediate language are described
below in alphabetical order. Each section is headed by the name
of a macro and its calling sequence; following is a description
of the arguments and the intended function of the macro call.
1. ADCONn: %An(0,BASE,OFFSET) [n=0,1,2,3]
This is a set of macros, one for each possible pointer class.
BASE and OFFSET together make up a REF for an external or static
variable or function. The expansion of an ADCONn macro should
define a pointer constant of pointer class "n" that points to the
specified variable or function. This macro is used in the
initialization of static and external pointers and arrays of
pointers.
2. ALIGNn: %ALn() [n=1,2,3
N is an integer specifying an alignment class (alignment classes
are numbered from 0, where alignment class 0 is the alignment
class of characters). The expansion of the macro call should be
the pseudo-operations needed (if any) to properly align the
location counter for an object of the specified alignment class.
This macro is used in the definition of static and external
variables.
3. CALL: %CA(NARGS,ARGP,0,FBASE,FOFFSET)
The CALL macro generates a function call. NARGS is an integer
specifying the number of arguments to the function call. ARGP is
an integer. If the .ARG amops have not been defined in the
machine description, then ARGP specifies the byte offset in the
caller's stack frame of the arguments, which have been so placed
by previous instructions. Otherwise, ARGP is meaningless. FBASE
and FOFFSET are integers that together make up a REF specifying
the location of the function being called (it may be indirect
through a pointer in a register); these are passed as arguments 3
and 4 of the macro call so that they may be referenced as #F in
the macro definition.
4. CHAR: %C(I)
The CHAR macro produces a definition of a character constant
whose value is the integer I; it is used in the initialization of
static and external characters and arrays of characters. When
producing code for an assembler that does not have a byte
location counter (for example, the HIS-6000 assembler GMAP), the
- 2 -
characters produced by CHAR macro calls must be stored in a
buffer until either enough are accumulated to fill a machine word
or a macro call other than CHAR is issued; in this case, all
macros that may follow a CHAR macro must first check to see if
there are any characters in the buffer and if so, print the
appropriate statement and clear the buffer.
5. DATA: %DA()
The DATA macro indicates that the following macros define impure
data areas that are not explicitly initialized.
6. DOUBLE: %D(I)
The DOUBLE macro produces a definition of a non-negative
double-precision floating-point constant whose C source
representation is stored in the internal compiler table CSTORE at
an offset specified by the integer I (the compiler itself does
not use any floating-point operations). This macro is used in
the initialization of static and external double-precision
floating-point variables and arrays.
7. ELSWITCH: %ELS(N,LBASE,LOFFSET,IBASE,IOFFSET)
The ELSWITCH macro marks the end of a switch specification begun
by an LSWITCH macro. The parameters are the same as for the
LSWITCH macro.
8. END: %END()
The END macro marks the end of the intermediate language program.
It may produce an END statement, if needed, or signal that any
processing associated with the end of the program should be
performed.
9. ENTRY: %EN(NAME)
NAME is an object language symbol constructed from an identifier
by the IDN macro. The expansion of the ENTRY macro should define
the symbol as an entry point, that is, one defined in the current
program but accessible to other programs.
10. EPILOG: %EP(FUNCNO,FRAMESIZE)
The EPILOG macro produces the epilog code for a C function. The
epilog code should restore the environment of the calling
function and return to that function. In the HIS-6000
implementation, these actions are performed by a subroutine.
FUNCNO and FRAMESIZE are integers that specify the internal
function number of the function and the size in bytes of its
stack frame, respectively. In the HIS-6000 implementation, these
integers are used to define an assembly-language symbol whose
value is the size in words of the stack frame; this symbol is
- 3 -
used by the code produced by the PROLOG macro that allocates the
stack frame.
11. EQU: %EQ(NAME)
NAME is an object language symbol constructed from an identifier
by the IDN macro; it is to be defined as having a value equal to
the current value of the location counter.
12. ETSWITCH: %ETS(LO,LBASE,LOFFSET,IBASE,IOFFSET,HI)
The ETSWITCH macro marks the end of a switch specification begun
by an TSWITCH macro. The parameters are the same as for the
TSWITCH macro.
13. EXTRN: %EX(NAME)
The EXTRN macro is similar to the ENTRY macro except that it
defines the symbol to be an external reference, that is, one used
in the current program but assumed to be defined in another
program.
14. FLOAT: %F(I)
The FLOAT macro produces a definition of a non-negative
single-precision floating-point constant; the argument has the
same interpretation as that of the DOUBLE macro.
15. GOTO: %GO(0,BASE,OFFSET)
The GOTO macro produces an unconditional jump to a location
denoted in the source program by a label constant or expression.
BASE and OFFSET together make up a REF that specifies the target
location of the jump; these are passed as arguments 1 and 2 of
the macro call so that they may be referenced as #R in the macro
definition.
16. HEAD: %HD()
The HEAD macro marks the beginning of the intermediate language
program. It may produce header statements, if needed, or signal
that any initialization processing should be performed.
17. IDN: %I(X)
The IDN macro should expand to the object language representation
of the identifier whose C source representation is stored in the
internal compiler table CSTORE at an offset specified by the
integer X. The processing performed by this macro may include
the truncation of long names, the replacement of the underline
character (which is allowed in C identifiers), and the insertion
of special character(s) to avoid conflicts between C identifiers
and other object language symbols.
- 4 -
18. IMPURE: %IM()
The IMPURE macro indicates that following macros define impure
data areas that are not explicitly initialized (and thus are
implicitly initialized to zero).
19. INT: %IN(I)
The INT macro produces a definition of an integer constant whose
value is specified by the integer I. It is used in the
initialization of static and external variables and arrays and in
the construction of tables for the LSWITCH macro.
20. LABCON: %LC(N)
The LABCON macro generates an address constant whose value is the
address corresponding to internal label number N. The LABCON
macro is used to construct the tables for the LSWITCH and TSWITCH
macros.
21. LABDEF: %L(N)
The LABDEF macro defines the location of internal label number N.
22. LN: %LN(N)
The LN macro associates the line in the source program whose line
number is specified by the integer N with the current value of
the location counter. This macro may optionally produce a
comment line in the object program to aid in the reading of the
object program, or it may define a line-number symbol to be used
in conjunction with a debugging system.
23. LSWITCH: %LS(N,LBASE,LOFFSET,IBASE,IOFFSET)
The LSWITCH macro should generate code that jumps according to
the value of the integer whose location is given by IBASE and
IOFFSET (selected from the locations permitted by the OPLOC for
the .sw operation). This macro is immediately followed by N
(N>0) INT macros (the cases), which are immediately followed by N
LABCON macros (the corresponding labels), which is followed by an
ELSWITCH macro. A search should be made through the case list;
if a match is found, a jump should be made to the label defined
by the corresponding LABCON macro. If the integer matches none
of the list entries, then a jump should be made to the internal
label defined by LBASE and LOFFSET.
24. NDOUBLE: %ND(I)
The NDOUBLE macro is the same as the DOUBLE macro except that the
value of the defined constant is made negative.
- 5 -
25. NFLOAT: %NF(I)
The NFLOAT macro is the same as the FLOAT macro except that the
value of the defined constant is made negative.
26. PDATA: %PD()
The PDATA macro indicates that following macros define pure data
areas, namely string literals.
27. PURE: %PU()
The PURE macro indicates that following macros define pure code.
28. PROLOG: %P(FUNCNO,FUNCNAME,FNARGS)
The PROLOG macro produces the prolog code for a C function.
FUNCNAME is an integer representing the name of the function as
it appears in the source program; its interpretation is the same
as that of the argument of the IDN macro. FUNCNO is an integer
that specifies the internal function number of the function; it
may be used in conjunction with the EPILOG macro to access the
size of the function's stack frame. FNARGS is an integer
specifying the number of formal arguments of the function. The
PROLOG macro should define the entry point name and produce the
code necessary to save the environment of the calling function
and set up the environment of the called function, using the
information provided in the function call. In the HIS-6000
implementation, these actions are performed by a subroutine. The
PROLOG macro call appears in the intermediate language program
immediately before the first instruction of the corresponding
function.
29. RETURN: %RT(FUNCNO)
The RETURN macro produces the statements needed to return from a
function to the calling function. FUNCNO is the internal
function number of the function, as given to the PROLOG and
EPILOG macros. In general, this macro will result in either a
transfer to the code produced by the corresponding EPILOG macro
(accessed via FUNCNO) or a transfer to epilog code common to all
C functions. The returned value of the function is loaded by
preceding macro calls into the appropriate register as specified
in the RETURNREG statement of the machine description.
30. STATIC: %ST(N,S)
The STATIC macro defines the location of the static variable
whose internal static variable number is N. S is the size of the
static variable in bytes. Typically, this macro will define an
assembly language symbol by which the static variable can be
referenced.
- 6 -
31. STRCON: %SC(N)
The STRCON macro should generate a character pointer that points
to the string constant whose internal string number is N. The
STRCON macro is used in the initialization of static and external
variables.
32. STRING: %SR()
The STRING macro marks the place in the object program where the
string constants should be defined. This macro is implemented as
a C routine macro since substantial processing is involved.
33. TSWITCH: %TS(LO,LBASE,LOFFSET,IBASE,IOFFSET,HI)
The TSWITCH macro produces an indexed jump based on the value of
the integer whose location is given by IBASE and IOFFSET
(selected from the locations permitted by the OPLOC for the .sw
operation). This macro is immediately followed by a sequence of
HI-LO+1 LABCON macros, which is followed by an ETSWITCH macro.
The sequence of LABCON macros defines the target labels
corresponding to integer values from LO to HI, Values outside
this range should result in transfers to the internal label
defined by LBASE and LOFFSET.
34. ZERO: %Z(I)
The ZERO macro specifies the definition of a block of storage
initialized to zero; the size in bytes of this storage area is
specified by the integer I.