Ypsilon.Emulation.Processor.YCPU.Disassemble C# (CSharp) Method

Disassemble() public method

public Disassemble ( ushort address, int count, bool extendedFormat = true ) : string[]
address ushort
count int
extendedFormat bool
return string[]
        public string[] Disassemble(ushort address, int count, bool extendedFormat = true)
        {
            string[] s = new string[count];
            ushort word;
            for (int i = 0; i < count; i += 1) {
                word = DebugReadMemory(address, SegmentIndex.CS);
                ushort nextword = DebugReadMemory((ushort)(address + 2), SegmentIndex.CS);
                ushort instructionSize = 2;
                YCPUInstruction opcode = m_Opcodes[word & 0x00FF];
                if (extendedFormat) {
                    s[i] =
                        $"{address:X4}:{word:X4} {(opcode.Disassembler != null ? opcode.Disassembler(opcode.Name, word, nextword, address, true, out instructionSize) : opcode.Name)}";
                }
                else {
                    s[i] = opcode.Disassembler != null ?
                        opcode.Disassembler(opcode.Name, word, nextword, address, false, out instructionSize).ToLowerInvariant() :
                        opcode.Name;
                }
                address += instructionSize;
            }
            return s;
        }

Usage Example

Example #1
0
        private string[] Disassemble(BinaryReader reader)
        {
            YCPU ycpu = new YCPU();
            byte[] data = new byte[reader.BaseStream.Length];
            reader.BaseStream.Read(data, 0, data.Length);
            ycpu.BUS.FillROM(data);

            string[] disassembled;
            disassembled = ycpu.Disassemble(0x0000, 32000, false);

            return disassembled;
        }