1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#
# RTEMS gdb extensions
# sparc archetecture specific abstractions
from helper import test_bit
class psr:
'''status register'''
sv_table = {
0 : 'user',
1 : 'superviser'
}
def __init__(self, psr):
self.psr = psr
def current_window(self):
return int(self.psr & 0xf)
def traps(self):
return test_bit(self.psr, 5)
def prev_superviser(self):
return int(test_bit(self.psr,6))
def superviser(self):
return int(test_bit(self.psr,7))
def interrupt_level(self):
# bits 8 to 11
return (self.spr & 0x780) >> 7
def floating_point_status(self):
return test_bit(self.psr, 12)
def coproc_status(self):
return test_bit(self.psr,13)
def carry(self):
return test_bit(self.psr, 20)
def overflow(self):
return test_bit(self.psr, 21)
def zero(self):
return test_bit(self.psr, 22)
def icc(self):
n = test_bit(self.psr,23)
z = test_bit(self.psr,22)
v = test_bit(self.psr,21)
c = test_bit(self.psr,20)
return (n,z,v,c)
def to_string(self):
val = " Status Register"
val += "\n R Window : " + str(self.current_window())
val += "\n Traps Enabled : " + str(self.traps())
val += "\n Flaoting Point : " + str(self.floating_point_status())
val += "\n Coprocessor : " + str(self.coproc_status())
val += "\n Processor Mode : " + self.sv_table[self.superviser()]
val += "\n Prev. Mode : " + self.sv_table[self.superviser()]
val += "\n Carry : " + str(int(self.carry()))
val += "\n Overflow : " + str(int(self.overflow()))
val += "\n Zero : " + str(int(self.zero()))
return val
|