made SOB into how simh does it

This commit is contained in:
folkert van heusden 2024-03-31 12:21:44 +02:00
parent fa86a547ec
commit 3eecaa265d
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1

11
op07.py
View file

@ -195,16 +195,9 @@ def op074_xor(cpu, inst):
def op077_sob(cpu, inst): def op077_sob(cpu, inst):
srcreg = (inst & 0o000700) >> 6 srcreg = (inst & 0o000700) >> 6
r = cpu.r[srcreg] r = (cpu.r[srcreg] - 1) & 0xffff
if r == 1:
r = 0
else:
if r > 0:
r -= 1
else:
r = 0o177777 # 0 means max, that's how SOB is defined
if r != 0:
# technically if this instruction occurs low enough in memory # technically if this instruction occurs low enough in memory
# this PC subtraction could wrap, so be technically correct & mask # this PC subtraction could wrap, so be technically correct & mask
cpu.r[cpu.PC] = (cpu.r[cpu.PC] - 2 * (inst & 0o077)) & cpu.MASK16 cpu.r[cpu.PC] = (cpu.r[cpu.PC] - 2 * (inst & 0o077)) & cpu.MASK16