Make @property psw use pswfields/dict methods
This commit is contained in:
parent
5df044e44c
commit
0f32d9fca9
1 changed files with 8 additions and 22 deletions
30
machine.py
30
machine.py
|
@ -921,28 +921,14 @@ class PDP1170(PDP11):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def psw(self):
|
def psw(self):
|
||||||
# NOTE: to simplify/accelerate condition code handling during
|
pswd = {attr: getattr(self, 'psw_' + attr)
|
||||||
# instructions, the NZVC bits are broken out into individual
|
for attr in self._pswfields}
|
||||||
# attributes, and are stored as truthy/falsey not necessarily
|
# the various 1-bit attributes are stored as "truthy/falsy"
|
||||||
# 1/0 or True/False.
|
# in the psw_foo attributes but need to be normalized to 1/0 here
|
||||||
|
for a, v in pswd.items():
|
||||||
# so, to reconstitute NZVC bits ...
|
if self._pswfields[a][1] == 1:
|
||||||
NZVC = 0
|
pswd[a] = bool(v)
|
||||||
if self.psw_n:
|
return self._dict2psw(pswd)
|
||||||
NZVC |= 0o10
|
|
||||||
if self.psw_z:
|
|
||||||
NZVC |= 0o04
|
|
||||||
if self.psw_v:
|
|
||||||
NZVC |= 0o02
|
|
||||||
if self.psw_c:
|
|
||||||
NZVC |= 0o01
|
|
||||||
|
|
||||||
return (((self.psw_curmode & 3) << 14) |
|
|
||||||
((self.psw_prevmode & 3) << 12) |
|
|
||||||
((self.psw_regset & 1) << 11) |
|
|
||||||
((self.psw_pri & 7) << 5) |
|
|
||||||
((self.psw_trap & 1) << 4) |
|
|
||||||
NZVC)
|
|
||||||
|
|
||||||
# Write the ENTIRE processor word, without any privilege enforcement.
|
# Write the ENTIRE processor word, without any privilege enforcement.
|
||||||
# The lack of privilege enforcement is necessary because, e.g., that's
|
# The lack of privilege enforcement is necessary because, e.g., that's
|
||||||
|
|
Loading…
Add table
Reference in a new issue