예제 #1
0
파일: NPUSHB.cs 프로젝트: Vengarioth/XUI
        public void StreamTooShort()
        {
            var streamData = new byte[] { 0x2 };
            var stream = new InstructionStream(streamData);
            var stack = new InstructionStack();
            var flags = 0;

            Instructions.NPUSHB(flags, stream, stack);
        }
예제 #2
0
        public void PushPopInt32()
        {
            var stack = new InstructionStack();

            byte value = 0x3;

            stack.PushAsInt32(value);

            Assert.AreEqual(value, stack.PopInt32());
        }
예제 #3
0
        public void Interpret(byte[] instructions)
        {
            EnsureInstructionsLoaded();

            var stack = new InstructionStack();
            var stream = new InstructionStream(instructions);

            while (stream.Position < stream.Length)
            {
                var opCode = (int)stream.ReadByte();
                instructionMap[opCode].Execute(opCode, stream, stack);
            }
        }
예제 #4
0
파일: NPUSHB.cs 프로젝트: Vengarioth/XUI
        public void PushOntoStack()
        {
            var streamData = new byte[] { 0x0b, 0x07, 0x01, 0x03, 0x04, 0x00, 0x03, 0x05, 0x05, 0x09, 0x04, 0x00 };
            var stream = new InstructionStream(streamData);
            var stack = new InstructionStack();
            var flags = 0;

            Instructions.NPUSHB(flags, stream, stack);

            Assert.AreEqual(0x00, stack.PopInt32());
            Assert.AreEqual(0x04, stack.PopInt32());
            Assert.AreEqual(0x09, stack.PopInt32());
            Assert.AreEqual(0x05, stack.PopInt32());
            Assert.AreEqual(0x05, stack.PopInt32());
            Assert.AreEqual(0x03, stack.PopInt32());
            Assert.AreEqual(0x00, stack.PopInt32());
            Assert.AreEqual(0x04, stack.PopInt32());
            Assert.AreEqual(0x03, stack.PopInt32());
            Assert.AreEqual(0x01, stack.PopInt32());
            Assert.AreEqual(0x07, stack.PopInt32());
        }