__iter__ for instruction blocks
This commit is contained in:
parent
ed0737c5b1
commit
80290556b9
1 changed files with 21 additions and 26 deletions
47
pdptests.py
47
pdptests.py
|
@ -177,7 +177,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.halt()
|
a.halt()
|
||||||
|
|
||||||
instloc = 0o4000 # 2K
|
instloc = 0o4000 # 2K
|
||||||
self.loadphysmem(p, a.instructions(), instloc)
|
self.loadphysmem(p, a, instloc)
|
||||||
return p, instloc
|
return p, instloc
|
||||||
|
|
||||||
# these tests end up testing other stuff too of course, including MMU
|
# these tests end up testing other stuff too of course, including MMU
|
||||||
|
@ -191,7 +191,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.mov(r1tval, 'r1')
|
a.mov(r1tval, 'r1')
|
||||||
a.mfpi('(r1)')
|
a.mfpi('(r1)')
|
||||||
a.mov('(sp)+', 'r0')
|
a.mov('(sp)+', 'r0')
|
||||||
tvecs.append((result, a.instructions()))
|
tvecs.append((result, list(a)),)
|
||||||
|
|
||||||
for result, insts in tvecs:
|
for result, insts in tvecs:
|
||||||
with self.subTest(result=result, insts=insts):
|
with self.subTest(result=result, insts=insts):
|
||||||
|
@ -205,7 +205,6 @@ class TestMethods(unittest.TestCase):
|
||||||
with ASM() as u:
|
with ASM() as u:
|
||||||
u.mov('r2', 'r6')
|
u.mov('r2', 'r6')
|
||||||
u.trap(0)
|
u.trap(0)
|
||||||
user_mode_instructions = u.instructions()
|
|
||||||
|
|
||||||
with ASM() as premmu:
|
with ASM() as premmu:
|
||||||
ts = premmu # just for brevity...
|
ts = premmu # just for brevity...
|
||||||
|
@ -213,7 +212,7 @@ class TestMethods(unittest.TestCase):
|
||||||
ts.clr(ts.ptr(0o36)) # PSW for trap - zero work
|
ts.clr(ts.ptr(0o36)) # PSW for trap - zero work
|
||||||
ts.mov(0o20000, 'r0') # mov #20000,r0
|
ts.mov(0o20000, 'r0') # mov #20000,r0
|
||||||
|
|
||||||
for uinst in user_mode_instructions:
|
for uinst in u:
|
||||||
ts.mov(uinst, '(r0)+')
|
ts.mov(uinst, '(r0)+')
|
||||||
ts.mov(0o123456, 'r2') # mov #123456,r2
|
ts.mov(0o123456, 'r2') # mov #123456,r2
|
||||||
ts.mov(0o140340, '-(sp)') # push user-ish PSW to K stack
|
ts.mov(0o140340, '-(sp)') # push user-ish PSW to K stack
|
||||||
|
@ -222,15 +221,14 @@ class TestMethods(unittest.TestCase):
|
||||||
with ASM() as postmmu:
|
with ASM() as postmmu:
|
||||||
postmmu.literal(6) # RTT - goes to user mode, addr 0
|
postmmu.literal(6) # RTT - goes to user mode, addr 0
|
||||||
|
|
||||||
p, pc = self.simplemapped_pdp(premmu=premmu.instructions(),
|
p, pc = self.simplemapped_pdp(premmu=premmu, postmmu=postmmu)
|
||||||
postmmu=postmmu.instructions())
|
|
||||||
|
|
||||||
# put the trap handler at 14000 as expected
|
# put the trap handler at 14000 as expected
|
||||||
with ASM() as th:
|
with ASM() as th:
|
||||||
th.mfpd('sp')
|
th.mfpd('sp')
|
||||||
th.mov('(sp)+', 'r3')
|
th.mov('(sp)+', 'r3')
|
||||||
th.halt()
|
th.halt()
|
||||||
self.loadphysmem(p, th.instructions(), 0o14000)
|
self.loadphysmem(p, th, 0o14000)
|
||||||
p.run(pc=pc)
|
p.run(pc=pc)
|
||||||
self.assertEqual(p.r[2], p.r[3])
|
self.assertEqual(p.r[2], p.r[3])
|
||||||
|
|
||||||
|
@ -243,7 +241,7 @@ class TestMethods(unittest.TestCase):
|
||||||
ts.clr(ts.ptr(cn.MMR0)) # turn MMU back off
|
ts.clr(ts.ptr(cn.MMR0)) # turn MMU back off
|
||||||
ts.mov(ts.ptr(0o20002), 'r0') # r0 = (020002)
|
ts.mov(ts.ptr(0o20002), 'r0') # r0 = (020002)
|
||||||
|
|
||||||
tvecs = ((0o1717, ts.instructions()),)
|
tvecs = ((0o1717, ts),)
|
||||||
|
|
||||||
for r0result, insts in tvecs:
|
for r0result, insts in tvecs:
|
||||||
with self.subTest(r0result=r0result, insts=insts):
|
with self.subTest(r0result=r0result, insts=insts):
|
||||||
|
@ -272,8 +270,7 @@ class TestMethods(unittest.TestCase):
|
||||||
with ASM() as a:
|
with ASM() as a:
|
||||||
getattr(a, addsub)('r0', 'r1')
|
getattr(a, addsub)('r0', 'r1')
|
||||||
a.halt()
|
a.halt()
|
||||||
for offs, inst in enumerate(a.instructions()):
|
self.loadphysmem(p, a, loc)
|
||||||
p.physmem[(loc >> 1) + offs] = inst
|
|
||||||
|
|
||||||
for r0, r1, added, a_nzvc, subbed, s_nzvc in testvecs:
|
for r0, r1, added, a_nzvc, subbed, s_nzvc in testvecs:
|
||||||
with self.subTest(r0=r0, r1=r1, op="add"):
|
with self.subTest(r0=r0, r1=r1, op="add"):
|
||||||
|
@ -314,7 +311,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.halt()
|
a.halt()
|
||||||
|
|
||||||
instloc = 0o4000
|
instloc = 0o4000
|
||||||
self.loadphysmem(p, a.instructions(), instloc)
|
self.loadphysmem(p, a, instloc)
|
||||||
|
|
||||||
p.run(pc=instloc)
|
p.run(pc=instloc)
|
||||||
self.assertEqual(p.r[0], loopcount)
|
self.assertEqual(p.r[0], loopcount)
|
||||||
|
@ -339,7 +336,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.halt()
|
a.halt()
|
||||||
|
|
||||||
instloc = 0o4000
|
instloc = 0o4000
|
||||||
self.loadphysmem(p, a.instructions(), instloc)
|
self.loadphysmem(p, a, instloc)
|
||||||
p.run(pc=instloc)
|
p.run(pc=instloc)
|
||||||
self.assertEqual(p.r[1], goodval)
|
self.assertEqual(p.r[1], goodval)
|
||||||
|
|
||||||
|
@ -379,7 +376,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.halt()
|
a.halt()
|
||||||
a.dec('r0')
|
a.dec('r0')
|
||||||
a.halt()
|
a.halt()
|
||||||
return a.instructions()
|
return a
|
||||||
|
|
||||||
def test_cc(self):
|
def test_cc(self):
|
||||||
# various condition code tests
|
# various condition code tests
|
||||||
|
@ -461,7 +458,7 @@ class TestMethods(unittest.TestCase):
|
||||||
|
|
||||||
p = self.make_pdp()
|
p = self.make_pdp()
|
||||||
instloc = 0o4000
|
instloc = 0o4000
|
||||||
self.loadphysmem(p, a.instructions(), instloc)
|
self.loadphysmem(p, a, instloc)
|
||||||
p.run(pc=instloc)
|
p.run(pc=instloc)
|
||||||
self.assertEqual(p.r[2], 0o1224)
|
self.assertEqual(p.r[2], 0o1224)
|
||||||
|
|
||||||
|
@ -493,8 +490,7 @@ class TestMethods(unittest.TestCase):
|
||||||
|
|
||||||
# put that mess into memory at an arbitrary spot
|
# put that mess into memory at an arbitrary spot
|
||||||
baseloc = 0o10000
|
baseloc = 0o10000
|
||||||
for a, w in enumerate(insts, start=(baseloc >> 1)):
|
self.loadphysmem(p, insts, baseloc)
|
||||||
p.physmem[a] = w
|
|
||||||
|
|
||||||
# test the negative offsets:
|
# test the negative offsets:
|
||||||
# Set R0 to 65535 (-1)
|
# Set R0 to 65535 (-1)
|
||||||
|
@ -640,7 +636,7 @@ class TestMethods(unittest.TestCase):
|
||||||
handler.movb('-2(r0)', 'r3')
|
handler.movb('-2(r0)', 'r3')
|
||||||
handler.rtt()
|
handler.rtt()
|
||||||
|
|
||||||
self.loadphysmem(p, handler.instructions(), 0o10000)
|
self.loadphysmem(p, handler, 0o10000)
|
||||||
|
|
||||||
# just bash a stack pointer directly in
|
# just bash a stack pointer directly in
|
||||||
p.r[6] = 0o20000 # 8K and working down
|
p.r[6] = 0o20000 # 8K and working down
|
||||||
|
@ -651,7 +647,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.mov('r3', 'r1') # MOV R3,R1 just to show RTT worked
|
a.mov('r3', 'r1') # MOV R3,R1 just to show RTT worked
|
||||||
a.halt()
|
a.halt()
|
||||||
|
|
||||||
self.loadphysmem(p, a.instructions(), 0o30000)
|
self.loadphysmem(p, a, 0o30000)
|
||||||
p.run(pc=0o30000)
|
p.run(pc=0o30000)
|
||||||
self.assertEqual(p.r[3], p.r[1])
|
self.assertEqual(p.r[3], p.r[1])
|
||||||
|
|
||||||
|
@ -1154,7 +1150,7 @@ class TestMethods(unittest.TestCase):
|
||||||
# need to know DOWNTEST and BONUS
|
# need to know DOWNTEST and BONUS
|
||||||
downtest = kaddr + b.getlabel('DOWNTEST')
|
downtest = kaddr + b.getlabel('DOWNTEST')
|
||||||
bonus = kaddr + b.getlabel('BONUS')
|
bonus = kaddr + b.getlabel('BONUS')
|
||||||
self.loadphysmem(p, b.instructions(), addr)
|
self.loadphysmem(p, b, addr)
|
||||||
|
|
||||||
with self.subTest(phase="UP"):
|
with self.subTest(phase="UP"):
|
||||||
# finally ready to run the whole shebang!
|
# finally ready to run the whole shebang!
|
||||||
|
@ -1284,7 +1280,7 @@ class TestMethods(unittest.TestCase):
|
||||||
k.label('_done')
|
k.label('_done')
|
||||||
k.halt()
|
k.halt()
|
||||||
|
|
||||||
self.loadphysmem(p, k.instructions(), base_address)
|
self.loadphysmem(p, k, base_address)
|
||||||
p.run(pc=base_address)
|
p.run(pc=base_address)
|
||||||
self.assertEqual(p.r[0], 0)
|
self.assertEqual(p.r[0], 0)
|
||||||
|
|
||||||
|
@ -1305,7 +1301,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.halt()
|
a.halt()
|
||||||
|
|
||||||
aa = 0o4000
|
aa = 0o4000
|
||||||
self.loadphysmem(p, a.instructions(), aa)
|
self.loadphysmem(p, a, aa)
|
||||||
p.run(pc=aa)
|
p.run(pc=aa)
|
||||||
self.assertEqual(p.r[0], 3) # confirm made it all the way through
|
self.assertEqual(p.r[0], 3) # confirm made it all the way through
|
||||||
|
|
||||||
|
@ -1340,7 +1336,7 @@ class TestMethods(unittest.TestCase):
|
||||||
tr.rtt()
|
tr.rtt()
|
||||||
|
|
||||||
tra = 0o6000
|
tra = 0o6000
|
||||||
self.loadphysmem(p, tr.instructions(), tra)
|
self.loadphysmem(p, tr, tra)
|
||||||
|
|
||||||
recordmagic = 0o66000
|
recordmagic = 0o66000
|
||||||
with ASM() as a:
|
with ASM() as a:
|
||||||
|
@ -1367,7 +1363,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.halt()
|
a.halt()
|
||||||
|
|
||||||
aa = 0o4000
|
aa = 0o4000
|
||||||
self.loadphysmem(p, a.instructions(), aa)
|
self.loadphysmem(p, a, aa)
|
||||||
p.r[p.PC] = aa
|
p.r[p.PC] = aa
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
@ -1489,7 +1485,7 @@ class TestMethods(unittest.TestCase):
|
||||||
k.rtt() # off to the races!
|
k.rtt() # off to the races!
|
||||||
|
|
||||||
kloc = 0o4000
|
kloc = 0o4000
|
||||||
for a2, w in enumerate(k.instructions()):
|
for a2, w in enumerate(k):
|
||||||
p.mmu.wordRW(kloc + (2 * a2), w)
|
p.mmu.wordRW(kloc + (2 * a2), w)
|
||||||
|
|
||||||
# The test timing loop... 49 "inst" instructions
|
# The test timing loop... 49 "inst" instructions
|
||||||
|
@ -1502,8 +1498,7 @@ class TestMethods(unittest.TestCase):
|
||||||
a.sob('r4', 'LOOP')
|
a.sob('r4', 'LOOP')
|
||||||
a.halt()
|
a.halt()
|
||||||
|
|
||||||
insts = a.instructions()
|
for a2, w in enumerate(a):
|
||||||
for a2, w in enumerate(insts):
|
|
||||||
p.physRW(user_physloc + (2 * a2), w)
|
p.physRW(user_physloc + (2 * a2), w)
|
||||||
|
|
||||||
return p, kloc
|
return p, kloc
|
||||||
|
|
Loading…
Add table
Reference in a new issue