Part 1: Create a simple virtual machine with two registers (a
and b
, non-negative integers) and six instructions:
hlf (a|b)
- divide the given register by half, round downtpl (a|b)
- triple the given registerinc (a|b)
- add 1 to the given registerjmp [+-]\d+
- jump forward/backwards by the given number of instructionsjie (a|b), [+-]\d+
- if the given register is even, jumpjio (a|b), [+-]\d+
- if the given register equals one, jump