safeguard literal from allowing bad values into physmem

This commit is contained in:
Neil Webber 2024-04-23 08:00:33 -05:00
parent 7a9fff6f8b
commit 8259c035e0

View file

@ -299,6 +299,9 @@ class PDP11InstructionAssembler:
def literal(self, inst, oprnd=None, /): def literal(self, inst, oprnd=None, /):
"""For hand-assembled instructions. Also allows 1 operand.""" """For hand-assembled instructions. Also allows 1 operand."""
# prevent bad values from leaking into physical memory this way
if inst < 0 or inst > 65535:
raise ValueError(f"Bad instruction literal: {inst}")
return self._1op(inst, oprnd) return self._1op(inst, oprnd)