Ad
  • Custom User Avatar

    What I did is move the task of increasing the IP out of each instruction. Then in what would be your "process" method, I would wrap that self.instructionParser... inside an if, like this:
    if (!self.instructionParser...) : self.IP += 1
    And only the jnz instruction returns true (I called this "Hold IP"). Also, in the jnz method I think you're supposed to handle both constants (ints) and registers, so I defined another method valueOf(x) that returns x if it is a number, or the value of your self.regis[x], if it is alpha (isNaN, actually).
    I did not process (split) the instructions array in advance, although I think that's more up to personal likes :)