Esempio n. 1
0
        private void ProcessPrologueInstructions()
        {
            uint sp = iEngine.CPU[TArmRegisterType.EArmReg_SP];

            iEngine.Trace("[PLG] ProcessPrologueInstructions - initial PC: 0x{0:x8}, SP: 0x{1:x8}", iPC.Value, sp);

            // We've got the necessary instructions so continue as normal...
            int actual = iInstructions.Count;

            while (actual > 0)
            {
                // Get instruction
                AccInstruction inst = iInstructions.Deque();

                // Don't process any ignored instructions
                if (inst.Ignored == false)
                {
                    iEngine.Trace("[PLG] ProcessPrologueInstructions - PC: 0x{0:x8}, SP: 0x{1:x8}, I: {2}", iPC.Value, sp + (iNumberOfWordsPushedOnStack * 4), inst.ToString());
                    iEngine.SetIndent(1);

                    // Process it to update offsets & register values
                    inst.Process(this);

                    // Update Prologue program counter value
                    iPC.Value += SingleInstructionSize;

                    // Finished with indentation
                    iEngine.SetIndent(0);
                }

                // Update count
                actual = iInstructions.Count;
            }
        }
Esempio n. 2
0
        public void AccTest()
        {
            State initialState = new State();

            Instruction accInstruction = new AccInstruction(1);
            var         newState       = accInstruction.Execute(initialState);

            newState.Acc.Should().Be(1);
            newState.Pc.Should().Be(1);
        }
Esempio n. 3
0
        internal override void Prefilter(AccInstructionList aInstructions, int aMyIndex, int aInstructionCountOffsetToPC)
        {
            if (this.Ignored == false)
            {
                int count = aInstructions.Count;
                //
                if (base.Instruction.AIConditionCode == TArmInstructionCondition.AL)
                {
                    // As soon as we see any unconditional branch statement we can be sure that we are past the Prologue.
                    for (int i = aMyIndex + 1; i < count; i++)
                    {
                        aInstructions[i].Ignored = true;
                    }
                }
                else
                {
                    // Count the number of interesting instructions before the conditional branch
                    int interestingInstructionCount = 0;
                    for (int i = 0; i < aMyIndex; i++)
                    {
                        AccInstruction  accInstruction = aInstructions[i];
                        IArmInstruction inst           = accInstruction.Instruction;
                        //
                        bool involvesSP = inst.QueryInvolvement(TArmRegisterType.EArmReg_SP);
                        if (involvesSP)
                        {
                            ++interestingInstructionCount;
                        }
                    }

                    // If we have seen at least one interesting instruction then assume prologue is complete.
                    if (interestingInstructionCount >= 1)
                    {
                        for (int i = aMyIndex; i < count; i++)
                        {
                            aInstructions[i].Ignored = true;
                        }
                    }
                }
            }
        }