with one click
r2000-analyze-basic
// Analyzes a sequence of memory containing Commodore BASIC tokens, formats address/word data types, and constructs side comments representing the plain BASIC commands.
// Analyzes a sequence of memory containing Commodore BASIC tokens, formats address/word data types, and constructs side comments representing the plain BASIC commands.
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.
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-basic |
| description | Analyzes a sequence of memory containing Commodore BASIC tokens, formats address/word data types, and constructs side comments representing the plain BASIC commands. |
Use this skill when the user asks to:
Identify the starting and ending addresses of the Commodore BASIC sequence from the user's request or cross-references. If unspecified, prompt the user for clarification.
Invoke the r2000_read_region tool to read the requested sequence:
start_address: The sequence start address (decimal).end_address: The sequence end address (decimal).view: "hexdump"Commodore BASIC programs follow a strict structured sequence in memory. Iterate through the lines starting from the initial address, following the "Next Line Pointer" until you reach the end of the program.
24 04 $\rightarrow$ `$0424$).0A 00 $\rightarrow$ 10).$00 (null) terminator is encountered.$00 $00.Bytes in step 3 with the high-bit set ($80 to $CB) are keyword tokens. Decode them against this table:
| Hex | Keyword | Hex | Keyword | Hex | Keyword | Hex | Keyword |
|---|---|---|---|---|---|---|---|
$80 | END | $93 | LOAD | $A6 | SPC( | $B9 | POS |
$81 | FOR | $94 | SAVE | $A7 | THEN | $BA | SQR |
$82 | NEXT | $95 | VERIFY | $A8 | NOT | $BB | RND |
$83 | DATA | $96 | DEF | $A9 | STEP | $BC | LOG |
$84 | INPUT# | $97 | POKE | $AA | + | $BD | EXP |
$85 | INPUT | $98 | PRINT# | $AB | - | $BE | COS |
$86 | DIM | $99 | PRINT | $AC | * | $BF | SIN |
$87 | READ | $9A | CONT | $AD | / | $C0 | TAN |
$88 | LET | $9B | LIST | $AE | ^ | $C1 | ATN |
$89 | GOTO | $9C | CLR | $AF | AND | $C2 | PEEK |
$8A | RUN | $9D | CMD | $B0 | OR | $C3 | LEN |
$8B | IF | $9E | SYS | $B1 | > | $C4 | STR$ |
$8C | RESTORE | $9F | OPEN | $B2 | = | $C5 | VAL |
$8D | GOSUB | $A0 | CLOSE | $B3 | < | $C6 | ASC |
$8E | RETURN | $A1 | GET | $B4 | SGN | $C7 | CHR$ |
$8F | REM | $A2 | NEW | $B5 | INT | $C8 | LEFT$ |
$90 | STOP | $A3 | TAB( | $B6 | ABS | $C9 | RIGHT$ |
$91 | ON | $A4 | TO | $B7 | USR | $CA | MID$ |
$92 | WAIT | $A5 | FN | $B8 | FRE | $CB | GO |
(Note: Bytes between $20 and $7F are literal PETSCII text characters like strings, variables, and numbers).
Formulate a sequence of commands for r2000_batch_execute to apply the modifications for all decoded BASIC lines at once.
For each decoded line:
r2000_set_data_type on Bytes 0–1 with "data_type": "address".r2000_set_data_type on Bytes 2–3 with "data_type": "word".r2000_set_data_type from Byte 4 to the $00 terminator (inclusive) with "data_type": "byte".10 REM LODE RUNNER).r2000_set_comment to set this string as a "side" comment at the start of the line (Byte 0).Continue this process by jumping to the address specified in the "Next Line Pointer" until the pointer is $00 $00. Finally, mark the $00 $00 terminator itself as "word".
When completed, invoke r2000_save_project to persist the comments and types.