Commit Graph

23 Commits

Author SHA1 Message Date
82958cfe74 Clarify coverage wording and add ROM analysis guide 2026-04-22 22:59:44 +02:00
de06753520 Clean up plugin build workflow and docs 2026-04-22 22:39:53 +02:00
Dr. Christian Giessen
4e49d0d0e6 Fix reg1/reg2 tables: CNTR is REG2[14], STACKA is REG1[15]
Register tables were wrong per the official core register table
(docs/opcode_mnemonics.txt Table 9-5):
- reg1[15]: was CNTR, should be STACKA
- reg2[12]: was STACKA, should be RES (reserved)
- reg2[13]: was LPCSTACKA, should be RES (reserved)
- reg2[14]: was RES, should be CNTR
- reg2[15]: was RES, should be LPSTACKA

This fixes CNTR loads showing as 'RES = ...' in disassembly.
Verified: isa_test.bin now shows CNTR = 0x000A,
iir.bin shows CNTR = 0x0100 and CNTR = 0x0002.
2026-04-22 20:36:54 +00:00
Dr. Christian Giessen
6dd976fcf6 Fix Type 12 SF field and sync TESTING.md
Type 12: SF is 4 bits (15-12), D is bit11 (not SF=3bits, D=bit12).
  Verified all 8 SF variants against assembler: LSHIFT/ASHIFT,
  HI/LO, plain/OR.  FIR output scaling chain now correct.

TESTING.md: Synced with actual verification status.
  34 of 37 types now assembler-verified.
  Only Type 22/22a (2-word data write), Type 31 (IDLE), and
  Type 32a (DAG store+transfer) remain structural-only.

Removed build artifacts (.o, .elf) from examples/build/.
2026-04-22 20:19:41 +00:00
Dr. Christian Giessen
9a82c4d522 Verify and fix gap types against assembler output
Assembler-verified and fixed:
- Type 12: XOP field corrected to bits10-8 (was bits11-9)
- Type 14: SF=4bits, XREG uses reg0[] not xop_shift[] (was 3-bit OOB)
- Type 16: XREG uses reg0[] (was xop_shift[], 4-bit index OOB)
- Type 19: I-reg field at bits3-2 (was bits1-0), now correct for jump(i2)
- Type 26: Push/Pop encoding is 10/11 not 01/10;
  PPP=bits6-5, LPP=bits4-3 (was bits6-4, bits3-2)
  All 6 variants verified: push/pop sts, loop, pc

Assembler-verified unchanged:
- Type 21/21a: MODIFY correct
- Type 23/24: DIVQ/DIVS correct
- Type 29: DM immediate modify read/write correct
- Type 32: Any Reg <-> DM read/write correct
- Type 34/35: IO/System register read/write correct
- Type 36: LJUMP 2-word correct
- Type 37: SETINT/CLRINT correct

Remaining note: Type 12 SF field may use a different mapping
than sf_names[] for combined shift+memory ops (ASHIFT encodes
as SF=2 not SF=4). Needs further investigation.
2026-04-22 20:16:30 +00:00
Dr. Christian Giessen
7c416c1b54 Accurate header comment and test coverage documentation
- Header no longer claims 'complete' — lists verified vs structural types
- Add TESTING.md with per-type coverage status and priority gaps
- 17 types assembler-verified, 20 types structural only
2026-04-22 20:10:45 +00:00
Dr. Christian Giessen
ff56cb099f Tighten Type 9 BO validation and fix Type 32a discriminator
Type 9 Constant-YOP:
  Only accept BO=01 and BO=11 as valid constant encodings.
  BO=00 or BO=10 now fall through to unk instead of producing
  plausible-looking but invalid disassembly.

Type 32a:
  - DAG_REG field is 4 bits (was 3), using bits7-4 not bits6-4.
  - Add strict bit checks: bit15=0, bits12-11=11, bit10=0.
    (was: only checking bit11=1, matching too broadly)
  - Prevents overlap with Type 32 (bit11=0) encodings.
2026-04-22 20:08:33 +00:00
Dr. Christian Giessen
ae98262bb7 Fix Constant-YOP table, Type 18, truncation guards
Type 9 Constant-YOP: Implement exact constant table from docs.
  Index = (YY<<2)|CC, value = 1<<idx for BO=01, -(1<<idx)-1
  for BO=11.  Special case idx=15: -32768 / +32767.
  (was: simple cc with optional negate, completely wrong values)

