diff --git a/CHANGELOG.md b/CHANGELOG.md index e25c5355d..4b9450d35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2911,4 +2911,4 @@ Bug fixes - Terminal created - KerboScript designed and implemented - VAB Part created -- Flight stats and bindings created \ No newline at end of file +- Flight stats and bindings created diff --git a/src/kOS.Safe/Compilation/Opcode.cs b/src/kOS.Safe/Compilation/Opcode.cs index f33ff14d2..d7a65a8d1 100644 --- a/src/kOS.Safe/Compilation/Opcode.cs +++ b/src/kOS.Safe/Compilation/Opcode.cs @@ -87,7 +87,7 @@ public enum ByteCode :byte ARGBOTTOM = 0x60, TESTARGBOTTOM = 0x61, TESTCANCELLED = 0x62, - + JUMPSTACK = 0x63, // Augmented bogus placeholder versions of the normal // opcodes: These only exist in the program temporarily @@ -1102,6 +1102,27 @@ public override void Execute(ICpu cpu) DeltaInstructionPointer = Distance; } } + + /// + /// + /// Pops a Int32 from the stack and then unconditionally + /// advances the instruction pointer by it + /// + /// + /// ... dist ... + /// + public class OpcodeJumpStack : Opcode + { + protected override string Name { get { return "jumpstack"; } } + public override ByteCode Code { get { return ByteCode.JUMPSTACK; } } + + public override void Execute(ICpu cpu) + { + object popval = cpu.PopValueArgument(); + int distance = Convert.ToInt32(popval); + DeltaInstructionPointer = distance; + } + } /// /// Most Opcode.Label fields are just string-ified numbers for their index