148108Sbostic /*- 2*62183Sbostic * Copyright (c) 1980, 1993 3*62183Sbostic * The Regents of the University of California. All rights reserved. 422158Sdist * 548108Sbostic * %sccs.include.redist.c% 648108Sbostic * 7*62183Sbostic * @(#)machdep.h 8.1 (Berkeley) 06/06/93 822158Sdist */ 92081Smckusick 1010235Smckusick #ifdef ADDR32 1136537Smckusick #define pushaddr(x) push4((long)(x)) 1236537Smckusick #define popaddr() (char *)pop4() 1310235Smckusick #endif ADDR32 1410235Smckusick #ifdef ADDR16 1536537Smckusick #define pushaddr(x) push2((short)(x)) 1636537Smckusick #define popaddr() (char *)pop2() 1710235Smckusick #endif ADDR16 1830056Smckusick 1936537Smckusick #define popfile() (FILE *)(popaddr()) 2036537Smckusick 2136537Smckusick #if defined(pdp11) 2236537Smckusick #define popint pop2 2336537Smckusick #define pushint push2 2436537Smckusick #else 2536537Smckusick #define popint pop4 2636537Smckusick #define pushint push4 2736537Smckusick #endif 2836537Smckusick 2930056Smckusick /* 3030056Smckusick * Machine specific macros for reading quantities from the 3130056Smckusick * interpreter instruction stream. Operands in the instruction 3230056Smckusick * stream are aligned to short, but not long boundries. Blockmarks 3330056Smckusick * are always long aligned. Stack alignment indicates whether the 3430056Smckusick * stack is short or long aligned. Stack alignment is assumed to 3530056Smckusick * be no more than long aligned for ADDR32 machines, short aligned 3630056Smckusick * for ADDR16 machines. 3730056Smckusick */ 3830056Smckusick #if defined(vax) || defined(mc68000) || defined(pdp11) 3930056Smckusick #define PCLONGVAL(target) target = *pc.lp++ 4030056Smckusick #define GETLONGVAL(target, srcptr) target = *(long *)(srcptr) 4130056Smckusick #define STACKALIGN(target, value) target = ((value) + 1) &~ 1 4230056Smckusick #endif vax || mc68000 || pdp11 4330056Smckusick 4430056Smckusick #ifdef tahoe 4530056Smckusick #define PCLONGVAL(target) target = *pc.sp++ << 16, target += *pc.usp++ 4630056Smckusick #define GETLONGVAL(target, srcptr) \ 4730056Smckusick tsp = (short *)(srcptr), \ 4830056Smckusick target = *tsp++ << 16, target += *(unsigned short *)tsp 4930056Smckusick #define STACKALIGN(target, value) target = ((value) + 3) &~ 3 5030056Smckusick #endif tahoe 5136537Smckusick 5236537Smckusick /* 5336537Smckusick * The following macros implement all accesses to the interpreter stack. 5436537Smckusick * 5536537Smckusick * They used to be hard-coded assembler stuff massaged into the compiler 5636537Smckusick * output by sed scripts, but things are cleaner now. 5736537Smckusick * 5836537Smckusick * The STACKSIZE is an arbitrary value. I picked 100K since it was unlikely 5936537Smckusick * that anybody's program would run out of stack. Automatic allocation 6036537Smckusick * would be nice, maybe procedure call should check for enough space + slop 6136537Smckusick * and expand it if necessary. Expanding the stack will require 6236537Smckusick * pointer relocation if it moves, though. Probably better would be a 6336537Smckusick * command line option to set the stack size. 6436537Smckusick */ 6536537Smckusick #define STACKSIZE 100000 6636537Smckusick #define setup() { \ 6736537Smckusick extern char *malloc(); \ 6836537Smckusick stack.cp = STACKSIZE + malloc((unsigned)STACKSIZE); \ 6936537Smckusick } 7036537Smckusick #ifndef tahoe 7136537Smckusick #define push2(x) (*--stack.sp) = (x) 7236537Smckusick #else 7336537Smckusick #define push2(x) (*--stack.lp) = (x) << 16 7436537Smckusick #endif 7536537Smckusick #define push4(x) (*--stack.lp) = (x) 7636537Smckusick #define push8(x) (*--stack.dbp) = (x) 7736537Smckusick #define pushsze8(x) (*--stack.s8p) = (x) 7836537Smckusick #define pushsp(x) (stack.cp -= (x)) 7936537Smckusick #ifndef tahoe 8036537Smckusick #define pop2() (*stack.sp++) 8136537Smckusick #else 8236537Smckusick #define pop2() (*stack.lp++) >> 16 8336537Smckusick #endif 8436537Smckusick #define pop4() (*stack.lp++) 8536537Smckusick #define pop8() (*stack.dbp++) 8636537Smckusick #define popsze8() (*stack.s8p++) 8736537Smckusick #define popsp(x) (void)(stack.cp += (x)) 8836537Smckusick #define enableovrflo() /*nop*/ 8936537Smckusick #define disableovrflo() /*nop*/ 90