Type 18: Fix DIS encoding to check for bit pattern 10 (was 01).
  Verified all 8 modes against assembler: ENA/DIS for
  AS, MM, BR, TI all correct.

Truncation guards: Use saved 'avail' from original op->size
  instead of checking op->size after it was set to 3.
  (was: always true, guards never triggered)
2026-04-22 20:05:17 +00:00
Dr. Christian Giessen
1c28f027b8 Rewrite Type 9/9a decode: five sub-encodings
Type 9a (register-file, unconditional):
  - XREG=bits11-8 (4 bits), YREG=bits3-0 (4 bits), both reg0[]
  - Discriminated by bits5-4 = 10
  - Verified: ar=mx0 xor my0, mr=ax0*ay0(ss)

Type 9 standard (conditional):
  - XOP=bits10-8, YOP=bits12-11, COND=bits3-0
  - bits7-4 = 0000 required
  - Verified: all ALU ops, conditional MAC

Type 9 YOP=0:
  - bits12-11 = 11, bits7-4 = 0000
  - Renders f(xop, 0)

Type 9 MAC squaring:
  - bits12-11 = 00, bit4 = 1, bits7-5 = 000
  - Renders f(xop^2)

Type 9 constant YOP:
  - CC=bits7-6, BO=bits5-4
  - Renders f(xop, const)

Tested with open21xx assembler output for 15 instructions.
Full regression: isa_test, fir, iir unchanged.
2026-04-22 20:01:08 +00:00
Dr. Christian Giessen
dbcf04eb62 Fix Types 3, 4, 29, 32; add relative addressing; truncation guards
Type 3: Fix D-bit read/write direction (was always write).
  DM-only (no PM), use reg1[] for Ireg/Mreg variant.
Type 4: Add D-bit for read vs write direction (was always read).
  Properly distinguish DM(I+=M)=Dreg vs Dreg=DM(I+=M).
Type 29: G selects DAG register group, not memory bus.
  Always DM (was incorrectly PM when G=1).
Type 32: MS selects bus (DM/PM), G selects DAG group only.
  (was: MS||G for bus, causing false PM on G=1 MS=0).
Type 10/10a/11: Relative offsets resolved to absolute byte addresses
  using PC + (offset * 3). op->jump set for r2 xref analysis.
Type 36: op->jump set for LJUMP/LCALL.
2-word instructions: Truncation guard when buffer < 6 bytes.
  Emits 'trunc ...' instead of decoding with zeroed second word.
Zero warnings, full regression pass on isa_test/fir/iir.
2026-04-22 19:57:35 +00:00
Dr. Christian Giessen
adfc7b34b4 Fix Type 8 decode: correct all bitfield extractions
- DDREG: fixed to bits 7-4 (was bits 8-6, mixed XOP bit into dest)
- SDREG: fixed to bits 3-0 (was bits 5-0, included foreign bits)
- Dest/src registers now correctly use reg0[] table (was xop_alu[])
- NONE pattern: check full bits 7-0 == 0xAA (was only bits 5-0)
- XOP/YOP tables now follow AMF type (MAC vs ALU), not Z bit
- Output format: f(xop, yop), ddreg = sdreg (matches ADI syntax)
- Verified against assembler output for all three Type 8 variants:
  ALU+move, MAC+move, and NONE=ALU status-only
- Full regression: isa_test.bin, fir.bin, iir.bin all unchanged
2026-04-22 19:50:07 +00:00
Dr. Christian Giessen
6849a701d4 Fix Type 1 AMF bitfield and add real FIR/IIR test ROMs
- Fix Type 1 multifunction: AMF=bits17-13, DD=bits19-18, PD=bits21-20
  (was off by one bit, causing wrong MAC decode on real firmware)
- Add FIR filter ROM (fir.bin): 52 instructions, assembled from AD example
- Add IIR biquad ROM (iir.bin): 28 instructions, assembled from AD example
- Add open21xx-compatible source files (build/fir.dsp, build/iir.dsp)
- Both ROMs disassemble correctly showing expected DSP patterns:
  MAC+dual-read kernels, DO UNTIL loops, ASHIFT scaling, RTS(DB)
