Exemplo n.º 1
0
        // find fragments jumped to by this fragment
        // applies Branch and Call code tags, and adjusts fragments to include SPB return address
        static void Connect(Fragment frag)
        {
            Int32 addr  = frag.Start;
            Int32 limit = frag.Start + frag.Length;

            while (addr < limit)
            {
                UInt16 word = CORE[addr];
                if (!CTagIs(addr++, CTag.Valid))
                {
                    continue;                              // skip over operands
                }
                Int32 op = (word >> 12) & 15;
                if (op == 0) // augmented 00 instructions
                {
                    op = word & 63;
                    if (op == 30) // LOB
                    {
                        Int32 target = CORE[addr++];
                        CTAG[target] |= CTag.Branch;
                        Fragment tf = FindFragment(target);
                        if (tf == null)
                        {
                            continue;
                        }
                        if (tf != frag)
                        {
                            Connect(frag, tf);
                        }
                    }
                }
                else if (op == 9) // BRU
                {
                    Int32 target = MemOpAddr(addr - 1, word);
                    CTAG[target] |= CTag.Branch;
                    Fragment tf = FindFragment(target);
                    if (tf == null)
                    {
                        continue;
                    }
                    if (tf != frag)
                    {
                        Connect(frag, tf);
                    }
                }
                else if (op == 10) // SPB
                {
                    Int32 target = MemOpAddr(addr - 1, word);
                    CTAG[target] |= CTag.Call;
                    Fragment tf = FindFragment(target + 1);
                    if (tf == null)
                    {
                        continue;
                    }
                    if (tf != frag)
                    {
                        Connect(frag, tf);
                    }
                    if (FindFragment(target) == null)
                    {
                        tf.AdjustStart(-1);
                    }
                }
            }
        }