more use of asm with

This commit is contained in:
Neil Webber 2023-09-11 17:45:59 -06:00
parent 475f2e4591
commit 4b9bdf77d0

View file

@ -241,12 +241,14 @@ class TestMethods(unittest.TestCase):
def test_mtpi(self): def test_mtpi(self):
cn = self.usefulconstants() cn = self.usefulconstants()
tvecs = ( with ASM.newsequence() as ts:
(0o1717, (0o012746, 0o1717, 0o006637, 0o02, ts.mov(0o1717, '-(sp)') # pushing 0o1717
# turn MMU back off (!) ts.mtpi(ts.ptr(0o02)) # and MTPI it to user location 2
0o005037, cn.MMR0, ts.clr(ts.ptr(cn.MMR0)) # turn MMU back off
0o013700, 0o20002)), ts.mov(ts.ptr(0o20002), 'r0') # r0 = (020002)
)
tvecs = ((0o1717, ts.sequence()),)
for r0result, insts in tvecs: for r0result, insts in tvecs:
with self.subTest(r0result=r0result, insts=insts): with self.subTest(r0result=r0result, insts=insts):
p, pc = self.simplemapped_pdp(postmmu=insts) p, pc = self.simplemapped_pdp(postmmu=insts)
@ -317,7 +319,8 @@ class TestMethods(unittest.TestCase):
def test_cc(self): def test_cc(self):
# various condition code tests # various condition code tests
p = self.make_pdp() p = self.make_pdp()
insts = (
with ASM.newsequence() as ts:
# program is: # program is:
# CLR R0 # CLR R0
# BEQ 1f # BEQ 1f
@ -344,19 +347,30 @@ class TestMethods(unittest.TestCase):
# #
# Given that, after running the program R0 should be 65553 # Given that, after running the program R0 should be 65553
0o005000, 0o101401, 0o0, 0o000257, 0o001001, 0, 0o005300, ts.clr('r0')
ts.literal(0o101401) # BEQ 1f
ts.halt()
ts.literal(0o000257) # 1f: CCC
ts.literal(0o001001) # BNE 1f
ts.halt()
ts.dec('r0')
# MOV @#5000 etc ts.mov(ts.ptr(0o5000), 'r1')
0o013701, 0o5000, 0o013702, 0o5002, ts.mov(ts.ptr(0o5002), 'r2')
# CMP R1,R2 BLE # CMP R1,R2 BLE
0o020102, 0o003401, 0, 0o005300, ts.cmp('r1', 'r2')
ts.literal(0o003401) # BLE 1f
ts.halt()
ts.dec('r0')
# CMP R2,R1 BGT ts.cmp('r2', 'r1')
0o020201, 0o003001, 0, 0o005300, ts.literal(0o003001) # BGT 1f
ts.halt()
0) ts.dec('r0')
ts.halt()
insts = ts.sequence()
instloc = 0o4000 instloc = 0o4000
self.loadphysmem(p, insts, instloc) self.loadphysmem(p, insts, instloc)