home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / pascal / src / objfmt.h.new < prev    next >
Encoding:
Text File  |  1991-04-20  |  6.4 KB  |  250 lines

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