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