xref: /original-bsd/usr.bin/pascal/px/machdep.h (revision c3e32dec)
1 /*-
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)machdep.h	8.1 (Berkeley) 06/06/93
8  */
9 
10 #ifdef ADDR32
11 #define pushaddr(x)	push4((long)(x))
12 #define popaddr()	(char *)pop4()
13 #endif ADDR32
14 #ifdef ADDR16
15 #define pushaddr(x)	push2((short)(x))
16 #define popaddr()	(char *)pop2()
17 #endif ADDR16
18 
19 #define popfile()	(FILE *)(popaddr())
20 
21 #if defined(pdp11)
22 #define	popint	pop2
23 #define	pushint	push2
24 #else
25 #define popint	pop4
26 #define pushint	push4
27 #endif
28 
29 /*
30  * Machine specific macros for reading quantities from the
31  * interpreter instruction stream. Operands in the instruction
32  * stream are aligned to short, but not long boundries. Blockmarks
33  * are always long aligned. Stack alignment indicates whether the
34  * stack is short or long aligned. Stack alignment is assumed to
35  * be no more than long aligned for ADDR32 machines, short aligned
36  * for ADDR16 machines.
37  */
38 #if defined(vax) || defined(mc68000) || defined(pdp11)
39 #define PCLONGVAL(target) target = *pc.lp++
40 #define GETLONGVAL(target, srcptr) target = *(long *)(srcptr)
41 #define STACKALIGN(target, value) target = ((value) + 1) &~ 1
42 #endif vax || mc68000 || pdp11
43 
44 #ifdef tahoe
45 #define PCLONGVAL(target) target = *pc.sp++ << 16, target += *pc.usp++
46 #define GETLONGVAL(target, srcptr) \
47 	tsp = (short *)(srcptr), \
48 	target = *tsp++ << 16, target += *(unsigned short *)tsp
49 #define STACKALIGN(target, value) target = ((value) + 3) &~ 3
50 #endif tahoe
51 
52 /*
53  * The following macros implement all accesses to the interpreter stack.
54  *
55  * They used to be hard-coded assembler stuff massaged into the compiler
56  * output by sed scripts, but things are cleaner now.
57  *
58  * The STACKSIZE is an arbitrary value.  I picked 100K since it was unlikely
59  * that anybody's program would run out of stack.  Automatic allocation
60  * would be nice, maybe procedure call should check for enough space + slop
61  * and expand it if necessary.  Expanding the stack will require
62  * pointer relocation if it moves, though.  Probably better would be a
63  * command line option to set the stack size.
64  */
65 #define	STACKSIZE	100000
66 #define	setup()		{ \
67 	extern char *malloc(); \
68 	stack.cp = STACKSIZE + malloc((unsigned)STACKSIZE); \
69 	}
70 #ifndef tahoe
71 #define	push2(x)	(*--stack.sp) = (x)
72 #else
73 #define	push2(x)	(*--stack.lp) = (x) << 16
74 #endif
75 #define push4(x)	(*--stack.lp)  = (x)
76 #define push8(x)	(*--stack.dbp) = (x)
77 #define pushsze8(x)	(*--stack.s8p) = (x)
78 #define pushsp(x)	(stack.cp -= (x))
79 #ifndef tahoe
80 #define pop2()		(*stack.sp++)
81 #else
82 #define pop2()		(*stack.lp++) >> 16
83 #endif
84 #define pop4()		(*stack.lp++)
85 #define pop8()		(*stack.dbp++)
86 #define popsze8()	(*stack.s8p++)
87 #define popsp(x)	(void)(stack.cp += (x))
88 #define	enableovrflo()	/*nop*/
89 #define	disableovrflo()	/*nop*/
90