Merge pull request #8 from folkertvanheusden/SOB

made SOB into how simh does it
This commit is contained in:
Neil Webber 2024-03-31 11:58:51 -05:00 committed by GitHub
commit 3afe220ac1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

11
op07.py
View file

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