@@ -39,42 +39,105 @@ impl Fpscr {
39
39
self . bits & ( 1 << 31 ) != 0
40
40
}
41
41
42
+ /// Sets the Negative condition code flag
43
+ pub fn set_n ( & mut self , n : bool ) {
44
+ let mask = 1 << 31 ;
45
+ match n {
46
+ true => self . bits |= mask,
47
+ false => self . bits &= !mask,
48
+ }
49
+ }
50
+
42
51
/// Read the Zero condition code flag
43
52
#[ inline]
44
53
pub fn z ( self ) -> bool {
45
54
self . bits & ( 1 << 30 ) != 0
46
55
}
47
56
57
+ /// Sets the Zero condition code flag
58
+ pub fn set_z ( & mut self , z : bool ) {
59
+ let mask = 1 << 30 ;
60
+ match z {
61
+ true => self . bits |= mask,
62
+ false => self . bits &= !mask,
63
+ }
64
+ }
65
+
48
66
/// Read the Carry condition code flag
49
67
#[ inline]
50
68
pub fn c ( self ) -> bool {
51
69
self . bits & ( 1 << 29 ) != 0
52
70
}
53
71
72
+ /// Sets the Carry condition code flag
73
+ pub fn set_c ( & mut self , c : bool ) {
74
+ let mask = 1 << 29 ;
75
+ match c {
76
+ true => self . bits |= mask,
77
+ false => self . bits &= !mask,
78
+ }
79
+ }
80
+
54
81
/// Read the Overflow condition code flag
55
82
#[ inline]
56
83
pub fn v ( self ) -> bool {
57
84
self . bits & ( 1 << 28 ) != 0
58
85
}
59
86
87
+ /// Sets the Zero condition code flag
88
+ pub fn set_v ( & mut self , v : bool ) {
89
+ let mask = 1 << 28 ;
90
+ match v {
91
+ true => self . bits |= mask,
92
+ false => self . bits &= !mask,
93
+ }
94
+ }
95
+
60
96
/// Read the Alternative Half Precision bit
61
97
#[ inline]
62
98
pub fn ahp ( self ) -> bool {
63
99
self . bits & ( 1 << 26 ) != 0
64
100
}
65
101
102
+ /// Sets the Alternative Half Precision bit
103
+ pub fn set_ahp ( & mut self , ahp : bool ) {
104
+ let mask = 1 << 26 ;
105
+ match ahp {
106
+ true => self . bits |= mask,
107
+ false => self . bits &= !mask,
108
+ }
109
+ }
110
+
66
111
/// Read the Default NaN mode bit
67
112
#[ inline]
68
113
pub fn dn ( self ) -> bool {
69
114
self . bits & ( 1 << 25 ) != 0
70
115
}
71
116
117
+ /// Sets the Default NaN mode bit
118
+ pub fn set_dn ( & mut self , dn : bool ) {
119
+ let mask = 1 << 25 ;
120
+ match dn {
121
+ true => self . bits |= mask,
122
+ false => self . bits &= !mask,
123
+ }
124
+ }
125
+
72
126
/// Read the Flush to Zero mode bit
73
127
#[ inline]
74
128
pub fn fz ( self ) -> bool {
75
129
self . bits & ( 1 << 24 ) != 0
76
130
}
77
131
132
+ /// Sets the Flush to Zero mode bit
133
+ pub fn set_fz ( & mut self , fz : bool ) {
134
+ let mask = 1 << 24 ;
135
+ match fz {
136
+ true => self . bits |= mask,
137
+ false => self . bits &= !mask,
138
+ }
139
+ }
140
+
78
141
/// Read the Rounding Mode control field
79
142
#[ inline]
80
143
pub fn rmode ( self ) -> RMode {
@@ -86,41 +149,106 @@ impl Fpscr {
86
149
}
87
150
}
88
151
152
+ /// Sets the Rounding Mode control field
153
+ pub fn set_rmode ( & mut self , rmode : RMode ) {
154
+ let mask = 3 << 22 ;
155
+ match rmode {
156
+ RMode :: Nearest => self . bits = ( self . bits & !mask) ,
157
+ RMode :: Nearest => self . bits = ( self . bits & !mask) | ( 1 << 22 ) ,
158
+ RMode :: Nearest => self . bits = ( self . bits & !mask) | ( 2 << 22 ) ,
159
+ RMode :: Nearest => self . bits = self . bits | mask,
160
+ }
161
+ }
162
+
89
163
/// Read the Input Denormal cumulative exception bit
90
164
#[ inline]
91
165
pub fn idc ( self ) -> bool {
92
166
self . bits & ( 1 << 7 ) != 0
93
167
}
94
168
169
+ /// Sets the Input Denormal cumulative exception bit
170
+ pub fn set_idc ( & mut self , idc : bool ) {
171
+ let mask = 1 << 7 ;
172
+ match idc {
173
+ true => self . bits |= mask,
174
+ false => self . bits &= !mask,
175
+ }
176
+ }
177
+
95
178
/// Read the Inexact cumulative exception bit
96
179
#[ inline]
97
180
pub fn ixc ( self ) -> bool {
98
181
self . bits & ( 1 << 4 ) != 0
99
182
}
100
183
184
+ /// Sets the Inexact cumulative exception bit
185
+ pub fn set_ixc ( & mut self , ixc : bool ) {
186
+ let mask = 1 << 4 ;
187
+ match ixc {
188
+ true => self . bits |= mask,
189
+ false => self . bits &= !mask,
190
+ }
191
+ }
192
+
101
193
/// Read the Underflow cumulative exception bit
102
194
#[ inline]
103
195
pub fn ufc ( self ) -> bool {
104
196
self . bits & ( 1 << 3 ) != 0
105
197
}
106
198
199
+ /// Sets the Underflow cumulative exception bit
200
+ pub fn set_ufc ( & mut self , ufc : bool ) {
201
+ let mask = 1 << 3 ;
202
+ match ufc {
203
+ true => self . bits |= mask,
204
+ false => self . bits &= !mask,
205
+ }
206
+ }
207
+
107
208
/// Read the Overflow cumulative exception bit
108
209
#[ inline]
109
210
pub fn ofc ( self ) -> bool {
110
211
self . bits & ( 1 << 2 ) != 0
111
212
}
112
213
214
+ /// Sets the Overflow cumulative exception bit
215
+ pub fn set_ofc ( & mut self , ofc : bool ) {
216
+ let mask = 1 << 2 ;
217
+ match ofc {
218
+ true => self . bits |= mask,
219
+ false => self . bits &= !mask,
220
+ }
221
+ }
222
+
113
223
/// Read the Division by Zero cumulative exception bit
114
224
#[ inline]
115
225
pub fn dzc ( self ) -> bool {
116
226
self . bits & ( 1 << 1 ) != 0
117
227
}
118
228
229
+ /// Sets the Division by Zero cumulative exception bit
230
+ pub fn set_dzc ( & mut self , dzc : bool ) {
231
+ let mask = 1 << 1 ;
232
+ match dzc {
233
+ true => self . bits |= mask,
234
+ false => self . bits &= !mask,
235
+ }
236
+ }
237
+
119
238
/// Read the Invalid Operation cumulative exception bit
120
239
#[ inline]
121
240
pub fn ioc ( self ) -> bool {
122
241
self . bits & ( 1 << 0 ) != 0
123
242
}
243
+
244
+ /// Sets the Invalid Operation cumulative exception bit
245
+ pub fn set_ioc ( & mut self , ioc : bool ) {
246
+ let mask = 1 << 0 ;
247
+ match ioc {
248
+ true => self . bits |= mask,
249
+ false => self . bits &= !mask,
250
+ }
251
+ }
124
252
}
125
253
126
254
/// Read the FPSCR register
0 commit comments