From 872ad7833d0ea2a3962445e5799679f70fa07ffd Mon Sep 17 00:00:00 2001 From: Neil Webber Date: Tue, 23 Apr 2024 07:39:18 -0500 Subject: [PATCH] Make sure no illegal values outside 16 bit range loaded via loadphysmem --- pdptests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pdptests.py b/pdptests.py index a31e1e5..4f7741d 100644 --- a/pdptests.py +++ b/pdptests.py @@ -57,6 +57,9 @@ class TestMethods(unittest.TestCase): @staticmethod def loadphysmem(p, words, addr): for a, w in enumerate(words, start=(addr >> 1)): + # make sure no bogus values get into memory + if w < 0 or w > 65535: + raise ValueError(f"Illegal value {w} in loadphysmem") p.physmem[a] = w # some of these can't be computed at class definition time, so... @@ -198,13 +201,13 @@ class TestMethods(unittest.TestCase): a.mov('r0', 'sp') a.halt() a.literal(0o111111) - a.literal(0o777777) + a.literal(0o177777) a.label('stack') p = self.make_pdp() self.loadphysmem(p, a, 0o10000) p.run(pc=0o10000) - self.assertEqual(p.mmu.wordRW(p.r[6] - 2), 0o777777) + self.assertEqual(p.mmu.wordRW(p.r[6] - 2), 0o177777) self.assertEqual(p.mmu.wordRW(p.r[6] - 4), 0o111111) # these tests end up testing other stuff too of course, including MMU