Pristine Ack-5.5
[Ack-5.5.git] / util / int / text.c
1 /*
2         Manipulating the Program Counter
3 */
4
5 /* $Id: text.c,v 2.3 1994/06/24 10:49:22 ceriel Exp $ */
6
7 #include        <em_abs.h>
8 #include        "global.h"
9 #include        "alloc.h"
10 #include        "trap.h"
11 #include        "text.h"
12 #include        "read.h"
13 #include        "proctab.h"
14 #include        "warn.h"
15
16 init_text() {
17         DB = i2p(NTEXT);                /* set Descriptor Base */
18         NProc = NPROC;                  /* set Number of Proc. Descriptors */
19         PI = -1;                        /* initialize Procedure Identifier */
20         PC = 0;                         /* initialize Program Counter */
21
22         text = Malloc((size)p2i(DB), "text space");
23 }
24
25
26 /************************************************************************
27  *      Program Counter division                                        *
28  ************************************************************************
29  *                                                                      *
30  *      newPC(p)        - check and adjust PC.                          *
31  *                                                                      *
32  ************************************************************************/
33
34 newPC(p)
35         register ptr p;
36 {
37         register struct proc *pr = &proctab[PI];
38
39         if (p >= DB) {
40                 wtrap(WPCOVFL, EBADPC);
41         }
42         if (p < pr->pr_ep || p >= pr->pr_ff) {
43                 wtrap(WPCPROC, EBADPC);
44         }
45         PC = p;
46 }
47