1.1 --- a/rsvp.py Sun May 18 19:59:26 2008 +0200
1.2 +++ b/rsvp.py Sun May 18 20:50:05 2008 +0200
1.3 @@ -151,23 +151,29 @@
1.4 except IndexError:
1.5 raise EmptyMetadataStack
1.6
1.7 - def execute(self):
1.8 + def run(self):
1.9
1.10 "Execute code in the memory, starting from the current PC address."
1.11
1.12 try:
1.13 while 1:
1.14 - instruction = self.load(self.pc)
1.15 - if self.debug:
1.16 - print "%8d %s" % (self.pc, instruction)
1.17 - method = getattr(self, instruction, None)
1.18 - if method is None:
1.19 - raise IllegalInstruction, self.pc
1.20 - else:
1.21 - method()
1.22 + self.execute()
1.23 except EmptyPCStack:
1.24 pass
1.25
1.26 + def execute(self):
1.27 +
1.28 + "Execute code at the current PC address."
1.29 +
1.30 + instruction = self.load(self.pc)
1.31 + if self.debug:
1.32 + print "%8d %s" % (self.pc, instruction)
1.33 + method = getattr(self, instruction, None)
1.34 + if method is None:
1.35 + raise IllegalInstruction, self.pc
1.36 + else:
1.37 + method()
1.38 +
1.39 def jump(self, addr, next):
1.40
1.41 """
1.42 @@ -277,31 +283,28 @@
1.43 def LoadAddress(self):
1.44
1.45 """
1.46 - LoadAddress addr, #n
1.47 - Load from position n in reference at addr: get the contents of position
1.48 - n in the memory referenced by addr, adding the retrieved value to the
1.49 - top of the stack.
1.50 + LoadAddress addr
1.51 + Load from addr: get the contents of the location in memory referenced by
1.52 + addr, adding the retrieved value to the top of the stack.
1.53 """
1.54
1.55 - red = self.load(self.pc + 1)
1.56 - n = self.load(self.pc + 2)
1.57 - self.push(self.load(ref + n))
1.58 - self.pc += 3
1.59 + ref = self.load(self.pc + 1)
1.60 + self.push(self.load(ref))
1.61 + self.pc += 2
1.62
1.63 def StoreAddress(self):
1.64
1.65 """
1.66 - StoreAddress addr, #n
1.67 - Save to position n in reference at addr: pull a value from the stack and
1.68 - save it to position n in the memory referenced by addr, also removing
1.69 - the value on the top of the stack.
1.70 + StoreAddress addr
1.71 + Save to addr: pull a value from the stack and save it to the location in
1.72 + memory referenced by addr, also removing the value on the top of the
1.73 + stack.
1.74 """
1.75
1.76 ref = self.load(self.pc + 1)
1.77 - n = self.load(self.pc + 2)
1.78 value = self.pull()
1.79 - self.save(ref + n, value)
1.80 - self.pc += 3
1.81 + self.save(ref, value)
1.82 + self.pc += 2
1.83
1.84 def Return(self):
1.85