Commits

David Boddie  committed 2d10bd2 Draft

Ensured that the CLR instruction treats the Rd register in a way
that is compatible and interoperable with the EOR instruction.

  • Participants
  • Parent commits f89c744

Comments (0)

Files changed (1)

File ATmega/instructions.py

     opcode = OpcodeTemplate("001001dddddddddd")
     flags = ("S", "V", "N", "Z")
     syntax = Syntax("Rd")
+    
+    def argument_for_field(self, name):
+    
+        if name == "d":
+            # Since this instruction is equivalent to EOR Rd,Rd the field must
+            # contain a register number that can be broken up into two equal
+            # register numbers in the same format as the opcode for EOR.
+            eor = EOR(opcode = 0x2400 | self.values["d"])
+            
+            if eor.values["r"] != eor.values["d"]:
+                raise ParseError, "Mismatched registers in opcode %s: %x, %x" % (self.text, self.values["d"], self.values["r"])
+            
+            # Return the value from the corresponding EOR instruction.
+            return Register(eor.values["d"])
+        else:
+            return self.values[name]
 
 Lookup.add(CLR.opcode, CLR)