Skip to content

Commit 3089ecc

Browse files
CoderCatGGgithub-actions
andauthored
Add JUMPSTACK kRISC instruction (KSP-KOS#3148)
* Add OpcodeBranchJumpStack in opcode.cs * Fix Opcode.cs documentation & exception handling * Fix Opcode.cs exception I dont do C# let me back to rust * Fix Opcode.cs, for the last time (hopefully) Really, i dont do C# * bump version to 1.4.1.0 * Removed error handling of type conversion Wasn't needed. We don't check for distance == 0, as someone could purposefully push 0 to do a NOP * refix CHANGELOG.md * bump version to 1.4.0.1 * Fix CHANGELOG.md after release * Fix kOS.version after release * Fix CHANGELOG.md --------- Co-authored-by: github-actions <github-actions@github.com>
1 parent b76759f commit 3089ecc

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2911,4 +2911,4 @@ Bug fixes
29112911
- Terminal created
29122912
- KerboScript designed and implemented
29132913
- VAB Part created
2914-
- Flight stats and bindings created
2914+
- Flight stats and bindings created

src/kOS.Safe/Compilation/Opcode.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public enum ByteCode :byte
8787
ARGBOTTOM = 0x60,
8888
TESTARGBOTTOM = 0x61,
8989
TESTCANCELLED = 0x62,
90-
90+
JUMPSTACK = 0x63,
9191

9292
// Augmented bogus placeholder versions of the normal
9393
// opcodes: These only exist in the program temporarily
@@ -1102,6 +1102,27 @@ public override void Execute(ICpu cpu)
11021102
DeltaInstructionPointer = Distance;
11031103
}
11041104
}
1105+
1106+
/// <summary>
1107+
/// <para>
1108+
/// Pops a Int32 from the stack and then unconditionally
1109+
/// advances the instruction pointer by it
1110+
/// </para>
1111+
/// <para></para>
1112+
/// <para>... dist ...</para>
1113+
/// </summary>
1114+
public class OpcodeJumpStack : Opcode
1115+
{
1116+
protected override string Name { get { return "jumpstack"; } }
1117+
public override ByteCode Code { get { return ByteCode.JUMPSTACK; } }
1118+
1119+
public override void Execute(ICpu cpu)
1120+
{
1121+
object popval = cpu.PopValueArgument();
1122+
int distance = Convert.ToInt32(popval);
1123+
DeltaInstructionPointer = distance;
1124+
}
1125+
}
11051126

11061127
/// <summary>
11071128
/// Most Opcode.Label fields are just string-ified numbers for their index

0 commit comments

Comments
 (0)