Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/* 	$Id: guard.c,v 1.1.1.1 1998/01/17 15:56:00 release Exp $	 */
32
 
33
#ifndef lint
34
static char vcid[] = "$Id: guard.c,v 1.1.1.1 1998/01/17 15:56:00 release Exp $";
35
#endif /* lint */
36
 
37
/*
38
  guard.c
39
 
40
  These routines are provided to guard registers from use.
41
*/
42
 
43
 
44
#include "config.h"
45
#include "fail.h"
46
#include "procrecs.h"
47
#include "addresstypes.h"
48
#include "guard.h"
49
 
50
 
51
/*
52
  guardregs() and guardfregs() take two arguments : an integer 
53
  representing the register to be guarded and a space variable 
54
  representing the current status of the pool of registers.  A 
55
  register is guarded by setting its corresponding bit in the 
56
  space variable to 1.
57
*/
58
space guardreg
59
    PROTO_N ( ( r,sp ) )
60
    PROTO_T ( int r X space sp )
61
{
62
  if ((r >= 0 && r <= 8) || (r>=16 && r<=21)||(r >= 22 && r <= 26)||(r==27)) {
63
				/* r is a fixed point t reg */
64
    sp.fixed |= (1 << r);
65
  }				/* set bit in the fixed field of sp */
66
  return sp;
67
}
68
 
69
space guardfreg
70
    PROTO_N ( ( r, sp ) )
71
    PROTO_T ( int r X space sp )
72
{
73
  if((r==0)||(r>=10 && r<=21)||(r>=22 && r<=30))
74
    sp.flt |= (1<<r);
75
  return sp;
76
}
77
 
78
 
79
/*
80
   Guard takes an expression and protects the register involved 
81
   in the same manner as guardreg and guardfreg.  If the expression 
82
   is in store the register can be obtained from the base part 
83
   of the address.
84
*/
85
space guard
86
    PROTO_N ( ( w,sp ) )
87
    PROTO_T ( where w X space sp )
88
{
89
  switch (w.answhere.discrim) {
90
    case inreg : {
91
      int   r = regalt (w.answhere);
92
      if((r>=0 && r<=8) || (r>=16 && r<=21) || (r>=22 && r<=27)) {
93
	sp.fixed |= (1 << r);
94
      }			/* guard reg */
95
      return sp;
96
    }
97
    case infreg : {
98
      int   r = fregalt (w.answhere).fr;
99
      if ((r<=15) ||(r>=16 && r<=21)||((r>=22) && (r<=30))) {
100
	sp.flt |= (1 << r);
101
      }			/* guard freg */
102
      return sp;
103
    }
104
    case notinreg : {
105
      int   r = insalt (w.answhere).b.base;
106
      if((r>=0 && r<=8) || (r>=16 && r<=21) || (r>=22 && r<=27)) {
107
	sp.fixed |= (1 << r);
108
      }
109
      /* guard fixed point t reg used as base of address */
110
      return sp;
111
    }
112
    case insomereg : 
113
    case insomefreg : {
114
      failer ("Guard ? reg ");
115
      break;
116
    }
117
    default:{
118
      failer ("error in guard\n");
119
      break;
120
    }
121
  }	
122
  return sp;
123
}