en un clic
r2000-analyze-symbol
// 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 specific memory address or label to determine its purpose (variable, flag, pointer, hardware register) by examining its cross-references and usage patterns.
Orchestrates full-program analysis by running block classification, then analyzing all unanalyzed routines and symbols in parallel using subagents.
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-symbol |
| description | Analyzes a specific memory address or label to determine its purpose (variable, flag, pointer, hardware register) by examining its cross-references and usage patterns. |
Use this skill when the user asks to "analyze this label", "what is this variable?", or "trace this address". This skill focuses on data flow—understanding what a memory location represents rather than just what code executes.
r2000_get_disassembly_cursor or r2000_get_address_details to identify the address under the cursor.r2000_get_binary_info.
filename response and description (if provided) to identify the specific game or program. This allows you to infer domain-specific labels (e.g., "lap_counter" for a racing game, "lives" for a platformer) and look up known memory maps for popular titles.may_contain_undocumented_opcodes is true, the binary may use illegal/undocumented MOS 6502 opcodes. When tracing cross-references, be aware that instructions like LAX, SAX, DCP, etc. are valid and their read/write side effects must be considered in the data flow analysis.r2000_get_cross_references on the target address.
STA, STX, STY, INC, DEC, ASL, LSR, ROR, ROL.LDA, LDX, LDY, BIT, CMP, CPX, CPY, ADC, SBC.INC, DEC, ASL, LSR, ROR, ROL (read-modify-write).r2000_get_cross_references returns zero results:
$00–$FF) and whether nearby code uses ($addr),Y or ($addr,X) patterns.system value from r2000_get_binary_info.system value from r2000_get_binary_info.e_ or points to known system memory vectors (such as C64 KERNAL ROM space between $E000 and $FFFF, or standard system shadow vectors).$E544 -> KERNAL_CLRCHN or SCREENCLEAR, $FFD2 -> KERNAL_CHROUT, $EA31 -> SYSTEM_IRQ_HANDLER).($xx),Y?
LDA ($FB),Y($xx,X)?ptr_screen, ptr_data, or vec_irq.
r2000_set_immediate_format on the low-byte instruction address with "format": "low_byte" and "target_address": <decimal_target>.r2000_set_immediate_format on the high-byte instruction address with "format": "high_byte" and "target_address": <decimal_target>.0 or 1 (or $00/$FF)?BIT, LDA/BEQ/BNE?is_active, has_collided, enable_music, etc.$01 = ACTIVE, $02 = COLLIDED, $04 = VISIBLE) using r2000_create_project_enum.r2000_apply_enum_usage to make bitmask tests readable.INC) or decremented (DEC) inside a loop?CPX, CPY, CMP) against a limit?loop_idx, sprite_count, delay_timer.ASL / TAX / JMP (table,X))?game_state, current_mode.0 = INIT, 1 = TITLE, 2 = GAMEPLAY, 3 = GAME_OVER) using r2000_create_project_enum (including a helpful description).r2000_apply_enum_usage to all instructions reading or writing to this state variable.Rename: Use r2000_set_label_name to give it a meaningful, descriptive name based on your analysis.
Use the following naming conventions consistently:
| Symbol Kind | Convention | Example |
|---|---|---|
| Zero Page variable | zp_ prefix | zp_player_lives, zp_delay_timer |
| Zero Page pointer | zp_ptr_ prefix | zp_ptr_screen, zp_ptr_dest |
| RAM variable | snake_case | score_hi, current_level |
| Pointer / vector | ptr_ prefix | ptr_screen, vec_irq |
| Hardware register | UPPER_SNAKE | VIC_SPR0_X, SID_FreqLo1 |
| Constant / address | UPPER_SNAKE | SCREEN_RAM, CHR_ROM_BASE |
| Routine entry point | snake_case | init_screen, draw_sprite |
| External ROM call | KERNAL_ / OS_ | KERNAL_CHROUT, KERNAL_CLRCHN |
Zero Page rule: If the symbol's address is ≤
$FF, it must be prefixed withzp_. This applies to all categories above — a Zero Page pointer becomeszp_ptr_, a Zero Page flag becomeszp_is_active, and so on. Hardware registers and OS/KERNAL constants that live in Zero Page (e.g., C64 Zero Page OS variables) should also usezp_to make their addressing mode explicit.
Document:
r2000_set_comment with "type": "line" at the definition (if it's a variable in memory) to explain its range, purpose, or bitfield layout.r2000_set_comment with "type": "side" at key usages to clarify why it's being read or written (e.g., "Reset life counter", "Check for fire button").r2000_create_project_enum and r2000_apply_enum_usage) to formalize state values, mode types, or bitmask flags.r2000_set_immediate_format to format immediate low/high byte writes initializing the pointer to the target 16-bit address (using "format": "low_byte" / "high_byte" and "target_address").If you analyze an IRQ vector address and see:
IRQ_VECTOR_LO. Add comment: "Hardware IRQ vector shadow".If you analyze a Zero Page address (≤ $FF) and see:
STA ($20),Y.zp_ptr_dest. Add comment: "Destination pointer for memory copy".After completing the analysis, report to the user:
r2000_get_cross_references returned nothing, explain the possibilities (indirect use, KERNAL address, or dead variable).