diff --git a/examples/build/shift_sf_test.dsp b/examples/build/shift_sf_test.dsp new file mode 100644 index 0000000..f7bbf73 --- /dev/null +++ b/examples/build/shift_sf_test.dsp @@ -0,0 +1,20 @@ + .section/PM program0; + .global _start; +_start: + si = 0x00FF; + i0 = 0x0100; + m0 = 1; + + /* Type 12: all SF variants with DM read */ + sr = lshift si (hi), mx0 = dm(i0,m0); + sr = lshift si (lo), mx0 = dm(i0,m0); + sr = sr or lshift si (hi), mx0 = dm(i0,m0); + sr = sr or lshift si (lo), mx0 = dm(i0,m0); + sr = ashift si (hi), mx0 = dm(i0,m0); + sr = ashift si (lo), mx0 = dm(i0,m0); + sr = sr or ashift si (hi), mx0 = dm(i0,m0); + sr = sr or ashift si (lo), mx0 = dm(i0,m0); + + nop; +_halt: + jump _halt; diff --git a/examples/build/verify_gaps.elf b/examples/build/verify_gaps.elf deleted file mode 100644 index fbf888c..0000000 Binary files a/examples/build/verify_gaps.elf and /dev/null differ diff --git a/examples/build/verify_gaps.o b/examples/build/verify_gaps.o deleted file mode 100644 index 3b713e9..0000000 Binary files a/examples/build/verify_gaps.o and /dev/null differ diff --git a/r2plugin/TESTING.md b/r2plugin/TESTING.md index 7de4fe4..8032bee 100644 --- a/r2plugin/TESTING.md +++ b/r2plugin/TESTING.md @@ -16,50 +16,37 @@ Structural = implemented from reference docs, no assembler test. | 10 | Conditional jump (13-bit rel) | Verified | isa_test.bin | | 10a | Unconditional jump (16-bit) | Verified | isa_test.bin | | 11 | DO UNTIL (12-bit rel) | Verified | isa_test.bin, fir.bin | -| 12 | Shift + DM/PM | Structural | — | -| 14 | Shift + Dreg move | Structural | — | +| 12 | Shift + DM/PM | Verified | shift_sf_test.dsp, fir | +| 14 | Shift + Dreg move | Verified | verify_gaps.dsp | | 15 | Shift immediate | Verified | isa_test.bin | -| 16 | Conditional shift | Structural | — | +| 16 | Conditional shift | Verified | verify_gaps.dsp | | 17 | Reg = Reg | Verified | isa_test.bin | | 18 | Mode control (ENA/DIS) | Verified | type18_test.dsp | -| 19 | Indirect jump/call | Structural | — | +| 19 | Indirect jump/call | Verified | verify_gaps.dsp | | 20 | RTS/RTI | Verified | isa_test.bin, fir.bin | -| 21 | MODIFY (Ireg += Mreg) | Structural | — | -| 21a | MODIFY (Ireg += Imm8) | Structural | — | +| 21 | MODIFY (Ireg += Mreg) | Verified | verify_gaps.dsp | +| 21a | MODIFY (Ireg += Imm8) | Verified | verify_gaps.dsp | | 22 | DM = Data16 (2-word) | Structural | — | | 22a | PM = Data24 (2-word) | Structural | — | -| 23 | DIVQ | Structural | — | -| 24 | DIVS | Structural | — | +| 23 | DIVQ | Verified | verify_gaps.dsp | +| 24 | DIVS | Verified | verify_gaps.dsp | | 25 | SAT MR/SR | Verified | isa_test.bin | -| 26 | Push/Pop/Flush Cache | Structural | — | -| 29 | DM read/write imm modify | Structural | — | +| 26 | Push/Pop/Flush Cache | Verified | verify_gaps.dsp | +| 29 | DM read/write imm modify | Verified | verify_gaps.dsp | | 30 | NOP | Verified | isa_test.bin | | 31 | IDLE | Structural | — | -| 32 | Any Reg <-> DM/PM (DAG) | Structural | — | +| 32 | Any Reg <-> DM/PM (DAG) | Verified | verify_gaps.dsp | | 32a | DAG reg store + transfer | Structural | — | | 33 | Reg3 = Data12 | Verified | isa_test.bin | -| 34 | IO register read/write | Structural | — | -| 35 | System register read/write | Structural | — | -| 36 | Long jump/call (2-word) | Structural | — | -| 37 | SETINT/CLRINT | Structural | — | +| 34 | IO register read/write | Verified | verify_gaps.dsp | +| 35 | System register read/write | Verified | verify_gaps.dsp | +| 36 | Long jump/call (2-word) | Verified | verify_gaps.dsp | +| 37 | SETINT/CLRINT | Verified | verify_gaps.dsp | -## Priority gaps for assembler verification +## Remaining structural-only types -High (used in real firmware, likely to encounter): -- Type 12: Shift + memory (common in FIR output scaling) -- Type 29: DM immediate modify (common for stack-like access) -- Type 32: Any Reg <-> DM/PM (general register save/restore) -- Type 19: Indirect jump (function pointer dispatch) - -Medium (less common but structurally complex): -- Type 22/22a: 2-word immediate write (initialization code) -- Type 36: Long jump/call (large firmware images) -- Type 32a: DAG store + transfer (DSP loop setup) - -Low (rare or simple): -- Type 16: Conditional shift -- Type 21/21a: MODIFY -- Type 23/24: DIVQ/DIVS -- Type 26: Push/Pop -- Type 34/35: IO/System registers -- Type 37: SETINT/CLRINT +- Type 22/22a: 2-word immediate data write. No open21xx syntax + equivalent found for testing. +- Type 31: IDLE. Trivial encoding, low risk. +- Type 32a: DAG register store with transfer. Tightly constrained + discriminator (bits 15=0, 12-11=11, 10=0), low overlap risk. diff --git a/r2plugin/asm_adsp219x.c b/r2plugin/asm_adsp219x.c index c2366d7..db0b481 100644 --- a/r2plugin/asm_adsp219x.c +++ b/r2plugin/asm_adsp219x.c @@ -445,12 +445,15 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) return true; } - /* Type 12: Shift | DM/PM (bits 23-17 = 0001001) */ + /* Type 12: Shift | DM/PM (bits 23-17 = 0001001) + G=bit16, SF=bits15-12 (4 bits, same as sf_names[]), + D=bit11 (0=read, 1=write), XOP=bits10-8 (xop_shift), + DREG=bits7-4, I=bits3-2, M=bits1-0. */ if ((ins >> 17) == 0x09) { ut32 g = (ins >> 16) & 1; - ut32 sf = (ins >> 13) & 0x7; - ut32 d = (ins >> 12) & 1; + ut32 sf = (ins >> 12) & 0xF; + ut32 d = (ins >> 11) & 1; ut32 xop_i = (ins >> 8) & 0x7; ut32 dreg = (ins >> 4) & 0xF; ut32 ireg = (ins >> 2) & 0x3; diff --git a/r2plugin/asm_adsp219x.so b/r2plugin/asm_adsp219x.so index 0e6365e..883de27 100755 Binary files a/r2plugin/asm_adsp219x.so and b/r2plugin/asm_adsp219x.so differ