@@ -529,6 +529,10 @@ void McpServer::HandleToolsList(const json& request)
529529 {" resolve_symbols" , {
530530 {" type" , " boolean" },
531531 {" description" , " When true, replace addresses in instruction mnemonics with user-defined symbol names and hardware register labels (e.g. 'LDA MY_VAR,X' instead of 'LDA $2C00,X'). Symbol resolution for non-jump operands depends on the current MPR mapping. Default: false" }
532+ }},
533+ {" detailed" , {
534+ {" type" , " boolean" },
535+ {" description" , " Default false. Do NOT set to true unless you specifically need opcode bytes, jump targets, or IRQ metadata. The compact format is sufficient for analyzing code." }
532536 }}
533537 }},
534538 {" required" , json::array ({" start_address" , " end_address" })}
@@ -1621,42 +1625,66 @@ json McpServer::ExecuteCommand(const std::string& toolName, const json& argument
16211625 if (arguments.contains (" resolve_symbols" ) && arguments[" resolve_symbols" ].is_boolean ())
16221626 resolve_symbols = arguments[" resolve_symbols" ].get <bool >();
16231627
1628+ bool detailed = false ;
1629+ if (arguments.contains (" detailed" ) && arguments[" detailed" ].is_boolean ())
1630+ detailed = arguments[" detailed" ].get <bool >();
1631+
16241632 std::vector<DisasmLine> lines = m_debugAdapter.GetDisassembly (start_address, end_address, bank, resolve_symbols);
16251633
16261634 json result;
1627- json instructions = json::array ();
16281635
1629- for ( const DisasmLine& line : lines )
1636+ if (detailed )
16301637 {
1631- json instr;
1632- std::ostringstream addr_ss, bank_ss, jump_ss;
1633-
1634- addr_ss << std::hex << std::uppercase << std::setfill (' 0' ) << std::setw (4 ) << line.address ;
1635- bank_ss << std::hex << std::uppercase << std::setfill (' 0' ) << std::setw (2 ) << (int )line.bank ;
1636-
1637- instr[" address" ] = addr_ss.str ();
1638- instr[" bank" ] = bank_ss.str ();
1639- instr[" segment" ] = line.segment ;
1640- instr[" instruction" ] = line.name ;
1641- instr[" bytes" ] = line.bytes ;
1642- instr[" size" ] = line.size ;
1638+ json instructions = json::array ();
16431639
1644- if ( line. jump )
1640+ for ( const DisasmLine& line : lines )
16451641 {
1646- jump_ss << std::hex << std::uppercase << std::setfill (' 0' ) << std::setw (4 ) << line.jump_address ;
1647- instr[" jump_target" ] = jump_ss.str ();
1648- instr[" is_subroutine" ] = line.subroutine ;
1642+ json instr;
1643+ std::ostringstream addr_ss, bank_ss, jump_ss;
1644+
1645+ addr_ss << std::hex << std::uppercase << std::setfill (' 0' ) << std::setw (4 ) << line.address ;
1646+ bank_ss << std::hex << std::uppercase << std::setfill (' 0' ) << std::setw (2 ) << (int )line.bank ;
1647+
1648+ instr[" address" ] = addr_ss.str ();
1649+ instr[" bank" ] = bank_ss.str ();
1650+ instr[" segment" ] = line.segment ;
1651+ instr[" instruction" ] = line.name ;
1652+ instr[" bytes" ] = line.bytes ;
1653+ instr[" size" ] = line.size ;
1654+
1655+ if (line.jump )
1656+ {
1657+ jump_ss << std::hex << std::uppercase << std::setfill (' 0' ) << std::setw (4 ) << line.jump_address ;
1658+ instr[" jump_target" ] = jump_ss.str ();
1659+ instr[" is_subroutine" ] = line.subroutine ;
1660+ }
1661+
1662+ if (line.irq > 0 )
1663+ {
1664+ instr[" irq" ] = line.irq ;
1665+ }
1666+
1667+ instructions.push_back (instr);
16491668 }
16501669
1651- if (line.irq > 0 )
1670+ result[" instructions" ] = instructions;
1671+ }
1672+ else
1673+ {
1674+ json instructions = json::array ();
1675+
1676+ for (const DisasmLine& line : lines)
16521677 {
1653- instr[" irq" ] = line.irq ;
1678+ std::ostringstream ss;
1679+ ss << std::hex << std::uppercase << std::setfill (' 0' ) << std::setw (2 ) << (int )line.bank ;
1680+ ss << " :" << std::setw (4 ) << line.address ;
1681+ ss << " " << line.name ;
1682+ instructions.push_back (ss.str ());
16541683 }
16551684
1656- instructions. push_back (instr) ;
1685+ result[ " instructions" ] = instructions ;
16571686 }
16581687
1659- result[" instructions" ] = instructions;
16601688 result[" count" ] = lines.size ();
16611689 result[" start_address" ] = startAddrStr;
16621690 result[" end_address" ] = endAddrStr;
0 commit comments