Exemplo n.º 1
0
        public bool PrepareCall(string mnemonic, IFullWord rAValue, IFullWord paramValue)
        {
            Memory[mAccAddress.Value].LongValue = rAValue.LongValue;
            Registers.RA.LongValue = paramValue.LongValue;

            return(PrepareCall(mnemonic));
        }
Exemplo n.º 2
0
        public static IFullWord[] ReadWords(Stream stream, int wordCount)
        {
            var readBytes = ReadBytes(stream, wordCount);

            IFullWord[] readWords = new IFullWord[wordCount];
            IFullWord   currentWord;
            int         byteIndex = 0;

            for (int i = 0; i < wordCount; i++)
            {
                currentWord = new FullWord
                {
                    Sign = readBytes[byteIndex++].ToSign()
                };

                for (int j = 0; j < FullWord.ByteCount; j++)
                {
                    currentWord[j] = readBytes[byteIndex++];
                }

                readWords[i] = currentWord;
            }

            return(readWords);
        }
Exemplo n.º 3
0
        public int CompareTo(IFullWord toCompare)
        {
            var field = LoadFromFullWord(mFieldSpec, toCompare);

            long wordValue  = LongValue;
            long fieldValue = field.LongValue;

            return(wordValue.CompareTo(fieldValue));
        }
Exemplo n.º 4
0
        public DeviceWordEditor(IFullWord deviceWord)
        {
            mDeviceWord = deviceWord;
            if (mDeviceWord == null)
            {
                mDeviceWord = new FullWord();
            }

            mFullWordEditor = new FullWordEditor(mDeviceWord);
            mWordIndexLabel = new Label();
            InitializeComponent();
        }
