xref: /csrg-svn/usr.bin/pascal/px/machdep.h (revision 36537)
122158Sdist /*
222158Sdist  * Copyright (c) 1980 Regents of the University of California.
322158Sdist  * All rights reserved.  The Berkeley software License Agreement
422158Sdist  * specifies the terms and conditions for redistribution.
522158Sdist  *
6*36537Smckusick  *	@(#)machdep.h	5.3 (Berkeley) 01/09/89
722158Sdist  */
82081Smckusick 
910235Smckusick #ifdef ADDR32
10*36537Smckusick #define pushaddr(x)	push4((long)(x))
11*36537Smckusick #define popaddr()	(char *)pop4()
1210235Smckusick #endif ADDR32
1310235Smckusick #ifdef ADDR16
14*36537Smckusick #define pushaddr(x)	push2((short)(x))
15*36537Smckusick #define popaddr()	(char *)pop2()
1610235Smckusick #endif ADDR16
1730056Smckusick 
18*36537Smckusick #define popfile()	(FILE *)(popaddr())
19*36537Smckusick 
20*36537Smckusick #if defined(pdp11)
21*36537Smckusick #define	popint	pop2
22*36537Smckusick #define	pushint	push2
23*36537Smckusick #else
24*36537Smckusick #define popint	pop4
25*36537Smckusick #define pushint	push4
26*36537Smckusick #endif
27*36537Smckusick 
2830056Smckusick /*
2930056Smckusick  * Machine specific macros for reading quantities from the
3030056Smckusick  * interpreter instruction stream. Operands in the instruction
3130056Smckusick  * stream are aligned to short, but not long boundries. Blockmarks
3230056Smckusick  * are always long aligned. Stack alignment indicates whether the
3330056Smckusick  * stack is short or long aligned. Stack alignment is assumed to
3430056Smckusick  * be no more than long aligned for ADDR32 machines, short aligned
3530056Smckusick  * for ADDR16 machines.
3630056Smckusick  */
3730056Smckusick #if defined(vax) || defined(mc68000) || defined(pdp11)
3830056Smckusick #define PCLONGVAL(target) target = *pc.lp++
3930056Smckusick #define GETLONGVAL(target, srcptr) target = *(long *)(srcptr)
4030056Smckusick #define STACKALIGN(target, value) target = ((value) + 1) &~ 1
4130056Smckusick #endif vax || mc68000 || pdp11
4230056Smckusick 
4330056Smckusick #ifdef tahoe
4430056Smckusick #define PCLONGVAL(target) target = *pc.sp++ << 16, target += *pc.usp++
4530056Smckusick #define GETLONGVAL(target, srcptr) \
4630056Smckusick 	tsp = (short *)(srcptr), \
4730056Smckusick 	target = *tsp++ << 16, target += *(unsigned short *)tsp
4830056Smckusick #define STACKALIGN(target, value) target = ((value) + 3) &~ 3
4930056Smckusick #endif tahoe
50*36537Smckusick 
51*36537Smckusick /*
52*36537Smckusick  * The following macros implement all accesses to the interpreter stack.
53*36537Smckusick  *
54*36537Smckusick  * They used to be hard-coded assembler stuff massaged into the compiler
55*36537Smckusick  * output by sed scripts, but things are cleaner now.
56*36537Smckusick  *
57*36537Smckusick  * The STACKSIZE is an arbitrary value.  I picked 100K since it was unlikely
58*36537Smckusick  * that anybody's program would run out of stack.  Automatic allocation
59*36537Smckusick  * would be nice, maybe procedure call should check for enough space + slop
60*36537Smckusick  * and expand it if necessary.  Expanding the stack will require
61*36537Smckusick  * pointer relocation if it moves, though.  Probably better would be a
62*36537Smckusick  * command line option to set the stack size.
63*36537Smckusick  */
64*36537Smckusick #define	STACKSIZE	100000
65*36537Smckusick #define	setup()		{ \
66*36537Smckusick 	extern char *malloc(); \
67*36537Smckusick 	stack.cp = STACKSIZE + malloc((unsigned)STACKSIZE); \
68*36537Smckusick 	}
69*36537Smckusick #ifndef tahoe
70*36537Smckusick #define	push2(x)	(*--stack.sp) = (x)
71*36537Smckusick #else
72*36537Smckusick #define	push2(x)	(*--stack.lp) = (x) << 16
73*36537Smckusick #endif
74*36537Smckusick #define push4(x)	(*--stack.lp)  = (x)
75*36537Smckusick #define push8(x)	(*--stack.dbp) = (x)
76*36537Smckusick #define pushsze8(x)	(*--stack.s8p) = (x)
77*36537Smckusick #define pushsp(x)	(stack.cp -= (x))
78*36537Smckusick #ifndef tahoe
79*36537Smckusick #define pop2()		(*stack.sp++)
80*36537Smckusick #else
81*36537Smckusick #define pop2()		(*stack.lp++) >> 16
82*36537Smckusick #endif
83*36537Smckusick #define pop4()		(*stack.lp++)
84*36537Smckusick #define pop8()		(*stack.dbp++)
85*36537Smckusick #define popsze8()	(*stack.s8p++)
86*36537Smckusick #define popsp(x)	(void)(stack.cp += (x))
87*36537Smckusick #define	enableovrflo()	/*nop*/
88*36537Smckusick #define	disableovrflo()	/*nop*/
89