64kramsystem / 64kramsystem/ghidra-vice-connector

Import symbols from VICE label files and assembler debug output

Open
#25 0 comments 0 reactions 0 assignees View on GitHub
priority: medium
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Summary

Import labels and source-line mappings from common C64 assembler output formats into the Ghidra program database. Many C64 games have published community disassemblies with label files; being able to import them instantly bootstraps analysis.

Source: IceBroLite (auto-loads .dbg, .sym, .vs); 64tass `--vice-labels` output; Kick Assembler `.dbg` files.

---

## Format 1: VICE label format (`.vs` / `.sym`)

Used by: VICE monitor `save_labels`, 64tass `--vice-labels`, CBM prg Studio symbol export.

```
al C:0800 .game_start
al C:1234 .irq_handler
al C:FFEE .CHROUT
```

Parsing: `re.findall(r'al C:([0-9a-fA-F]{4})\s+\.(\S+)', text)` → `(hex_addr, label_name)`.

### 2: Kick Assembler `.dbg` format

XML file output by KickAssembler (`-debugdump` flag). Structure (confirmed from vscode-kickass-studio `sourceMap.ts`):

```xml






0800,,0,10,0
0803,,0,11,0



```

Labels field: comma-separated `_,addr_hex,name`.

---

## Implementation

A Ghidra script `ImportC64Labels.java` in `data/ghidra-scripts/`:

```java
// Prompt for file, detect format by extension or content
File f = askFile("Select label file", "Import");
String text = new String(Files.readAllBytes(f.toPath()));

if (text.contains("")) {
// Parse XML .dbg format
} else {
// Parse VICE .vs format: lines matching /al C:([0-9a-fA-F]{4}) \.(\S+)/
Pattern p = Pattern.compile("al C:([0-9a-fA-F]{4}) \\.([\\S]+)");
Matcher m = p.matcher(text);
while (m.find()) {
long addr = Long.parseLong(m.group(1), 16);
String name = m.group(2);
createLabel(toAddr(addr), name, true, SourceType.IMPORTED);
}
}
```

For `.dbg` files, also map source lines to addresses using Ghidra's `SourceFile` / `LineNumber` APIs to enable source-level display.

---

## Files to create/change

- `data/ghidra-scripts/ImportC64Labels.java` — new script
- `README.md` — mention in setup section

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.