with one click
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.
| 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, collect the information needed by all subsequent phases:
r2000_get_binary_info → get system, filename, description, may_contain_undocumented_opcodes.r2000_get_blocks → get the current block classification map.r2000_get_symbols → get all labels (user + system), including external labels.r2000_get_comments with type = "line" → used to detect routines that already have documentation header blocks.Store all of this data — you will reference it in every subsequent phase to skip already-analyzed items.
r2000-analyze-blocks)This phase always runs first. 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).r2000_get_blocks again.r2000_get_symbols again (new labels may have been created during block analysis).r2000_get_comments with type = "line" again.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 data, filter labels that represent subroutine entry points:
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.Use a rolling window of up to 10 concurrent subagents.
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, and add side comments to key instructions. 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:
After all routine subagents complete:
r2000_get_symbols again (labels were renamed by subagents).r2000_save_project to persist changes so far.Goal: For every data 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), ORTo build the candidate list:
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 and a_XXXX — auto-generated pointers, fields and absolute addresses outside the zero page.s_XXXX labels — those were handled in Phase 2.b_XXXX labels — those are branch labels, not data symbols.e_XXXX labels — those are external JMP/JSR targets, not data symbols.p_XXXX labels that are inside a Code block — those were handled as routine candidates in Phase 2.Same rolling window strategy as Phase 2: up to 10 concurrent subagents.
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 and add comments (line and/or side). 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.
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 |
| ... | ... | ... | ... |
r2000_save_project fails, warn the user immediately.The user says:
"Analyze this program"
The agent:
[HINT] Download the complete skill directory including SKILL.md and all related files