|
|
1.1 root 1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)traper_.c 5.3 11/3/86
7: *
8: * Full of Magic! DON'T CHANGE ANYTHING !!
9: *
10: * To use from f77:
11: * integer oldmsk, traper
12: * oldmsk = traper (mask)
13: * where for vax:
14: * mask = 1 to trap integer overflow
15: * mask = 2 to trap floating underflow
16: * mask = 3 to trap both
17: * These 2 bits will be set into the PSW.
18: * The old state will be returned.
19: *
20: * where for CCI:
21: * mask = 0 to trap neither
22: * mask = 1 to trap integer overflow
23: * mask = 2 to trap floating underflow
24: * mask = 3 to trap both
25: * These 2 bits will be set into the PSL.
26: * The old state will be returned.
27: */
28:
29: #ifdef vax
30: long traper_(msk)
31: long *msk;
32: {
33: int old = 0;
34: #define IOV_MASK 0140
35: int **s = &msk;
36: int psw;
37:
38: s -= 5;
39: psw = (int)*s;
40: old = (psw & IOV_MASK) >> 5;
41: psw = (psw & ~IOV_MASK) | ((*msk << 5) & IOV_MASK);
42: *s = (int *)psw;
43: return((long)old);
44: }
45: #endif vax
46:
47: /*
48: * Assumptions for CCI:
49: * - the two bits are contiguous in PSL;
50: * - integer overflow trap enable bit < floating underflow trap enable bit;
51: */
52: #ifdef tahoe
53: # include <machine/psl.h>
54:
55: unsigned long old_msk;
56: unsigned short new_msk;
57: unsigned long tst_msk;
58:
59: long traper_(msk)
60: long *msk;
61: {
62: #define IOV_MASK (PSL_IV | PSL_FU)
63: #define IOV_DISP 5
64:
65: asm(" movpsl _old_msk");
66:
67: old_msk = (old_msk & IOV_MASK) >> IOV_DISP;
68:
69: new_msk = (*msk << IOV_DISP) & IOV_MASK;
70: asm(" bispsw _new_msk");
71:
72: new_msk = ~(*msk << IOV_DISP) & IOV_MASK;
73: asm(" bicpsw _new_msk");
74:
75: return(old_msk);
76: }
77: #endif tahoe
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.