From d48fb25678e10c79bf8971892b8573fb7cb9e247 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 2 Dec 2011 20:28:29 +0000 Subject: Use DW instead of DS, add ASM source, fix some coding errors --- AsmLine.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'AsmLine.py') diff --git a/AsmLine.py b/AsmLine.py index 4561b30..5a5249f 100644 --- a/AsmLine.py +++ b/AsmLine.py @@ -47,25 +47,25 @@ class AsmLine(object): line = label + ":" + line parts = self.re_whitespace.split(line, 1) - instruction = parts[0] + self.instruction = parts[0] - if instruction in Asm.operators_binary: + if self.instruction in Asm.operators_binary: # a label for sure reg, operand = self.re_whitespace.split(parts[1], 1) self.register = reg self.setOperand(operand) - elif instruction in Asm.operators_branch: + elif self.instruction in Asm.operators_branch: # skip validation of reg for speed self.register = parts[1] - elif instruction in Asm.operators_unary: + elif self.instruction in Asm.operators_unary: self.setOperand(parts[1]) - elif instruction in Asm.operators_misc_reg: + elif self.instruction in Asm.operators_misc_reg: self.register = parts[1] - elif instruction in Asm.operators_misc_noreg: + elif self.instruction in Asm.operators_misc_noreg: # no args pass else: - raise RuntimeError("Unknown instruction '{}'".format(instruction)) + raise RuntimeError("Unknown instruction '{}'".format(self.instruction)) def setOperand(self, str): """Sets the operand for this object either as a string or an identifier object @@ -112,3 +112,4 @@ class AsmLine(object): if self.operand: # join all operand parts together line += " " + "".join(str(elm) for elm in self.operand) + return line -- cgit v1.2.1