一键导入
r2000-analyze-program
// Orchestrates full-program analysis by running block classification, then analyzing all unanalyzed routines and symbols in parallel using subagents.
// Orchestrates full-program analysis by running block classification, then analyzing all unanalyzed routines and symbols in parallel using subagents.
Analyzes a specific memory address or label to determine its purpose (variable, flag, pointer, hardware register) by examining its cross-references and usage patterns.
Analyzes a disassembly subroutine to determine its function by examining code, cross-references, and memory usage, leveraging target system expertise.
Analyzes memory regions of a disassembled binary and converts them to the correct block types (code, bytes, words, text, tables, etc.) using MOS 6502 and the target system's expertise.
Analyzes a sequence of memory containing Commodore BASIC tokens, formats address/word data types, and constructs side comments representing the plain BASIC commands.
Streamlines the process of adding new tools to the MCP server.
Automates the process of bumping the version and updating the changelog.
| name | r2000-analyze-program |
| description | Orchestrates full-program analysis by running block classification, then analyzing all unanalyzed routines and symbols in parallel using subagents. |
Use this skill when the user asks to "analyze this program", "analyze everything", "full analysis", or wants a complete end-to-end pass over the loaded binary — classifying blocks, documenting routines, and naming symbols.
This skill orchestrates the following existing skills in order:
r2000-analyze-blocks — Classify all memory regions (code vs data vs text, etc.).r2000-analyze-routine — Analyze and document each subroutine.r2000-analyze-symbol — Analyze and name each data symbol.Before starting or launching any subagents, you must gather context and check if the binary is packed/compressed.
r2000_get_binary_info.
"entropy" value.r2000_get_binary_info tool (e.g. from tools/list) to find the entropy threshold preference (e.g., 7.5).entropy is greater than or equal to the threshold (values above the threshold suggest the binary might be compressed):
r2000_unpack_binary tool.r2000_unpack_binary is a destructive action (clears existing comments/labels/blocks) and may take up to 10 seconds or more.r2000_unpack_binary returns an error: The binary was not unpacked. Log the failure and continue the analysis on the current binary.r2000_get_binary_info again to fetch the new unpacked binary's info and continue.r2000-analyze-blocks)Block classification is a prerequisite for all subsequent analysis.
.agent/skills/r2000-analyze-blocks/SKILL.md.r2000-analyze-blocks workflow directly (not via a subagent — this is a single long-running pass over the entire binary that you perform yourself).Goal: For every subroutine that hasn't been analyzed yet, launch a subagent to analyze it.
A subroutine is considered already analyzed if its entry point has any line comment (the presence of a line comment indicates it has already been documented).
To build the candidate list:
r2000_get_symbols to get all labels (user + system), including external labels, and save the symbols since they will be used later.r2000_get_comments to get all the comments, and save the comments since they will be used later.s_ (auto-generated subroutine labels), ORCode block that are the target of at least one JSR cross-reference, ORp_XXXX label that is inside a Code block. These are addresses referenced as pointers (via immediate lo/hi byte loads like LDX #<addr / LDY #>addr, or stored in address tables) and point to executable code. They are almost always one of:
$0314/$0315) via a helper routine. The pointer labels are created from the LDX #<p_XXXX / LDY #>p_XXXX immediate loads, not from direct vector writes. This is the most common case.$FFFA–$FFFF) or shadow vectors ($0314/$0315, $0318/$0319).p_XXXX label in a Code block as a routine candidate. This avoids the need for fragile pattern-matching against specific vector addresses or instruction sequences.start. This is the program's entry point and is critical for understanding the overall program flow.r2000_get_comments data). If yes → skip it (already documented).start is in the unanalyzed list, it must be placed first — it is the program entry point and should be analyzed before all other routines. This ensures that the entry-point context is available when analyzing subsequent routines.CRITICAL: Always launch each subagent with an explicit target address (e.g., $XXXX or decimal NNNNN). NEVER use the "current cursor address" or rely on the active cursor location in the editor, as the cursor will change dynamically when running parallel subagents.
Use a rolling window of up to 7 concurrent subagents (to avoid hitting rate limit quota errors like RESOURCE_EXHAUSTED).
For each subagent, provide this prompt:
Read the skill file at
.agent/skills/r2000-analyze-routine/SKILL.mdand follow its workflow.Analyze the routine at address
$XXXX(decimal: NNNNN).Binary info: system = {system}, filename = {filename}, description = {description}, may_contain_undocumented_opcodes = {hint}.
Apply all changes automatically — rename the label, add the header comment block, add side comments to key instructions, and apply low/high byte formatting (
r2000_set_immediate_format) to any immediate pointer loads. Do NOT ask for user confirmation.When done, report: the new label name, a one-line summary of what the routine does, and any uncertain areas.
Rolling window strategy:
RESOURCE_EXHAUSTED / Code 429), immediately catch the failure, log it, and queue the routine to be processed sequentially or directly by the parent orchestrator after a brief delay.After all routine subagents complete:
r2000_save_project to persist changes so far.Goal: For every data symbol and external jump symbol (internal + external) that hasn't been analyzed yet, launch a subagent.
A symbol is considered already analyzed if:
a_XXXX, f_XXXX, p_XXXX, zpa_XX, zpf_XX, zpp_XX, e_XXXX), ORTo build the candidate list:
r2000_get_symbols again (labels were renamed by subagents).r2000_get_symbols data, collect all labels whose name matches auto-generated patterns:
zpp_XX, zpf_XX and zpa_XX — auto-generated pointers, fields and absolute addresses in the zero page.p_XXXX, f_XXXX, a_XXXX and e_XXXX — auto-generated pointers, fields, absolute addresses, and external ROM jump vectors outside the zero page.s_XXXX labels — those were handled in Phase 2.b_XXXX labels — those are branch labels, not data symbols.p_XXXX labels that are inside a Code block — those were handled as routine candidates in Phase 2.CRITICAL: Always launch each subagent with an explicit target address (e.g., $XXXX or decimal NNNNN). NEVER use the "current cursor address" or rely on the active cursor location in the editor, as the cursor will change dynamically when running parallel subagents.
Same rolling window strategy as Phase 2: up to 7 concurrent subagents (to avoid hitting rate limit quota errors like RESOURCE_EXHAUSTED).
For each subagent, provide this prompt:
Read the skill file at
.agent/skills/r2000-analyze-symbol/SKILL.mdand follow its workflow.Analyze the symbol at address
$XXXX(decimal: NNNNN). Current label:{current_label}.Binary info: system = {system}, filename = {filename}, description = {description}, may_contain_undocumented_opcodes = {hint}.
Apply all changes automatically — rename the label, add comments (line and/or side), and apply low/high byte formatting (
r2000_set_immediate_format) to any instructions initializing the symbol. Do NOT ask for user confirmation.When done, report: the old label, the new label name, the classification (flag, counter, pointer, state variable, etc.), and any uncertain areas.
As each subagent completes, immediately launch the next symbol from the queue into the freed slot.
Error Fallback: If any subagent encounters a quota or model capacity error (e.g., RESOURCE_EXHAUSTED / Code 429), immediately catch the failure, log it, and queue the symbol to be processed sequentially or directly by the parent orchestrator after a brief delay.
After all symbol subagents complete:
r2000_save_project to persist all changes.r2000_save_project one final time to ensure everything is persisted.Total number of routines analyzed.
Table of results:
| Address | Old Label | New Label | Summary |
|---|---|---|---|
$C000 | s_C000 | init_screen | Clears screen RAM and sets border color |
$C050 | s_C050 | read_joystick | Reads CIA1 port A for joystick 2 input |
| ... | ... | ... | ... |
Total number of symbols analyzed.
Table of results:
| Address | Old Label | New Label | Classification |
|---|---|---|---|
$02 | zpp_02 | ptr_screen | Pointer (ZP indirect) |
$0400 | a_0400 | score_display | Screencode buffer |
| ... | ... | ... | ... |
RESOURCE_EXHAUSTED / Code 429) during analysis.RESOURCE_EXHAUSTED (code 429)).RESOURCE_EXHAUSTED / Code 429), log the failure, cleanly terminate the background task if necessary, and fallback to direct sequential analysis of the failed target.r2000_save_project fails, warn the user immediately.The user says:
"Analyze this program"
The agent: