Executive Summary

When building a custom disassembler for an undocumented, legacy, or modified CPU architecture, the primary challenge is not writing the decoding loop, but obtaining a structured, machine-readable opcode-to-instruction mapping table.

While one might expect to extract these tables from existing reverse-engineering frameworks like Ghidra, doing so is surprisingly difficult. Ghidra’s instruction definitions are deeply integrated into its SLAgh engine and designed for internal P-Code translation rather than data export. Traditional CLI disassemblers (like dis51) hardcode their mappings directly inside compiled execution logic.

This article presents an alternative methodology: leveraging a Large Language Model (Gemini) to reconstruct, normalize, and export a complete opcode lookup table into a clean Python structure in minutes, and using it to power a lightweight linear sweep disassembler.

1. The Core Problem: Why Extracting Opcode Tables from Existing Tools Fails