fix backwards raw label references
This commit is contained in:
parent
bfd40bafa1
commit
1f196e1923
1 changed files with 14 additions and 1 deletions
|
@ -402,6 +402,7 @@ class InstructionBlock(PDP11InstructionAssembler):
|
||||||
# Extend base operand_parser with ability to handle labels,
|
# Extend base operand_parser with ability to handle labels,
|
||||||
# including forward references
|
# including forward references
|
||||||
def operand_parser(self, operand_token, *args, **kwargs):
|
def operand_parser(self, operand_token, *args, **kwargs):
|
||||||
|
|
||||||
# it's possible to get here with operand_token already
|
# it's possible to get here with operand_token already
|
||||||
# being a forward ref (e.g., if getlabel was used)
|
# being a forward ref (e.g., if getlabel was used)
|
||||||
if isinstance(operand_token, FwdRef):
|
if isinstance(operand_token, FwdRef):
|
||||||
|
@ -414,7 +415,7 @@ class InstructionBlock(PDP11InstructionAssembler):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# falling through to here means it is a label or forward reference
|
# falling through to here means it is a label or forward reference
|
||||||
return self.getlabel(operand_token)
|
return [0o27, self.getlabel(operand_token)]
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
"""Returns the length of the sequence in WORDS"""
|
"""Returns the length of the sequence in WORDS"""
|
||||||
|
@ -438,6 +439,8 @@ class InstructionBlock(PDP11InstructionAssembler):
|
||||||
def _allowable_label(self, s):
|
def _allowable_label(self, s):
|
||||||
if not hasattr(s, 'isalpha'):
|
if not hasattr(s, 'isalpha'):
|
||||||
return False
|
return False
|
||||||
|
if s[0] == '+':
|
||||||
|
s = s[1:]
|
||||||
return ((s.upper() not in self.B6MODES) and
|
return ((s.upper() not in self.B6MODES) and
|
||||||
(s[0].isalpha() or s[0] == '_'))
|
(s[0].isalpha() or s[0] == '_'))
|
||||||
|
|
||||||
|
@ -658,6 +661,16 @@ if __name__ == "__main__":
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
a.bne('foo')
|
a.bne('foo')
|
||||||
|
|
||||||
|
def test_backlab(self):
|
||||||
|
a = InstructionBlock()
|
||||||
|
a.mov('bozo', 'r0')
|
||||||
|
a.clr('r1')
|
||||||
|
a.label('bozo')
|
||||||
|
a.mov('bozo', 'r1')
|
||||||
|
|
||||||
|
insts = list(a)
|
||||||
|
self.assertEqual(list(a), [0o012700, 6, 0o005001, 0o012701, 6])
|
||||||
|
|
||||||
def test_labelmath_dot(self):
|
def test_labelmath_dot(self):
|
||||||
a = InstructionBlock()
|
a = InstructionBlock()
|
||||||
a.mov('bozo', 'r0')
|
a.mov('bozo', 'r0')
|
||||||
|
|
Loading…
Add table
Reference in a new issue