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

DisassembleJMP() private method

private DisassembleJMP ( string name, ushort operand, ushort nextword, ushort address, bool showMemoryContents, ushort &instructionSize ) : string
name string
operand ushort
nextword ushort
address ushort
showMemoryContents bool
instructionSize ushort
return string
        private string DisassembleJMP(string name, ushort operand, ushort nextword, ushort address, bool showMemoryContents, out ushort instructionSize)
        {
            int addressingmode = (operand & 0x7000) >> 12;
            RegGeneral r_src = (RegGeneral)((operand & 0x1C00) >> 10);
            int index_bits = (operand & 0x0300) >> 8;
            SegmentIndex segData = (operand & 0x8000) != 0 ? SegmentIndex.ES : SegmentIndex.DS;
            bool isFar = (operand & 0x0100) != 0;
            if (isFar) {
                name += ".F";
            }
            switch (addressingmode) {
                case 0: // Immediate or Absolute
                    bool absolute = (operand & 0x0200) != 0;
                    instructionSize = (ushort)(isFar && !absolute ? 8 : 4);
                    if (absolute) {
                        return
                            $"{name,-8}[${nextword:X4}]{string.Format($"         (${DebugReadMemory(nextword, SegmentIndex.CS):X4})", DebugReadMemory(nextword, SegmentIndex.CS))}";
                    }
                    return $"{name,-8}${nextword:X4}{(isFar ? ", $<SEGREG>" : string.Empty)}";
                case 1: // Register
                    instructionSize = 2;
                    return $"{name,-8}{NameOfRegGP(r_src)}              (${R[(int)r_src]:X4})";
                case 2: // Indirect
                    instructionSize = 2;
                    return
                        $"{name,-8}[{NameOfRegGP(r_src)}]            (${DebugReadMemory(R[(int)r_src], segData):X4})";
                case 3: // Indirect Offset (also Absolute Offset)
                    instructionSize = 4;
                    return
                        $"{name,-8}[{NameOfRegGP(r_src)},${nextword:X4}]      (${DebugReadMemory((ushort)(R[(int)r_src] + nextword), segData):X4})";
                default: // $8 - $f = Indirect Indexed
                    instructionSize = 2;
                    index_bits += (operand & 0x4000) >> 12;
                    return
                        $"{name,-8}[{NameOfRegGP(r_src)},{NameOfRegGP((RegGeneral)index_bits)}]         (${DebugReadMemory((ushort)(R[(int)r_src] + R[index_bits]), segData):X4})";
            }
        }