Beispiel #1
0
        public void AddReferenceWord()
        {
            Word word1 = new Word(0x1234);
            Word word2 = new Word(0x5678);

            m_relModule.AddWord(word1);
            m_relModule.AddWord(word2);
            MemoryOffset wordOffset = new MemoryOffset(2);

            m_relModule.AddReferenceWord(m_label);

            IEnumerable <Word> actualWords = m_relModule.Words;

            Word[] expectedWords = TestUtils.MakeArray(word1, word2, Word.Zero);
            TestUtils.CheckEnumerable(
                expectedWords, actualWords,
                "語のコレクションに、リンク時にラベルのアドレスと置き換わる値が 0 の語が追加される");

            Int32 labelRefsCount = m_relModule.LabelRefs.Count();

            Assert.AreEqual(1, labelRefsCount, "ラベル参照のコレクションに、ラベルへの参照が 1 つ追加される");

            LabelReference expectedLabelRef = LabelReference.MakeForUnitTest(m_label, wordOffset);
            LabelReference actualLabelRef   = m_relModule.LabelRefs.First();

            LabelReferenceTest.Check(
                expectedLabelRef, actualLabelRef,
                "ラベルへの参照には、参照するラベルとそのラベルのアドレスが入る語のオフセットが記録される");
        }
Beispiel #2
0
        public void ResolveReferringAddress()
        {
            LabelAddressResolver labelAddrResolver = LabelAddressResolverTest.Make();
            const UInt16         LabelAddress      = 0x2468;
            LabelDefinition      labelDef          = LabelDefinitionTest.Make("LBL001", 0, LabelAddress);

            labelAddrResolver.LabelTable.RegisterForUnitTest(labelDef);

            const Int32    WordCount   = 4;
            WordCollection actualWords = WordCollectionTest.MakeWords(WordCount);
            MemoryOffset   wordOffset  = new MemoryOffset(1);
            LabelReference labelRef    = LabelReference.MakeForUnitTest(labelDef.Label, wordOffset);

            labelRef.ResolveReferringAddress(labelAddrResolver, actualWords);

            WordCollection expectedWords = WordCollectionTest.MakeWords(WordCount);

            expectedWords[wordOffset] = new Word(LabelAddress);
            TestUtils.CheckEnumerable(
                expectedWords, actualWords,
                "ラベルを参照する語の値がそのラベルのアドレスに置き換えられる");
        }
Beispiel #3
0
        public void Make()
        {
            Label          referringLabel = new Label("LBL001");
            WordCollection actualWords    = new WordCollection();

            // actualWords に 1 語追加して、語のオフセットを初期値の 0 以外の値にする。
            MemoryOffset wordOffset = new MemoryOffset(1);
            Word         addedWord  = new Word(0x55AA);

            actualWords.Add(addedWord);

            LabelReference actualLabelRef = LabelReference.Make(referringLabel, actualWords);

            Word[] expectedWords = TestUtils.MakeArray(addedWord, Word.Zero);
            TestUtils.CheckEnumerable(
                expectedWords, actualWords,
                "オブジェクトコードに、参照するラベルのアドレスを入れる場所として、値が 0 の語が追加される");

            LabelReference expectedLabelRef = LabelReference.MakeForUnitTest(referringLabel, wordOffset);

            Check(
                expectedLabelRef, actualLabelRef,
                "作成された labelRef には、参照するラベルとそのアドレスを入れるオフセットが入る");
        }