Initial commit: ADSP-219x disassembler, docs, test ROMs, analysis tools
- Standalone Python disassembler for 24-bit ADSP-219x instructions - Complete instruction set reference (PDFs + extracted text) - Architecture documentation and getting-started guide - Test ROM generator with packed (3-byte) and padded (4-byte) formats - r2pipe-based analysis script for radare2 integration
This commit is contained in:
45
analysis/analyze_rom.py
Normal file
45
analysis/analyze_rom.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import r2pipe
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Load local disasm from disassembler dir
|
||||
sys.path.append("../disassembler")
|
||||
from adsp219x_disasm import decode_24
|
||||
|
||||
def analyze_rom(filename):
|
||||
"""
|
||||
Automated ROM analysis using radare2 + Python disassembler.
|
||||
"""
|
||||
r2 = r2pipe.open(filename)
|
||||
r2.cmd("e asm.arch = adsp219x") # Custom arch handled by our script logic
|
||||
r2.cmd("aa") # Basic analysis (will fail but good practice)
|
||||
|
||||
# Iterate over file bytes
|
||||
file_info = json.loads(r2.cmd("iX"))
|
||||
size = file_info[0]["size"]
|
||||
|
||||
print(f"Analyzing {filename} ({size} bytes)...")
|
||||
|
||||
# 3-byte step for ADSP-219x
|
||||
for offset in range(0, size, 3):
|
||||
# Read 3 bytes
|
||||
chunk = r2.cmdj(f"pxj 3 @ {offset}")
|
||||
if not chunk or len(chunk) < 3: break
|
||||
|
||||
opcode = (chunk[0] << 16) | (chunk[1] << 8) | chunk[2]
|
||||
disasm = decode_24(opcode)
|
||||
|
||||
# Set flags, comments, etc., back into r2
|
||||
r2.cmd(f"CC {disasm} @ {offset}")
|
||||
print(f"0x{offset:04X}: {disasm}")
|
||||
|
||||
# Output comment report
|
||||
print("\nAnalysis Summary:\n")
|
||||
print(r2.cmd("CC"))
|
||||
r2.quit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: analyze_rom.py <rom.bin>")
|
||||
else:
|
||||
analyze_rom(sys.argv[1])
|
||||
Reference in New Issue
Block a user