git @ Cat's Eye Technologies ZOWIE / a6f4e16
Use new-style classes. Chris Pressey 7 years ago
1 changed file(s) with 5 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
3939 return e
4040
4141
42 class MappedRegister: # abstract
42 class MappedRegister(object): # abstract
4343 def read(self):
4444 raise NotImplementedError
4545
155155 self.state[8] = 0
156156
157157
158 class MachineState:
158 class MachineState(object):
159159 def __init__(self, cpu):
160160 self.cpu = cpu
161161 self.pc = 0
189189 self.storage_register[key] = value
190190
191191
192 class Instruction:
192 class Instruction(object):
193193 def __init__(self):
194194 self.source_register = 0
195195 self.destination_register = 0
202202 if not line or line[0] == ';':
203203 return False
204204
205 if len(line) < 3 or line[0:3] != 'MOV':
205 if len(line) < 3 or not line.startswith('MOV'):
206206 raise SyntaxError("Could not parse line '%s'" % line)
207207
208208 line = line[3:].strip()
266266 src_fmt % self.source_register)
267267
268268
269 class Processor:
269 class Processor(object):
270270 def __init__(self):
271271 self.program = []
272272 self.state = MachineState(self)