コード例 #1
0
        private bool TryScanProcedure(out ImageSymbol sym)
        {
            ushort us;
            var    addrStart = rdr.Address;

            sym = null;
            while (rdr.TryReadBeUInt16(out us))
            {
                switch (us)
                {
                case RTS:
                case JMP_A0:
                    // Found what looks like a terminator.
                    break;

                case RTD:
                    // Read uint16 of bytes to pop.
                    if (!rdr.TryReadBeUInt16(out us))
                    {
                        return(false);
                    }
                    // looks like a RTD xxx instruction.
                    break;

                default:
                    // Any other words are quietly eaten.
                    continue;
                }

                // Remember the end of the procedure.
                var position = rdr.Offset;

                // We think we saw the end of the procedure. Could there be a MacsBug symbol?
                string symbol;
                if (!TryReadMacsBugSymbol(out symbol))
                {
                    // Don't really want a symbol in this case.
                    // But there might be more procedures.
                    continue;
                }

                if (!SkipConstantData())
                {
                    // That wasn't valid constant data, but there might be more procedures.
                    // But there might be more procedures.
                    continue;
                }

                sym = new ImageSymbol(addrStart)
                {
                    Type = SymbolType.Procedure, Name = symbol
                };
                return(true);
            }
            return(false);
        }
コード例 #2
0
        private bool TryScanProcedure(out ImageSymbol sym)
        {
            ushort us;
            var    addrStart = rdr.Address;

            sym = null;
            for (;;)
            {
                if (!rdr.TryReadBeUInt16(out us))
                {
                    return(false);
                }
                if (us == RTS || us == JMP_A0)
                {
                    // Found what looks like a terminator.
                    break;
                }
                if (us == RTD)
                {
                    if (!rdr.TryReadBeUInt16(out us))
                    {
                        return(false);
                    }
                    // looks like a RTD xxx instruction.
                    break;
                }
            }

            // Remember the end of the procedure.
            var position = rdr.Offset;

            // We think we saw the end of the procedure. Could there be a MacsBug symbol?
            string symbol;

            if (!TryReadMacsBugSymbol(out symbol))
            {
                // Don't really want a symbol in this case.
                sym = new ImageSymbol {
                    Type = SymbolType.Unknown
                };
                // But there might be more procedures.
                return(true);
            }

            if (!SkipConstantData())
            {
                // That wasn't valid constant data, but there might be more procedures.
                sym = new ImageSymbol {
                    Type = SymbolType.Unknown
                };
                // But there might be more procedures.
            }
            else
            {
                sym = new ImageSymbol(addrStart)
                {
                    Type = SymbolType.Procedure, Name = symbol
                };
            }
            return(true);
        }