xref: /original-bsd/usr.bin/pascal/src/pc.h (revision d25e1985)
1 /* Copyright (c) 1979 Regents of the University of California */
2 
3 /* static	char sccsid[] = "@(#)pc.h 1.1 08/27/80"; */
4 
5     /*
6      *		random constants for pc
7      */
8 
9     /*
10      *	the name of the display.
11      *	the display is made up of saved AP's and FP's.
12      *	FP's are used to find locals, and AP's are used to find parameters.
13      *	FP and AP are untyped pointers, but are used throughout as (char *).
14      *	the display is used by adding AP_OFFSET or FP_OFFSET to the
15      *	address of the approriate display entry.
16      */
17 #define	DISPLAYNAME	"__disply"
18 struct dispsave {
19     char	*savedAP;
20     char	*savedFP;
21 };
22 #define	AP_OFFSET	( 0 )
23 #define FP_OFFSET	( sizeof(char *) )
24 
25     /*
26      *	the structure below describes the locals used by the run time system.
27      *	at function entry, at least this much space is allocated,
28      *	and the following information is filled in:
29      *	the address of a routine to close the current frame for unwinding,
30      *	a pointer to the display entry for the current static level and
31      *	the previous contents of the display for this static level.
32      *	the curfile location is used to point to the currently active file,
33      *	and is filled in as io is initiated.
34      *	one of these structures is allocated on the (negatively growing) stack.
35      *	at function entry, fp is set to point to the last field of the struct,
36      *	thus the offsets of the fields are as indicated below.
37      */
38 struct rtlocals {
39     struct iorec	*curfile;
40     struct dispsave	dsave;
41     struct dispsave	*dptr;
42     int			(*unwind)();
43 } rtlocs;
44 #define	CURFILEOFFSET	( ( -sizeof rtlocs ) + sizeof rtlocs.unwind )
45 #define	DSAVEOFFSET	( CURFILEOFFSET + sizeof rtlocs.curfile )
46 #define	DPTROFFSET	( DSAVEOFFSET + sizeof rtlocs.dsave )
47 #define	UNWINDOFFSET	( DPTROFFSET + sizeof rtlocs.dptr )
48 #define	UNWINDNAME	"_UNWIND"
49 
50     /*
51      *	the register save mask for saving no registers
52      */
53 #define	RSAVEMASK	( 0 )
54 
55     /*
56      *	runtime check mask for divide check and integer overflow
57      */
58 #define	RUNCHECK	( ( 1 << 15 ) | ( 1 << 14 ) )
59 
60     /*
61      *	formats for various names
62      *	    NAMEFORMAT		arbitrary length strings.
63      *	    EXTFORMAT		for externals, a preceding underscore.
64      *	    PREFIXFORMAT	used to print made up names with prefixes.
65      *	    LABELPREFIX		with getlab() makes up label names.
66      *	    LLABELPREFIX	with getlab() makes up sdb labels.
67      *	    PLABELPREFIX	with atol(symbol) makes up global pascal labels.
68      *	    GLABELPREFIX	with getlab() makes up nested label names
69      *	a typical use might be to print out a name with a preceeding underscore
70      *	with putprintf( EXTFORMAT , 0 , name );
71      */
72 #define	NAMEFORMAT	"%s"
73 #define	EXTFORMAT	"_%s"
74 #define	PREFIXFORMAT	"%s%d"
75 #define	LABELPREFIX	"L"
76 #define	LLABELPREFIX	"LL"
77 #define	PLABELPREFIX	"P"
78 #define	GLABELPREFIX	"G"
79 
80     /*
81      *	the name of the statement counter
82      */
83 #define	STMTCOUNT	"__stcnt"
84 
85     /*
86      *	the name of the pcp counters
87      */
88 #define	PCPCOUNT	"__pcpcount"
89 
90     /*
91      *	a vector of pointer to enclosing functions for fully qualified names.
92      */
93 char	*enclosing[ DSPLYSZ ];
94 
95     /*
96      *	and of course ...
97      */
98 #define	BITSPERBYTE	8
99 
100     /*
101      *	error number for case label not found (ECASE)
102      *	stolen from ~mckusick/px/lib/h01errs.h
103      */
104 #define	ECASE		5
105