Pretty important bug fix for byte instruction register semantics

This commit is contained in:
Neil Webber 2023-10-28 13:33:20 -05:00
parent e3c0782c72
commit e42601ae14

View file

@ -433,9 +433,10 @@ class PDP11:
case Rn, None, 1: case Rn, None, 1:
value = self.r[Rn] & 0o377 value = self.r[Rn] & 0o377
case Rn, bv, 1: case Rn, bv, 1:
self.r[Rn] = bv # NOTE: The MOVB instruction has different semantics
if bv > 127: # than this; it is coded explicitly in op11_movb()
self.r[Rn] |= 0xFF00 self.r[Rn] &= 0o177400
self.r[Rn] |= (bv & 0o377)
return (value, b6) if rmw else value return (value, b6) if rmw else value
# harder cases # harder cases
@ -530,22 +531,16 @@ class PDP11:
# convenience, creates a breakpoint to stop at the given pc, # convenience, creates a breakpoint to stop at the given pc,
# optionally limited to a specific mode (KERNEL, USER, SUPERVISOR) # optionally limited to a specific mode (KERNEL, USER, SUPERVISOR)
def run_until(self, *args, stoppc, stopmode=None, **kwargs): def run_until(self, *args, stoppc, stopmode=None, **kwargs):
"""Run processor with breakpoint at 'stopat'. """Run processor with breakpoint at 'stoppc'.
If stopat is an integer, stop at that PC value in any mode. if stopmode is None (default), stop at the stoppc in any mode.
If stopat is a tuple, stop at (pc, mode) where mode Otherwise, only stop if mode is stopmode.
is self.KERNEL, self.SUPERVISOR or self.USER
""" """
bpt = PCBreakpoint(stoppc=stoppc, stopmode=stopmode) bpt = PCBreakpoint(stoppc=stoppc, stopmode=stopmode)
return self.run(*args, breakpoint=bpt, **kwargs) return self.run(*args, breakpoint=bpt, **kwargs)
def run(self, *, pc=None, breakpoint=None): def run(self, *, pc=None, breakpoint=None):
"""Run the machine for a number of steps (instructions). """The CPU main loop - run the machine!
If steps is None (default), the machine runs until a HALT instruction
is encountered. It may run forever and the method might never return.
Otherwise, it runs for that many instructions (or until a HALT).
If pc is None (default) execution begins at the current pc; otherwise If pc is None (default) execution begins at the current pc; otherwise
the pc is set to the given value first. the pc is set to the given value first.