private void ShowDisassembly()
    {
        byte[] data = new byte[lDisk.SectorSize * sectorsToBoot];
        byte[] sec;

        for (int i = 0; i <= sectorsToBoot - 1; i++)
        {
            sec = lDisk.ReadSector(i + 1);
            sec.CopyTo(data, i * lDisk.SectorSize);
        }

        M6502DASM disasm = new M6502DASM(data, loadAddress - 3);
        UIDisassembly.Text = disasm.Disassemble();
    }
Esempio n. 2
0
        private void AssembleLine()
        {
            Byte[] b = new Byte[3];
            UInt16 i, addr;
            int    n;

            // Get address
            try
            {
                addr = Convert.ToUInt16(txtAddr.Text.Trim(), 16);
            }
            catch
            {
                MessageBox.Show("Error: Invalid address");
                return;
            }

            // Assemble line
            if (txtLine.Text.Trim() == "")
            {
                return;
            }

            n = asm.AsmLine(txtLine.Text, b, addr);

            // Check for errors
            if (n == -1)
            {
                MessageBox.Show("Error: " + asm.ErrMsg, "Line ASM error");
            }
            else
            {
                // Write assembled instruction to memory
                for (i = 0; i < n; i++)
                {
                    mem.DebugWrite((UInt16)(addr + i), b[i]);
                }

                // Update display
                lbList.Items.Add(dasm.Disassemble(addr));
                addr        += (UInt16)n;
                txtAddr.Text = string.Format("{0:X4} ", addr);
                txtLine.Text = "";
            }
        }
Esempio n. 3
0
        public void update()
        {
            int    y, lines;
            string s;
            SizeF  size;
            UInt16 addr;

            // Clear bitmap
            g.Clear(Color.LightGray);

            // Determine the size of a Byte
            size = g.MeasureString("0", NormalFont);

            // Determine the number of lines that will fit in the box
            lines = (int)Math.Floor(pbMem.Height / size.Height);

            addr = startAddress;
            for (y = 0; y < lines; y++)
            {
                // Hightlight program counter address
                if (addr == CPU.PC)
                {
                    g.FillRectangle(CurAddressBrush, 0, y * size.Height, pbMem.Width, size.Height);
                }

                // Disassemble and display line
                s = dasm.Disassemble(addr);
                g.DrawString(s, NormalFont, NormalFontBrush, 0, y * size.Height);

                // Check if we are at the end of memory
                if (dasm.dPC < addr)
                {
                    endAddress = 0xFFFF;
                    break;
                }

                endAddress = addr;

                // Next address
                addr = dasm.dPC;
            }
            pbMem.Refresh();
        }
	public void DisassembleBinaryLoadFile(BinaryLoadFile file, string destFileName)
	{
		StreamWriter sw = new StreamWriter(destFileName);
		StringBuilder s;
		BinaryLoadSegment seg = new BinaryLoadSegment();

		for (int i = 0; i <= file.SegmentCount - 1; i++) {
			seg = file.Segment(i);
			s = new StringBuilder();
			s.Append(string.Format("Segment {0}",i));
			s.Append(string.Format(", Start Address: {0}" ,seg.StartAddress));
			s.Append(string.Format(", End Address: {0}",seg.EndAddress));

			sw.WriteLine(s.ToString());
			sw.WriteLine("");

			disAsm = new M6502DASM(seg.Data, seg.StartAddress);

			sw.Write(disAsm.Disassemble());
		}

		sw.Close();
	}
	private void cbSegments_SelectedIndexChanged(System.Object sender, System.EventArgs e)
	{
		BinaryLoadSegment seg;
		seg = _file.Segment(cbSegments.SelectedIndex);

		M6502DASM disasm = new M6502DASM(seg.Data, seg.StartAddress);
		txtDisasm.Text = disasm.Disassemble();
	}