text.c 987 B

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