Ejemplo n.º 1
0
        // CALLBACKS
        public void BRCHREL(BoundInstruction boundInsn, int targetAddrBase)
        {
            if (_section.RelEntries != null && _section.RelEntries.Any(r => r.r_offset == CurAbsoluteIndex))
            {
                var rEntry = _section.RelEntries.First(r => r.r_offset == CurAbsoluteIndex);
                var sEntry = _symEntries[rEntry.R_SYM];

                if (!string.IsNullOrEmpty(sEntry.name))
                {
                    _section.RelocationSymbols[CurAbsoluteIndex] = sEntry.name;
                    return;
                }
            }

            var actualTargetAddr = targetAddrBase + _section.SectionOffset;

            string s;
            if (_section.ObjectDefLocations.TryGetValue(actualTargetAddr, out s))
                _section.RelocationSymbols[CurAbsoluteIndex] = s;
            else if (_section.LabelDefLocations.TryGetValue(actualTargetAddr, out s))
                _section.RelocationSymbols[CurAbsoluteIndex] = s;
            else
            {
                // create label
                s = "L_" + actualTargetAddr.ToString("X").PadLeft(8, '0');
                _section.RelocationSymbols[CurAbsoluteIndex] = s;
                _section.LabelDefLocations[actualTargetAddr] = s;
            }
        }
Ejemplo n.º 2
0
        public string VECTARG80(BoundInstruction boundInsn, int vectorArg, int flags)
        {
            if (GetBits(vectorArg, 1, 3) == 0x0007)
                return "r" + GetExtraBits(flags, 2, 3);

            var sb = new StringBuilder();

            string argSize = ARG_BIT_SIZES[GetBits(vectorArg, 1, 2)];
            bool vert = IsFlagSet(vectorArg, ARG_VERTICAL_FLAG);
            bool increment = IsExtraFlagSet(flags, EARG_INCREMENT_FLAG);

            sb.Append(vert ? "V" : "H");
            sb.Append(argSize);
            sb.Append("(");
            sb.Append(GetBits(vectorArg, 5, 6));
            if (increment && !vert)
                sb.Append("++");
            sb.Append(", ");
            if (argSize == "")
                sb.Append((int)(GetBits(vectorArg, 2, 2) << 4));
            else if (argSize == "X")
                sb.Append((int)(GetBits(vectorArg, 3, 1) << 5));
            else if (argSize == "Y")
                sb.Append("0");
            if (increment && vert)
                sb.Append("++");
            sb.Append(")");

            return sb.ToString();
        }
Ejemplo n.º 3
0
        // CALLBACKS
        public string VECTARG48(BoundInstruction boundInsn, int vectorArg, int scalar)
        {
            if (GetBits(vectorArg, 1, 3) == 0x0007)
                return "r" + scalar;

            var sb = new StringBuilder();

            string argSize = ARG_BIT_SIZES[GetBits(vectorArg, 1, 2)];

            sb.Append(IsFlagSet(vectorArg, ARG_VERTICAL_FLAG) ? "V" : "H");
            sb.Append(argSize);
            sb.Append("(");
            sb.Append(GetBits(vectorArg, 5, 6));
            sb.Append(", ");
            if (argSize == "")
                sb.Append((int)(GetBits(vectorArg, 2, 2) << 4));
            else if (argSize == "X")
                sb.Append((int)(GetBits(vectorArg, 3, 1) << 5));
            else if (argSize == "Y")
                sb.Append("0");
            sb.Append(")");

            return sb.ToString();
        }
Ejemplo n.º 4
0
        public string Invoke(object target, BoundInstruction source, Dictionary<char, int> boundValues)
        {
            var funcRef = GetCallbackMethod(target);
            if (funcRef == null)
                return string.Empty;

            var evaluatedParams = new object[RequiredParams.Length + 1];
            evaluatedParams[0] = source;
            int i = 0;
            foreach (object p in RequiredParams)
            {
                i++;

                var expr = p as Expression;
                if (expr != null)
                {
                    evaluatedParams[i] = EvaluateExpression(expr, boundValues);
                    continue;
                }

                if (p is char)
                {
                    var boundIndex = (char)p;

                    int boundValue;
                    if (boundValues.TryGetValue(boundIndex, out boundValue))
                    {
                        string[] table;
                        if (IV_BASE._tables.TryGetValue(boundIndex, out table))
                            evaluatedParams[i] = table[boundValue];
                        else
                            evaluatedParams[i] = boundValue;

                        continue;
                    }

                    throw new Exception("INVALID CHARACTER");
                }

                throw new Exception("INVALID PRINT PARAMETER");
            }

            var retVal = funcRef.Invoke(target, evaluatedParams);
            return (retVal as string) ?? string.Empty;
        }
Ejemplo n.º 5
0
 public string REPNUM(BoundInstruction boundInsn, int rep)
 {
     if (rep > 0 && rep < 7)
         return " REP " + (0x1 << rep);
     return "";
 }