using System; using System.Collections.Generic; using System.Text; using Sunweaver.Commands.Attributes; using Sunweaver.VM; namespace Sunweaver.Commands { [Punctuation("Stores the top value of the integer stack in to the given memory location.")] public class ExplicitStore : Commands.Label { public ExplicitStore(string name, Int16 number) : base(name, number) { } public override void Implementation(VirtualMachine VM) { if (VM.Stack.Count == 0) return; long a = VM.Stack.Pop(); if (!VM.BoolStack.Peek()) return; int loc = Math.Abs(this.number) % (Sunweaver.VM.Memory.MemorySlots + 1); VM.Memory[loc] = (short)(a % (Sunweaver.VM.Memory.MaxAbsoluteMemoryValue + 1)); } public override string ToString() { if (Name != string.Empty) return "." + Name; else return "." + number.ToString(); } } }