with one click
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.
[HINT] Download the complete skill directory including SKILL.md and all related files
| 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.($xx),Y?
LDA ($FB),Y($xx,X)?ptr_screen, ptr_data, or vec_irq.
0 or 1 (or $00/$FF)?BIT, LDA/BEQ/BNE?is_active, has_collided, enable_music, etc.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.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 |
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").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).