home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / pascal / px / machdep.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-16  |  4.4 KB  |  116 lines

  1. /*-
  2.  * Copyright (c) 1980 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)machdep.h    5.4 (Berkeley) 4/16/91
  34.  */
  35.  
  36. #ifdef ADDR32
  37. #define pushaddr(x)    push4((long)(x))
  38. #define popaddr()    (char *)pop4()
  39. #endif ADDR32
  40. #ifdef ADDR16
  41. #define pushaddr(x)    push2((short)(x))
  42. #define popaddr()    (char *)pop2()
  43. #endif ADDR16
  44.  
  45. #define popfile()    (FILE *)(popaddr())
  46.  
  47. #if defined(pdp11)
  48. #define    popint    pop2
  49. #define    pushint    push2
  50. #else
  51. #define popint    pop4
  52. #define pushint    push4
  53. #endif
  54.  
  55. /*
  56.  * Machine specific macros for reading quantities from the
  57.  * interpreter instruction stream. Operands in the instruction
  58.  * stream are aligned to short, but not long boundries. Blockmarks
  59.  * are always long aligned. Stack alignment indicates whether the
  60.  * stack is short or long aligned. Stack alignment is assumed to
  61.  * be no more than long aligned for ADDR32 machines, short aligned
  62.  * for ADDR16 machines.
  63.  */
  64. #if defined(vax) || defined(mc68000) || defined(pdp11)
  65. #define PCLONGVAL(target) target = *pc.lp++
  66. #define GETLONGVAL(target, srcptr) target = *(long *)(srcptr)
  67. #define STACKALIGN(target, value) target = ((value) + 1) &~ 1
  68. #endif vax || mc68000 || pdp11
  69.  
  70. #ifdef tahoe
  71. #define PCLONGVAL(target) target = *pc.sp++ << 16, target += *pc.usp++
  72. #define GETLONGVAL(target, srcptr) \
  73.     tsp = (short *)(srcptr), \
  74.     target = *tsp++ << 16, target += *(unsigned short *)tsp
  75. #define STACKALIGN(target, value) target = ((value) + 3) &~ 3
  76. #endif tahoe
  77.  
  78. /*
  79.  * The following macros implement all accesses to the interpreter stack.
  80.  *
  81.  * They used to be hard-coded assembler stuff massaged into the compiler
  82.  * output by sed scripts, but things are cleaner now.
  83.  *
  84.  * The STACKSIZE is an arbitrary value.  I picked 100K since it was unlikely
  85.  * that anybody's program would run out of stack.  Automatic allocation
  86.  * would be nice, maybe procedure call should check for enough space + slop
  87.  * and expand it if necessary.  Expanding the stack will require
  88.  * pointer relocation if it moves, though.  Probably better would be a
  89.  * command line option to set the stack size.
  90.  */
  91. #define    STACKSIZE    100000
  92. #define    setup()        { \
  93.     extern char *malloc(); \
  94.     stack.cp = STACKSIZE + malloc((unsigned)STACKSIZE); \
  95.     }
  96. #ifndef tahoe
  97. #define    push2(x)    (*--stack.sp) = (x)
  98. #else
  99. #define    push2(x)    (*--stack.lp) = (x) << 16
  100. #endif
  101. #define push4(x)    (*--stack.lp)  = (x)
  102. #define push8(x)    (*--stack.dbp) = (x)
  103. #define pushsze8(x)    (*--stack.s8p) = (x)
  104. #define pushsp(x)    (stack.cp -= (x))
  105. #ifndef tahoe
  106. #define pop2()        (*stack.sp++)
  107. #else
  108. #define pop2()        (*stack.lp++) >> 16
  109. #endif
  110. #define pop4()        (*stack.lp++)
  111. #define pop8()        (*stack.dbp++)
  112. #define popsze8()    (*stack.s8p++)
  113. #define popsp(x)    (void)(stack.cp += (x))
  114. #define    enableovrflo()    /*nop*/
  115. #define    disableovrflo()    /*nop*/
  116.