Exemplo n.º 5
0
        public bool PreparePrenorm(IFullWord rAValue)
        {
            Registers.RA.LongValue = rAValue.LongValue;
            ProgramCounter         = mPrenormAddress.Value;

            if (IsBreakpointSet(ProgramCounter))
            {
                ReportBreakpointReached();
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        public FullWordEditor(IFullWord fullWord)
        {
            mFullWord = fullWord;
            mReadOnly = false;
            if (mFullWord == null)
            {
                mFullWord = new FullWord();
            }

            mWordValueEditor = new WordValueEditor(mFullWord);
            mWordCharTextBox = new MixByteCollectionCharTextBox(mFullWord);
            mEqualsLabel     = new Label();
            InitializeComponent();
        }
Exemplo n.º 7
0
        public void ApplyToFullWord(IFullWord word)
        {
            int byteCount         = mFieldSpec.ByteCount;
            int lowBoundByteIndex = mFieldSpec.LowBoundByteIndex;

            for (int i = 0; i < byteCount; i++)
            {
                word[lowBoundByteIndex + i] = base[i];
            }

            if (mFieldSpec.IncludesSign)
            {
                word.Sign = Sign;
            }
        }
Exemplo n.º 8
0
        void MExportButton_Click(object sender, EventArgs args)
        {
            var exportDialog = new MemoryExportDialog
            {
                MinMemoryIndex = mMemory.MinWordIndex,
                MaxMemoryIndex = mMemory.MaxWordIndex,
                FromAddress    = mWordEditorList.FirstVisibleIndex,
                ToAddress      = mWordEditorList.FirstVisibleIndex + mWordEditorList.VisibleEditorCount - 1,
                ProgramCounter = mMarkedAddress
            };

            if (exportDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            if (mSaveExportFileDialog == null)
            {
                mSaveExportFileDialog = new SaveFileDialog
                {
                    DefaultExt = "mixdeck",
                    Filter     = "MixEmul card deck files|*.mixdeck|All files|*.*",
                    Title      = "Specify export file name"
                };
            }

            if (mSaveExportFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                IFullWord[] memoryWords = new IFullWord[exportDialog.ToAddress - exportDialog.FromAddress + 1];

                int fromAddressOffset = exportDialog.FromAddress;
                for (int index = 0; index < memoryWords.Length; index++)
                {
                    memoryWords[index] = mMemory[fromAddressOffset + index];
                }

                try
                {
                    CardDeckExporter.ExportFullWords(mSaveExportFileDialog.FileName, memoryWords, fromAddressOffset, exportDialog.ProgramCounter);
                    MessageBox.Show(this, "Memory successfully exported.", "Export successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error while exporting memory: " + ex.Message, "Error while exporting", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
        }
Exemplo n.º 9
0
            public Instance(MixInstruction instruction, IFullWord instructionWord)
            {
                // check if this instruction word is actually encoding the instruction it is provided with...
                if (instructionWord[OpcodeByte] != instruction.Opcode)
                {
                    throw new ArgumentException("opcode in word doesn't match instruction opcode", nameof(instructionWord));
                }

                // ... and include the instruction fieldspec if there is one
                if (instruction.FieldSpec != null && instructionWord[FieldSpecByte] != instruction.FieldSpec.MixByteValue)
                {
                    throw new ArgumentException("fieldspec in word doesn't match instruction fieldspec", nameof(instructionWord));
                }

                MixInstruction  = instruction;
                InstructionWord = instructionWord;
            }
Exemplo n.º 10
0
        public void SaveToMemory(IMemory memory, int firstAddress, int addressValue)
        {
            int i;

            for (i = 0; i < mRegisters.Length; i++)
            {
                memory[firstAddress + i].Magnitude = mRegisters[i].Magnitude;
                memory[firstAddress + i].Sign      = mRegisters[i].Sign;
            }

            IFullWord composedWord = memory[firstAddress + i];

            if (addressValue < 0)
            {
                composedWord.Sign = Word.Signs.Negative;
                addressValue      = -addressValue;
            }
            else
            {
                composedWord.Sign = Word.Signs.Positive;
            }

            composedWord[addressByteIndex]     = (addressValue >> MixByte.BitCount) & MixByte.MaxValue;
            composedWord[addressByteIndex + 1] = addressValue & MixByte.MaxValue;

            FlagValues flags = FlagValues.None;

            if (OverflowIndicator)
            {
                flags |= FlagValues.Overflow;
            }
            if (CompareIndicator == CompValues.Greater)
            {
                flags |= FlagValues.Greater;
            }
            else if (CompareIndicator == CompValues.Less)
            {
                flags |= FlagValues.Less;
            }
            composedWord[flagsByteIndex] = (byte)flags;

            composedWord[rJByteIndex]     = RJ[0];
            composedWord[rJByteIndex + 1] = RJ[1];
        }
Exemplo n.º 11
0
        public static WordField LoadFromFullWord(FieldSpec fieldSpec, IFullWord word)
        {
            int fieldSpecByteCount = fieldSpec.ByteCount;

            var field             = new WordField(fieldSpec, fieldSpecByteCount);
            int lowBoundByteIndex = fieldSpec.LowBoundByteIndex;

            for (int i = 0; i < fieldSpecByteCount; i++)
            {
                field[i] = word[lowBoundByteIndex + i];
            }

            if (fieldSpec.IncludesSign)
            {
                field.Sign = word.Sign;
            }

            return(field);
        }
Exemplo n.º 12
0
        public InstructionInstanceTextBox(IFullWord instructionWord)
        {
            if (instructionWord == null)
            {
                instructionWord = new FullWord();
            }

            mInstructionWord = instructionWord;

            UpdateLayout();

            DetectUrls       = false;
            TextChanged     += This_TextChanged;
            KeyPress        += This_KeyPress;
            KeyDown         += This_KeyDown;
            LostFocus       += This_LostFocus;
            Enter           += This_Enter;
            ReadOnlyChanged += This_ReadOnlyChanged;

            mShowAddressMenuItem = new MenuItem("Show address", ShowAddressMenuItem_Click);

            mShowIndexedAddressMenuItem = new MenuItem("Show indexed address", ShowIndexedAddressMenuItem_Click);

            mContextMenu = new ContextMenu();
            mContextMenu.MenuItems.Add(mShowAddressMenuItem);
            mContextMenu.MenuItems.Add(mShowIndexedAddressMenuItem);

            ContextMenu = mContextMenu;

            mUpdating               = false;
            mEditMode               = false;
            MemoryAddress           = 0;
            mLastRenderedMagnitude  = unrendered;
            mLastRenderedSign       = Word.Signs.Positive;
            mLastRenderedSourceLine = null;
            mNoInstructionRendered  = true;

            Update();
        }
Exemplo n.º 13
0
        public int LoadFromMemory(IMemory memory, int firstAddress)
        {
            int i;

            for (i = 0; i < mRegisters.Length; i++)
            {
                mRegisters[i].Magnitude = memory[firstAddress + i].Magnitude;
                mRegisters[i].Sign      = memory[firstAddress + i].Sign;
            }

            IFullWord composedWord = memory[firstAddress + i];
            int       addressValue = ((byte)composedWord[addressByteIndex] << MixByte.BitCount) | (byte)composedWord[addressByteIndex + 1];

            if (composedWord.Sign.IsNegative())
            {
                addressValue = addressValue.GetMagnitude();
            }

            var flags = (FlagValues)(byte)composedWord[flagsByteIndex];

            OverflowIndicator = (flags & FlagValues.Overflow) == FlagValues.Overflow;
            if ((flags & FlagValues.Greater) == FlagValues.Greater)
            {
                CompareIndicator = CompValues.Greater;
            }
            else if ((flags & FlagValues.Less) == FlagValues.Less)
            {
                CompareIndicator = CompValues.Less;
            }
            else
            {
                CompareIndicator = CompValues.Equal;
            }

            RJ[0] = composedWord[rJByteIndex];
            RJ[1] = composedWord[rJByteIndex + 1];

            return(addressValue);
        }
Exemplo n.º 14
0
        public bool PrepareCall(string mnemonic, IFullWord rAValue)
        {
            Registers.RA.LongValue = rAValue.LongValue;

            return(PrepareCall(mnemonic));
        }
Exemplo n.º 15
0
 public Instance CreateInstance(IFullWord instructionWord) => new Instance(this, instructionWord);