diff --git a/r2plugin/asm_adsp219x.c b/r2plugin/asm_adsp219x.c index 16ea33d..e076daf 100644 --- a/r2plugin/asm_adsp219x.c +++ b/r2plugin/asm_adsp219x.c @@ -219,24 +219,31 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) } /* Constant YOP form: YY=bits12-11, CC=bits7-6, BO=bits5-4. + Only BO=01 and BO=11 are valid encodings. Index = (YY<<2)|CC. BO=01: val = 1<> 11) & 0x3; - ut32 cc = (ins >> 6) & 0x3; ut32 bo = (ins >> 4) & 0x3; - ut32 idx = (yy << 2) | cc; - int32_t val; - if (idx == 15) - val = (bo & 0x2) ? 32767 : -32768; - else if (bo & 0x2) - val = -((int32_t)(1 << idx)) - 1; - else - val = (int32_t)(1 << idx); - op->mnemonic = r_str_newf ("%s%s%s%s = %s(%s, %d)", - cp, cs, sp, dst, f, x, val); - return true; + if (bo == 1 || bo == 3) + { + ut32 yy = (ins >> 11) & 0x3; + ut32 cc_bits = (ins >> 6) & 0x3; + ut32 idx = (yy << 2) | cc_bits; + int32_t val; + if (idx == 15) + val = (bo == 3) ? 32767 : -32768; + else if (bo == 3) + val = -((int32_t)(1 << idx)) - 1; + else + val = (int32_t)(1 << idx); + op->mnemonic = r_str_newf ( + "%s%s%s%s = %s(%s, %d)", + cp, cs, sp, dst, f, x, val); + return true; + } + /* BO=00 or BO=10 with non-zero lower bits: + not a valid Type 9 encoding, fall through. */ } } @@ -710,13 +717,20 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) return true; } - /* Type 32a: DAG reg store + transfer (bits 23-17=0001010, bit11=1) */ - if ((ins >> 17) == 0x0A && ((ins >> 11) & 1)) + /* Type 32a: DAG reg store + register transfer. + bits23-17=0001010, bit15=0, bits12-11=11, bit10=0. + U=bit14, G=bit13, RGP=bits9-8, DAG_REG=bits7-4, + I=bits3-2, M=bits1-0. + Syntax: DM(Ireg1 op Mreg1) = DAGreg, DAGreg = Ireg1 */ + if ((ins >> 17) == 0x0A + && !((ins >> 15) & 1) + && ((ins >> 11) & 0x3) == 0x3 + && !((ins >> 10) & 1)) { ut32 u_bit = (ins >> 14) & 1; ut32 g = (ins >> 13) & 1; ut32 rgp = (ins >> 8) & 0x3; - ut32 dag_reg = (ins >> 4) & 0x7; + ut32 dag_reg = (ins >> 4) & 0xF; ut32 ireg = (ins >> 2) & 0x3; ut32 mreg = ins & 0x3; int base = g ? 4 : 0; diff --git a/r2plugin/asm_adsp219x.so b/r2plugin/asm_adsp219x.so index 8e1ced5..f53f4fe 100755 Binary files a/r2plugin/asm_adsp219x.so and b/r2plugin/asm_adsp219x.so differ