xref: /csrg-svn/usr.bin/pascal/src/objfmt.h (revision 10720)
1 /* Copyright (c) 1979 Regents of the University of California */
2 
3 /* static char sccsid[] = "@(#)objfmt.h 1.12 02/03/83"; */
4 
5 /*
6  * The size of the display.
7  */
8 #define DSPLYSZ 20
9 
10 /*
11  *	The structure of the runtime display
12  */
13 #ifdef OBJ
14 struct dispsave {
15 	char *locvars;		/* pointer to local variables */
16 	struct blockmark *stp;	/* pointer to local stack frame */
17 };
18 	/*
19 	 * The following union allows fast access to
20 	 * precomputed display entries
21 	 */
22 union display {
23 	struct dispsave frame[DSPLYSZ];
24 	char *raw[2*DSPLYSZ];
25 } display;
26 #endif OBJ
27 #ifdef PC
28 #ifdef vax
29 	/*
30 	 *	the display is made up of saved AP's and FP's.
31 	 *	FP's are used to find locals,
32 	 *	and AP's are used to find parameters.
33 	 *	FP and AP are untyped pointers,
34 	 *	but are used throughout as (char *).
35 	 *	the display is used by adding AP_OFFSET or FP_OFFSET to the
36 	 *	address of the approriate display entry.
37 	 */
38     struct dispsave {
39 	char	*savedAP;
40 	char	*savedFP;
41     } display[ DSPLYSZ ];
42 
43 #   define	AP_OFFSET	( 0 )
44 #   define	FP_OFFSET	( sizeof (char *) )
45 #endif vax
46 #ifdef mc68000
47 	/*
48 	 *	the display is just the saved a6.
49 	 *	arguments are at positive offsets,
50 	 *	locals are at negative offsets.
51 	 *	there are no offsets within the saved display structure.
52 	 */
53     struct dispsave {
54 	char	*saveda6;
55     } display[ DSPLYSZ ];
56 
57 #   define	AP_OFFSET	(0)
58 #   define	FP_OFFSET	(0)
59 #endif mc68000
60 #endif PC
61 
62     /*
63      *	the structure below describes the block mark used by the architecture.
64      *	this is the space used by the machine between the arguments and the
65      *	whatever is used to point to the arguments.
66      */
67 #ifdef OBJ
68 struct blockmark {
69 	char *tos;		/* pointer to top of stack frame */
70 	struct iorec *file;	/* pointer to active file name */
71 	struct hdr {
72 		long framesze;	/* number of bytes of local vars */
73 		long nargs;	/* number of bytes of arguments */
74 		long tests;	/* TRUE => perform runtime tests */
75 		short offset;	/* offset of procedure in source file */
76 		char name[1];	/* name of active procedure */
77 	} *entry;
78 	struct dispsave odisp;	/* previous display value for this level */
79 	struct dispsave *dp;	/* pointer to active display entry */
80 	char *pc;		/* previous location counter */
81 	long lino;		/* previous line number */
82 };
83 #endif OBJ
84 #ifdef PC
85 #ifdef vax
86 	/*
87 	 *	since we have the ap pointing to the number of args:
88 	 */
89     struct blockmark {
90         long	nargs;
91     };
92 #endif vax
93 #ifdef mc68000
94 	/*
95 	 *	there's the saved pc (from the jsr)
96 	 *	and the saved a6 (from the link a6).
97 	 */
98     struct blockmark {
99 	char	*savedpc;
100 	char	*saveda6;
101     };
102 #endif mc68000
103 #endif PC
104 
105     /*
106      *	formal routine structure:
107      */
108 struct formalrtn {
109 	long		(*fentryaddr)();	/* formal entry point */
110 	long		fbn;			/* block number of function */
111 	struct dispsave	fdisp[ DSPLYSZ ];	/* saved at first passing */
112 } frtn;
113 
114 #define	FENTRYOFFSET	0
115 #define FBNOFFSET	( FENTRYOFFSET + sizeof frtn.fentryaddr )
116 #define	FDISPOFFSET	( FBNOFFSET + sizeof frtn.fbn )
117 
118 #ifdef OBJ
119 	/*
120 	 *	the creation time, the size and the magic number of the obj file
121 	 */
122     struct pxhdr {
123 	    long	maketime;
124 	    long	objsize;
125 	    long	symtabsize;
126 	    short	magicnum;
127     };
128 
129 #ifdef vax
130 #   define HEADER_BYTES	2048			/* the size of px_header */
131 #endif vax
132 #ifdef mc68000
133 #   define HEADER_BYTES	3072			/* the size of px_header */
134 #endif mc68000
135 #   define INDX 1				/* amt to shift display index */
136 #endif OBJ
137 
138 	    /*
139 	     *	these are because of varying sizes of pointers
140 	     */
141 #ifdef ADDR16
142 #	define PTR_AS O_AS2
143 #	define PTR_RV O_RV2
144 #	define PTR_IND O_IND2
145 #	define PTR_CON O_CON2
146 #	define PTR_DUP O_SDUP2
147 #	define CON_INT O_CON2
148 #	define INT_TYP (nl + T2INT)
149 #	define PTR_DCL char *
150 #	define TOOMUCH 50000
151 #	define SHORTADDR 65536
152 #	define MAXSET 65536		/* maximum set size */
153 #endif ADDR16
154 #ifdef ADDR32
155 #	define PTR_AS O_AS4
156 #	define PTR_RV O_RV4
157 #	define PTR_IND O_IND4
158 #	define PTR_CON O_CON4
159 #	define PTR_DUP O_SDUP4
160 #	define CON_INT O_CON24
161 #	define INT_TYP (nl + T4INT)
162 #	define PTR_DCL unsigned long		/* for pointer variables */
163 #	define SHORTADDR 32768			/* maximum short address */
164 #	define TOOMUCH 65536			/* maximum variable size */
165 #	define MAXSET 65536			/* maximum set size */
166 #endif ADDR32
167 	/*
168 	 * Offsets due to the structure of the runtime stack.
169 	 * DPOFF1	is the amount of fixed storage in each block allocated
170 	 * 		as local variables for the runtime system.
171 	 *		since locals are allocated negative offsets,
172 	 *		-DPOFF1 is the last used implicit local offset.
173 	 * DPOFF2	is the size of the block mark.
174 	 *		since arguments are allocated positive offsets,
175 	 *		DPOFF2 is the end of the implicit arguments.
176 	 *		for obj, the first argument has the highest offset
177 	 *		from the stackpointer.  and the block mark is an
178 	 *		implicit last parameter.
179 	 *		for pc, the first argument has the lowest offset
180 	 *		from the argumentpointer.  and the block mark is an
181 	 *		implicit first parameter.
182 	 */
183 #	ifdef OBJ
184 #	    ifdef ADDR32
185 #		define MAGICNUM 0403	/* obj magic number */
186 #		define DPOFF1		0
187 #		define DPOFF2		(sizeof (struct blockmark))
188 #		define INPUT_OFF	-8	/* offset of `input' */
189 #		define OUTPUT_OFF	-4	/* offset of `output' */
190 #	    endif ADDR32
191 #	    ifdef ADDR16
192 #		define MAGICNUM 0404
193 #		define DPOFF1		0
194 #		define DPOFF2		(sizeof (struct blockmark))
195 #		define INPUT_OFF	-2
196 #		define OUTPUT_OFF	-4
197 #	    endif ADDR16
198 #	endif OBJ
199 #	ifdef	PC
200 #	    define DPOFF1	( sizeof (struct rtlocals) )
201 #	    define DPOFF2	( sizeof (struct blockmark) )
202 #	    define INPUT_OFF	0
203 #	    define OUTPUT_OFF	0
204 #	endif PC
205