Exemple #1
0
        public string OperandLabel(int addr)
        {
            AsmLine line = GetAsmLineByAddress(addr);

            Debug.Assert(line.Is6502Operation());
            return(line.OperandArgument.Label);
        }
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var            lbi  = (ListBoxItem)value;
            AsmListBoxItem item = (AsmListBoxItem)lbi.Content;

            AddressItem addressItem = item as AddressItem;
            string      operand     = addressItem.Operand ?? "";

            Console.WriteLine(operand);

            int padding;

            operand = int.TryParse(parameter.ToString(), out padding) ? operand.PadRight(padding) : operand;

            AsmLine asmLine = item.AsmLine;

            if (asmLine.HasOperandArgument())
            {
                if (asmLine.OperandArgument.HasLabel())
                {
                    if (!(asmLine.IsJumpOperation() || asmLine.IsBranchOperation() || asmLine.Opcode == "rts"))
                    {
                        string label = asmLine.OperandArgument.Label;
                        operand = operand.Replace(label, "<Run Foreground=\"DarkOrange\">" + label + "</Run>");
                    }
                }
            }


            return(operand.Replace("&", "&amp;"));
        }
Exemple #3
0
        public string OpcodeLineKey(int addr)
        {
            AsmLine line = GetAsmLineByAddress(addr);

            Debug.Assert(line.Is6502Operation());
            return(line.Offset + " " + line.Address);
        }
Exemple #4
0
        public string Opcode(int addr)
        {
            AsmLine line = GetAsmLineByAddress(addr);

            Debug.Assert(line.Is6502Operation());
            return(line.Opcode);
        }
Exemple #5
0
        private AsmLine GetAsmLineByAddress(int addr)
        {
            AsmLine line = null;

            _asmLineByAddress.TryGetValue(addr, out line);
            return(line);
        }
Exemple #6
0
 string InstructionColor(AsmLine asmLine)
 {
     if (asmLine.IsBranchOperation())
     {
         return("Blue");
     }
     if ("jmp jsr rts".Contains(asmLine.Opcode))
     {
         return("Red");
     }
     return("Black");
 }
Exemple #7
0
 private string ColorOpcodeOperand(AsmLine asmLine, string paddedOperand)
 {
     if (asmLine.HasOperandArgument())
     {
         if (asmLine.OperandArgument.HasLabel())
         {
             if (!(asmLine.IsJumpOperation() || asmLine.IsBranchOperation() || asmLine.Opcode == "rts"))
             {
                 string label = asmLine.OperandArgument.Label;
                 paddedOperand = "<Span>" + paddedOperand.Replace(label, "<Run Foreground=\"DarkOrange\">" + label + "</Run>").Replace("&", "&amp;") + "</Span>";
             }
         }
     }
     return(paddedOperand.Replace("&", "&amp;"));
 }
Exemple #8
0
        public AsmReader(string filename)
        {
            _inputLines = new List <string>(File.ReadAllLines(filename));

            foreach (string line in _inputLines)
            {
                AsmLine asmLine = new AsmLine(line, _asmLines.Count);
                _asmLines.Add(asmLine);
            }

            _addressByLabel = AddressByLabelDictionary();
            _labelByAddress = LabelByAddressDictionary();

            // all JSR have labels as subroutine address
            ValidateJsrCalls();
        }
Exemple #9
0
        private void GotoPreviousLabel()
        {
            AsmListBoxItem item    = listBox.SelectedItem as AsmListBoxItem;
            AsmLine        asmLine = item.AsmLine;
            int            index   = asmLine.Index - 1;

            while (index >= 0)
            {
                asmLine = AsmReader._asmLines[index];
                if (asmLine.IsMemoryMapped() && asmLine.HasLabel())
                {
                    ScrollToAddress(asmLine.DecimalAddress, ScrollMode.Smooth);
                    return;
                }
                index--;
            }
        }
Exemple #10
0
        private void FollowJumpImmediate()
        {
            AsmLine asmLine = SelectedAsmLine();

            if (!asmLine.IsJumpOperation())
            {
                return;
            }
            _addressStack.Push(asmLine.DecimalAddress);

            string label = asmLine.OperandArgument.Label;
            int    address;

            if (!AsmReader.AddressByLabelDictionary().TryGetValue(label, out address))
            {
                return;
            }
            ScrollToAddress(address, ScrollMode.ScrollToCenterOfView);
        }
Exemple #11
0
        public string GetAsmLineByIndex(int index)
        {
            AsmLine line = _reader._asmLines[index];

            return(line.Line);
        }