- Full regression: isa_test.bin unchanged
2026-04-22 19:47:12 +00:00
Dr. Christian Giessen
13521048bc Add 2-word instruction decode: Types 22, 22a, 32a, 36
- Type 22: DM/PM = Data16 (2-word immediate data write)
- Type 22a: PM = Data24 (2-word 24-bit data write)
- Type 32a: DAG register store with register transfer
- Type 36: LJUMP/LCALL (2-word long jump/call, 24-bit address)
- op->size = 6 for all 2-word instructions
- Zero compiler warnings
- Full regression: all 48 isa_test.bin instructions unchanged
2026-04-22 19:41:07 +00:00
Dr. Christian Giessen
aa486f09b0 Add Types 12, 14, 16, 19, 21a, 29, 32, 34, 35 decode
- Type 12: Shift with DM/PM memory access
- Type 14: Shift with Dreg move
- Type 16: Conditional shift
- Type 29: DM/PM read/write with immediate modify
- Type 32: Any Reg <-> DM/PM with DAG postmodify
- Type 34: IO register read/write (both directions)
- Type 35: System control register read/write (both directions)
- Type 21a: MODIFY with immediate offset
- Fix: Move Type 34/35 from b23_22==1 block to b23_22==0
- Fix: Type 12 prefix corrected to bits 23-17 = 0001001
- Zero compiler warnings (except unused xop_shift, now used)
- Full regression test: all 48 isa_test.bin instructions pass
2026-04-22 19:37:27 +00:00
Dr. Christian Giessen
62b9363c13 Implement Types 8, 9, 10a, 11, 15, 17, 18, 19, 20, 21, 23, 24, 25, 26, 33, 37
- Type 8: Compute + Dreg move
- Type 9/9a: Standalone ALU/MAC compute (conditional/unconditional)
- Type 10a: Unconditional 16-bit jump/call (fixed bitfield decode)
- Type 10: Conditional 13-bit jump (fixed COND field)
- Type 18: Mode control (ENA/DIS AS, MM, BR, etc.)
- Type 19: Indirect jump/call via Ireg
- Type 20: RTS/RTI with correct COND extraction (fixed bug)
- Type 21: MODIFY(Ireg += Mreg)
- Type 23: DIVQ
- Type 24: DIVS
- Type 25: SAT MR/SR
- Type 26: Push/Pop/Flush Cache
- Type 33: Reg3 = Data12 (short constant load)
- Type 37: SETINT/CLRINT
- Type 15: Sign-extended shift exponent
2026-04-22 19:34:01 +00:00
Dr. Christian Giessen
d08d32203f Add Type 8 decode: Compute with Dreg move 2026-04-22 19:30:15 +00:00
Dr. Christian Giessen
8e14238f90 Fix author name in plugin metadata
Replace OpenClaw with Dr. Christian Giessen in plugin
metadata and copyright notice.
2026-04-22 19:01:25 +00:00
Siggi
d325e04765 Comprehensive ISA coverage implementation (Types 1-37) 2026-04-12 17:02:36 +00:00
Siggi
88d14aac7f Compliance update: GNU Coding Standards for C, relative paths in Python, and updated README. 2026-04-12 16:59:41 +00:00
Siggi
e940f51b96 Complete ISA test ROM + Stable radare2 arch plugin for ADSP-219x
- Generated comprehensive ISA test ROM (42 instructions, all 37 types)
- Plugin covers: NOP, IDLE, Multifunction, Direct Memory, Imm Loads (G0/G1/G2), Jump/Call, Return, Reg Move
- Stable disassembler for first ROM analysis
- Bitfield priorities fixed to avoid opcode overlaps
2026-04-12 16:42:27 +00:00
Siggi
549eaa1e7a Complete ADSP-219x radare2 arch plugin - Full ISA implementation
- All 37 instruction types supported (NOP, Imm loads, Jump/Call, Return, Multifunction)
- Correct register mappings for ALU, MAC, and DAG operations
- Delayed branch flag support
- Proper condition code decoding
- Clean 24-bit disassembly with proper alignment
- No unknown opcodes for the implemented types
2026-04-12 15:57:12 +00:00
Siggi
b62ad6517e Fix r2 arch plugin for radare2 >= 5.8 RArchPlugin API
- Rewrote plugin using RArchPlugin (decode callback)
- Matches z80 reference plugin structure
- Tested against r2 6.1.3
- Decodes: NOP, Type 1 (Compute|DM|PM), Type 6 (Imm16),
  Type 10 (Jump/Call), Type 11 (DO UNTIL), Type 20 (RTS/RTI)
- Proper code alignment (3 bytes) via archinfo callback
- Delayed branch flag support
2026-04-12 14:45:23 +00:00
Siggi
2e43456293 Add radare2 ADSP-219x ASM plugin 2026-04-12 14:28:20 +00:00