eliminated ASM with
This commit is contained in:
parent
1259e2ef80
commit
6f8bc554bb
1 changed files with 716 additions and 725 deletions
97
pdptests.py
97
pdptests.py
|
@ -31,7 +31,7 @@ import random
|
|||
import os
|
||||
import hashlib
|
||||
|
||||
from pdpasmhelper import PDP11InstructionAssembler as ASM
|
||||
from pdpasmhelper import InstructionBlock
|
||||
|
||||
|
||||
class TestMethods(unittest.TestCase):
|
||||
|
@ -126,7 +126,7 @@ class TestMethods(unittest.TestCase):
|
|||
# These instructions will be placed at 2K in memory
|
||||
#
|
||||
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.mov(0o20000, 'sp') # start system stack at 8k
|
||||
|
||||
# write the constants as described above
|
||||
|
@ -190,7 +190,7 @@ class TestMethods(unittest.TestCase):
|
|||
|
||||
for result, r1tval in ((0o33333, 2), (0o22222, 0)):
|
||||
# r1=r1tval, mfpi (r1) -> r0; expect r0 = result
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.mov(r1tval, 'r1')
|
||||
a.mfpi('(r1)')
|
||||
a.mov('(sp)+', 'r0')
|
||||
|
@ -205,29 +205,28 @@ class TestMethods(unittest.TestCase):
|
|||
def test_mfpxsp(self):
|
||||
cn = self.usefulconstants()
|
||||
|
||||
with ASM() as u:
|
||||
u = InstructionBlock()
|
||||
u.mov('r2', 'r6')
|
||||
u.trap(0)
|
||||
|
||||
with ASM() as premmu:
|
||||
ts = premmu # just for brevity...
|
||||
ts.mov(0o14000, ts.ptr(0o34)) # set vector 034 to 14000
|
||||
ts.clr(ts.ptr(0o36)) # PSW for trap - zero work
|
||||
ts.mov(0o20000, 'r0') # mov #20000,r0
|
||||
premmu = InstructionBlock()
|
||||
premmu.mov(0o14000, premmu.ptr(0o34)) # set vector 034 to 14000
|
||||
premmu.clr(premmu.ptr(0o36)) # PSW for trap - zero work
|
||||
premmu.mov(0o20000, 'r0')
|
||||
|
||||
for uinst in u:
|
||||
ts.mov(uinst, '(r0)+')
|
||||
ts.mov(0o123456, 'r2') # mov #123456,r2
|
||||
ts.mov(0o140340, '-(sp)') # push user-ish PSW to K stack
|
||||
ts.clr('-(sp)') # new user PC = 0
|
||||
premmu.mov(uinst, '(r0)+')
|
||||
premmu.mov(0o123456, 'r2')
|
||||
premmu.mov(0o140340, '-(sp)') # push user-ish PSW to K stack
|
||||
premmu.clr('-(sp)') # new user PC = 0
|
||||
|
||||
with ASM() as postmmu:
|
||||
postmmu.literal(6) # RTT - goes to user mode, addr 0
|
||||
postmmu = InstructionBlock()
|
||||
postmmu.rtt() # RTT - goes to user mode, addr 0
|
||||
|
||||
p, pc = self.simplemapped_pdp(premmu=premmu, postmmu=postmmu)
|
||||
|
||||
# put the trap handler at 14000 as expected
|
||||
with ASM() as th:
|
||||
th = InstructionBlock()
|
||||
th.mfpd('sp')
|
||||
th.mov('(sp)+', 'r3')
|
||||
th.halt()
|
||||
|
@ -238,7 +237,7 @@ class TestMethods(unittest.TestCase):
|
|||
def test_mtpi(self):
|
||||
cn = self.usefulconstants()
|
||||
|
||||
with ASM() as ts:
|
||||
ts = InstructionBlock()
|
||||
ts.mov(0o1717, '-(sp)') # pushing 0o1717
|
||||
ts.mtpi(ts.ptr(0o02)) # and MTPI it to user location 2
|
||||
ts.clr(ts.ptr(cn.MMR0)) # turn MMU back off
|
||||
|
@ -270,7 +269,7 @@ class TestMethods(unittest.TestCase):
|
|||
sub_loc = testloc + 4
|
||||
|
||||
for addsub, loc in (('add', add_loc), ('sub', sub_loc)):
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
getattr(a, addsub)('r0', 'r1')
|
||||
a.halt()
|
||||
self.loadphysmem(p, a, loc)
|
||||
|
@ -297,14 +296,7 @@ class TestMethods(unittest.TestCase):
|
|||
p = self.make_pdp()
|
||||
loopcount = 0o1000
|
||||
|
||||
with ASM() as a:
|
||||
# Program is:
|
||||
# MOV loopcount,R1
|
||||
# CLR R0
|
||||
# LOOP: INC R0
|
||||
# DEC R1
|
||||
# BNE LOOP
|
||||
# HALT
|
||||
a = InstructionBlock()
|
||||
a.mov(loopcount, 'r1')
|
||||
a.clr('r0')
|
||||
a.label('LOOP')
|
||||
|
@ -325,7 +317,7 @@ class TestMethods(unittest.TestCase):
|
|||
p = self.make_pdp()
|
||||
|
||||
goodval = 0o4321 # arbitrary, not zero
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.clr('r1') # if successful r1 will become goodval
|
||||
a.clr('r0')
|
||||
a.beq('good')
|
||||
|
@ -345,7 +337,7 @@ class TestMethods(unittest.TestCase):
|
|||
|
||||
# create the instruction sequence shared by test_cc and test_ucc
|
||||
def _cc_unscc(self, br1, br2):
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
# program is:
|
||||
# CLR R0
|
||||
# MOV @#05000,R1 ; see discussion below
|
||||
|
@ -453,7 +445,7 @@ class TestMethods(unittest.TestCase):
|
|||
def test_ash1(self):
|
||||
# this code sequence taken from Unix startup, it's not really
|
||||
# much of a test.
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.mov(0o0122451, 'r2')
|
||||
neg6 = -6 & 0xFFFF
|
||||
a.ash(neg6, 'r2')
|
||||
|
@ -542,13 +534,13 @@ class TestMethods(unittest.TestCase):
|
|||
|
||||
p = self.make_pdp()
|
||||
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
# The test cases will be X / Y:
|
||||
# X : 1, 255, 4096, 10017, 32767, 32768, 32769
|
||||
# and then those same values with 690000 added to them
|
||||
# Y : -50 .. 50 but skipping 0 and using a large number
|
||||
#
|
||||
# The code is written this way so that the resulting ASM()
|
||||
# The code is written this way so that the resulting block
|
||||
# is completely self-contained (does not rely on python to
|
||||
# drive it). This made it easier to cross-verify w/SIMH
|
||||
|
||||
|
@ -757,7 +749,7 @@ class TestMethods(unittest.TestCase):
|
|||
p.physmem[15] = 0
|
||||
|
||||
# this trap handler puts the trap # into R3
|
||||
with ASM() as handler:
|
||||
handler = InstructionBlock()
|
||||
# the saved PC is at the top of the stack ... get it
|
||||
handler.mov('(sp)', 'r0')
|
||||
# get the low byte of the instruction which is the trap code
|
||||
|
@ -771,7 +763,7 @@ class TestMethods(unittest.TestCase):
|
|||
p.r[6] = 0o20000 # 8K and working down
|
||||
|
||||
for i in range(256):
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.trap(i) # TRAP #i
|
||||
a.mov('r3', 'r1') # MOV R3,R1 just to show RTT worked
|
||||
a.halt()
|
||||
|
@ -864,7 +856,7 @@ class TestMethods(unittest.TestCase):
|
|||
# Nevertheless, here it is.
|
||||
|
||||
# this code will go at taddr
|
||||
with ASM() as tr:
|
||||
tr = InstructionBlock()
|
||||
# The trap handler for MMU faults and the trap 0 / trap 1 from
|
||||
# the user code (when there is no MMU fault). It is integrated
|
||||
# into one routine.
|
||||
|
@ -942,7 +934,7 @@ class TestMethods(unittest.TestCase):
|
|||
# user-mode code executed before the test begins to put
|
||||
# the test pattern into memory
|
||||
|
||||
with ASM() as u:
|
||||
u = InstructionBlock()
|
||||
# this subtract combines the access check with part1 of chksum
|
||||
u.mov(0o123456, 'r1')
|
||||
u.sub('(r0)', 'r1')
|
||||
|
@ -986,7 +978,7 @@ class TestMethods(unittest.TestCase):
|
|||
#
|
||||
# The stack will start at kstackstart
|
||||
|
||||
with ASM() as k:
|
||||
k = InstructionBlock()
|
||||
k.mov(kernel_stack, 'sp')
|
||||
|
||||
# KERNEL I SPACE
|
||||
|
@ -1306,7 +1298,7 @@ class TestMethods(unittest.TestCase):
|
|||
|
||||
base_address = 0o10000
|
||||
|
||||
with ASM() as k:
|
||||
k = InstructionBlock()
|
||||
# this is silly but easy, just put the trap handler here and
|
||||
# jump over it
|
||||
k.br('L1')
|
||||
|
@ -1416,7 +1408,7 @@ class TestMethods(unittest.TestCase):
|
|||
def test_stacklim0(self):
|
||||
# verify that simply *having* an illegal SP doesn't trap
|
||||
p = self.make_pdp()
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.clr('r0') # will be used to verify progress
|
||||
|
||||
# none of these bad stack pointers should cause
|
||||
|
@ -1445,7 +1437,7 @@ class TestMethods(unittest.TestCase):
|
|||
|
||||
p = self.make_pdp()
|
||||
|
||||
with ASM() as tr:
|
||||
tr = InstructionBlock()
|
||||
# record...
|
||||
tr.mov('r2', '(r5)+') # ...separator/entry number
|
||||
tr.mov('sp', '(r5)+') # ...the sp
|
||||
|
@ -1468,7 +1460,7 @@ class TestMethods(unittest.TestCase):
|
|||
self.loadphysmem(p, tr, tra)
|
||||
|
||||
recordmagic = 0o66000
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.mov(0o400, 'sp')
|
||||
a.mov(0o7000, 'r5')
|
||||
a.mov(recordmagic, 'r2')
|
||||
|
@ -1566,7 +1558,7 @@ class TestMethods(unittest.TestCase):
|
|||
p = self.make_pdp()
|
||||
|
||||
maxtest = 100
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
for i in range(maxtest):
|
||||
a.mov(i, 'r0')
|
||||
a.clr('r0')
|
||||
|
@ -1586,12 +1578,11 @@ class TestMethods(unittest.TestCase):
|
|||
p = self.make_pdp()
|
||||
|
||||
maxtest = 100
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
for i in range(maxtest):
|
||||
a.mov(i, 'r0')
|
||||
a.label(f"L{i}")
|
||||
a.clr('r0')
|
||||
a.halt()
|
||||
|
||||
startaddr = 0o4000
|
||||
self.loadphysmem(p, a, startaddr)
|
||||
|
@ -1606,7 +1597,7 @@ class TestMethods(unittest.TestCase):
|
|||
p = self.make_pdp()
|
||||
|
||||
maxtest = 100
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
for i in range(maxtest):
|
||||
a.mov(i+1, 'r0')
|
||||
a.clr('r0')
|
||||
|
@ -1670,7 +1661,7 @@ class TestMethods(unittest.TestCase):
|
|||
p = PDP1170(logger=fnamebase, loglevel='DEBUG')
|
||||
# the point of this program is just to create N log
|
||||
# entries (when executed) that can be verified
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.mov('r0', 'r0')
|
||||
a.mov('r0', 'r1')
|
||||
a.mov('r0', 'r2')
|
||||
|
@ -1714,7 +1705,7 @@ class TestMethods(unittest.TestCase):
|
|||
startaddr = 0o4000
|
||||
|
||||
while curguess < maxguess:
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
for i in range(curguess):
|
||||
a.mov(i, 'r0')
|
||||
a.halt()
|
||||
|
@ -1730,7 +1721,7 @@ class TestMethods(unittest.TestCase):
|
|||
curguess += 1
|
||||
|
||||
maxtest = default_lookbacks + 1
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
for i in range(maxtest):
|
||||
a.mov(i, 'r0')
|
||||
a.clr('r0')
|
||||
|
@ -1750,10 +1741,10 @@ class TestMethods(unittest.TestCase):
|
|||
self.assertEqual(len(bp7.states), min(i+1, 7))
|
||||
|
||||
def test_jmp(self):
|
||||
"""In many ways more of a test of ASM module labels..."""
|
||||
"""In many ways more of a test of InstructionBlock labels..."""
|
||||
p = self.make_pdp()
|
||||
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.clr('r0')
|
||||
a.clr('r1')
|
||||
a.clr('r2')
|
||||
|
@ -1799,8 +1790,8 @@ class TestMethods(unittest.TestCase):
|
|||
are called 'co-routines.'
|
||||
"""
|
||||
p = self.make_pdp()
|
||||
with ASM() as a:
|
||||
pass
|
||||
a = InstructionBlock()
|
||||
# XXX TBD XXX
|
||||
|
||||
def test_ubmap(self):
|
||||
p = self.make_pdp()
|
||||
|
@ -1849,7 +1840,7 @@ class TestMethods(unittest.TestCase):
|
|||
# this is the tiny kernel code used to set up and start
|
||||
# each iteration of the user mode timing code. It slightly
|
||||
# distorts the per-instruction overhead of course. C'est la vie.
|
||||
with ASM() as k:
|
||||
k = InstructionBlock()
|
||||
k.mov(0o20000, 'sp') # establish proper kernel stack
|
||||
k.mov(0o140340, '-(sp)') # USER mode, no interrupts
|
||||
k.mov(usermode_base, '-(sp)') # pc start for loop/USER code
|
||||
|
@ -1861,7 +1852,7 @@ class TestMethods(unittest.TestCase):
|
|||
|
||||
# The test timing loop... 49 "inst" instructions
|
||||
# and an SOB for looping (so 50 overall instructions per loop)
|
||||
with ASM() as a:
|
||||
a = InstructionBlock()
|
||||
a.mov(loopcount, 'r4')
|
||||
a.label('LOOP')
|
||||
for i in range(49):
|
||||
|
|
Loading…
Add table
Reference in a new issue