* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* except as coprocessor 10/11 operations
* * Most ARM instructions through ARMv6 are decoded, but some
* of the post-ARMv4 opcodes may not be handled yet
* except as coprocessor 10/11 operations
* * Most ARM instructions through ARMv6 are decoded, but some
* of the post-ARMv4 opcodes may not be handled yet
"EQ", "NE", "CS", "CC", "MI", "PL", "VS", "VC", "HI", "LS", "GE", "LT", "GT", "LE", "", "NV"
};
"EQ", "NE", "CS", "CC", "MI", "PL", "VS", "VC", "HI", "LS", "GE", "LT", "GT", "LE", "", "NV"
};
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tB%s%s 0x%8.8" PRIx32 , address, opcode,
- (L) ? "L" : "", COND(opcode), target_address);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tB%s%s 0x%8.8" PRIx32,
+ address,
+ opcode,
+ (L) ? "L" : "",
+ COND(opcode),
+ target_address);
}
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 "\t0x%8.8" PRIx32
"\t%s%s%s p%i, %x, r%i, r%i, c%i",
}
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 "\t0x%8.8" PRIx32
"\t%s%s%s p%i, %x, r%i, r%i, c%i",
- ? "2" : COND(opcode),
- COND(opcode), cp_num, cp_opcode, Rd, Rn, CRm);
- }
- else /* LDC or STC */
- {
+ ? "2" : COND(opcode),
+ COND(opcode), cp_num, cp_opcode, Rd, Rn, CRm);
+ } else {/* LDC or STC */
snprintf(addressing_mode, 32, "[r%i, #%s%d]",
Rn, U ? "" : "-", offset);
snprintf(addressing_mode, 32, "[r%i, #%s%d]",
Rn, U ? "" : "-", offset);
snprintf(addressing_mode, 32, "[r%i, #%s%d]!",
Rn, U ? "" : "-", offset);
snprintf(addressing_mode, 32, "[r%i, #%s%d]!",
Rn, U ? "" : "-", offset);
snprintf(addressing_mode, 32, "[r%i], #%s%d",
Rn, U ? "" : "-", offset);
snprintf(addressing_mode, 32, "[r%i], #%s%d",
Rn, U ? "" : "-", offset);
uint8_t cp_num, opcode_1, CRd_Rd, CRn, CRm, opcode_2;
cond = ((opcode & 0xf0000000) == 0xf0000000) ? "2" : COND(opcode);
uint8_t cp_num, opcode_1, CRd_Rd, CRn, CRm, opcode_2;
cond = ((opcode & 0xf0000000) == 0xf0000000) ? "2" : COND(opcode);
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s p%i, 0x%2.2x, r%i, c%i, c%i, 0x%2.2x",
- address, opcode, mnemonic, cond,
- cp_num, opcode_1, CRd_Rd, CRn, CRm, opcode_2);
- }
- else /* bit 4 not set -> CDP */
- {
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s p%i, 0x%2.2x, r%i, c%i, c%i, 0x%2.2x",
+ address,
+ opcode,
+ mnemonic,
+ cond,
+ cp_num,
+ opcode_1,
+ CRd_Rd,
+ CRn,
+ CRm,
+ opcode_2);
+ } else {/* bit 4 not set -> CDP */
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s p%i, 0x%2.2x, c%i, c%i, c%i, 0x%2.2x",
- address, opcode, mnemonic, cond,
- cp_num, opcode_1, CRd_Rd, CRn, CRm, opcode_2);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s p%i, 0x%2.2x, c%i, c%i, c%i, 0x%2.2x",
+ address,
+ opcode,
+ mnemonic,
+ cond,
+ cp_num,
+ opcode_1,
+ CRd_Rd,
+ CRn,
+ CRm,
+ opcode_2);
uint32_t offset_12 = (opcode & 0xfff);
if (offset_12)
snprintf(offset, 32, ", #%s0x%" PRIx32 "", (U) ? "" : "-", offset_12);
uint32_t offset_12 = (opcode & 0xfff);
if (offset_12)
snprintf(offset, 32, ", #%s0x%" PRIx32 "", (U) ? "" : "-", offset_12);
snprintf(offset, 32, ", %sr%i, LSL #0x%x", (U) ? "" : "-", Rm, shift_imm);
break;
snprintf(offset, 32, ", %sr%i, LSL #0x%x", (U) ? "" : "-", Rm, shift_imm);
break;
snprintf(offset, 32, ", %sr%i, LSR #0x%x", (U) ? "" : "-", Rm, shift_imm);
break;
snprintf(offset, 32, ", %sr%i, LSR #0x%x", (U) ? "" : "-", Rm, shift_imm);
break;
snprintf(offset, 32, ", %sr%i, ASR #0x%x", (U) ? "" : "-", Rm, shift_imm);
break;
snprintf(offset, 32, ", %sr%i, ASR #0x%x", (U) ? "" : "-", Rm, shift_imm);
break;
snprintf(offset, 32, ", %sr%i, ROR #0x%x", (U) ? "" : "-", Rm, shift_imm);
break;
snprintf(offset, 32, ", %sr%i, ROR #0x%x", (U) ? "" : "-", Rm, shift_imm);
break;
snprintf(offset, 32, ", %sr%i, RRX", (U) ? "" : "-", Rm);
break;
}
}
}
snprintf(offset, 32, ", %sr%i, RRX", (U) ? "" : "-", Rm);
break;
}
}
}
- if (P == 1)
- {
- if (W == 0) /* offset */
- {
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i%s]",
- address, opcode, operation, COND(opcode), suffix,
- Rd, Rn, offset);
+ if (P == 1) {
+ if (W == 0) { /* offset */
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i%s]",
+ address,
+ opcode,
+ operation,
+ COND(opcode),
+ suffix,
+ Rd,
+ Rn,
+ offset);
- }
- else /* pre-indexed */
- {
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i%s]!",
- address, opcode, operation, COND(opcode), suffix,
- Rd, Rn, offset);
+ } else {/* pre-indexed */
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i%s]!",
+ address,
+ opcode,
+ operation,
+ COND(opcode),
+ suffix,
+ Rd,
+ Rn,
+ offset);
- }
- else /* post-indexed */
- {
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i]%s",
- address, opcode, operation, COND(opcode), suffix,
- Rd, Rn, offset);
+ } else {/* post-indexed */
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i]%s",
+ address,
+ opcode,
+ operation,
+ COND(opcode),
+ suffix,
+ Rd,
+ Rn,
+ offset);
}
sprintf(cp, "%s%s%s\tr%d, r%d, r%d", prefix, op, COND(opcode),
}
sprintf(cp, "%s%s%s\tr%d, r%d, r%d", prefix, op, COND(opcode),
- type, COND(opcode),
- (int) (opcode >> 12) & 0xf,
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf,
- shift, imm);
+ type, COND(opcode),
+ (int) (opcode >> 12) & 0xf,
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf,
+ shift, imm);
- (opcode & (1 << 22)) ? 'U' : 'S',
- COND(opcode),
- (int) (opcode >> 12) & 0xf,
- (int) (opcode >> 16) & 0x1f,
- (int) (opcode >> 0) & 0xf,
- shift, imm);
+ (opcode & (1 << 22)) ? 'U' : 'S',
+ COND(opcode),
+ (int) (opcode >> 12) & 0xf,
+ (int) (opcode >> 16) & 0x1f,
+ (int) (opcode >> 0) & 0xf,
+ shift, imm);
- (opcode & (1 << 6)) ? 'S' : 'A',
- (opcode & (1 << 5)) ? "X" : "",
- COND(opcode),
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf,
- (int) (opcode >> 8) & 0xf,
- rn);
+ (opcode & (1 << 6)) ? 'S' : 'A',
+ (opcode & (1 << 5)) ? "X" : "",
+ COND(opcode),
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf,
+ (int) (opcode >> 8) & 0xf,
+ rn);
+ (opcode & (1 << 6)) ? 'S' : 'A',
+ (opcode & (1 << 5)) ? "X" : "",
+ COND(opcode),
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf,
+ (int) (opcode >> 8) & 0xf);
+ return ERROR_OK;
+ }
+ if ((opcode & 0x01f00000) == 0x01400000) {
+ sprintf(cp, "SML%cLD%s%s\tr%d, r%d, r%d, r%d",
(int) (opcode >> 16) & 0xf,
(int) (opcode >> 0) & 0xf,
(int) (opcode >> 8) & 0xf);
return ERROR_OK;
}
(int) (opcode >> 16) & 0xf,
(int) (opcode >> 0) & 0xf,
(int) (opcode >> 8) & 0xf);
return ERROR_OK;
}
- if ((opcode & 0x01f00000) == 0x01400000) {
- sprintf(cp, "SML%cLD%s%s\tr%d, r%d, r%d, r%d",
- (opcode & (1 << 6)) ? 'S' : 'A',
- (opcode & (1 << 5)) ? "X" : "",
- COND(opcode),
- (int) (opcode >> 12) & 0xf,
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf,
- (int) (opcode >> 8) & 0xf);
- return ERROR_OK;
- }
- (opcode & (1 << 6)) ? 'S' : 'A',
- (opcode & (1 << 5)) ? "R" : "",
- COND(opcode),
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf,
- (int) (opcode >> 8) & 0xf,
- rn);
+ (opcode & (1 << 6)) ? 'S' : 'A',
+ (opcode & (1 << 5)) ? "R" : "",
+ COND(opcode),
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf,
+ (int) (opcode >> 8) & 0xf,
+ rn);
- (opcode & (1 << 5)) ? "R" : "",
- COND(opcode),
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf,
- (int) (opcode >> 8) & 0xf);
+ (opcode & (1 << 5)) ? "R" : "",
+ COND(opcode),
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf,
+ (int) (opcode >> 8) & 0xf);
- case 0x00a00030:
- case 0x00e00030:
- /* parallel halfword saturate */
- sprintf(cp, "%cSAT16%s\tr%d, #%d, r%d",
- (opcode & (1 << 22)) ? 'U' : 'S',
- COND(opcode),
- (int) (opcode >> 12) & 0xf,
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf);
- return ERROR_OK;
- case 0x00b00030:
- mnemonic = "REV";
- break;
- case 0x00b000b0:
- mnemonic = "REV16";
- break;
- case 0x00f000b0:
- mnemonic = "REVSH";
- break;
- case 0x008000b0:
- /* select bytes */
- sprintf(cp, "SEL%s\tr%d, r%d, r%d", COND(opcode),
- (int) (opcode >> 12) & 0xf,
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf);
- return ERROR_OK;
- case 0x01800010:
- /* unsigned sum of absolute differences */
- if (((opcode >> 12) & 0xf) == 0xf)
- sprintf(cp, "USAD8%s\tr%d, r%d, r%d", COND(opcode),
+ case 0x00a00030:
+ case 0x00e00030:
+ /* parallel halfword saturate */
+ sprintf(cp, "%cSAT16%s\tr%d, #%d, r%d",
+ (opcode & (1 << 22)) ? 'U' : 'S',
+ COND(opcode),
+ (int) (opcode >> 12) & 0xf,
- (int) (opcode >> 0) & 0xf,
- (int) (opcode >> 8) & 0xf);
- else
- sprintf(cp, "USADA8%s\tr%d, r%d, r%d, r%d", COND(opcode),
+ (int) (opcode >> 0) & 0xf);
+ return ERROR_OK;
+ case 0x00b00030:
+ mnemonic = "REV";
+ break;
+ case 0x00b000b0:
+ mnemonic = "REV16";
+ break;
+ case 0x00f000b0:
+ mnemonic = "REVSH";
+ break;
+ case 0x008000b0:
+ /* select bytes */
+ sprintf(cp, "SEL%s\tr%d, r%d, r%d", COND(opcode),
+ (int) (opcode >> 12) & 0xf,
- (int) (opcode >> 0) & 0xf,
- (int) (opcode >> 8) & 0xf,
- (int) (opcode >> 12) & 0xf);
- return ERROR_OK;
+ (int) (opcode >> 0) & 0xf);
+ return ERROR_OK;
+ case 0x01800010:
+ /* unsigned sum of absolute differences */
+ if (((opcode >> 12) & 0xf) == 0xf)
+ sprintf(cp, "USAD8%s\tr%d, r%d, r%d", COND(opcode),
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf,
+ (int) (opcode >> 8) & 0xf);
+ else
+ sprintf(cp, "USADA8%s\tr%d, r%d, r%d, r%d", COND(opcode),
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf,
+ (int) (opcode >> 8) & 0xf,
+ (int) (opcode >> 12) & 0xf);
+ return ERROR_OK;
{
uint8_t P, U, I, W, L, S, H;
uint8_t Rn, Rd;
{
uint8_t P, U, I, W, L, S, H;
uint8_t Rn, Rd;
uint32_t offset_8 = ((opcode & 0xf00) >> 4) | (opcode & 0xf);
snprintf(offset, 32, "#%s0x%" PRIx32 "", (U) ? "" : "-", offset_8);
instruction->info.load_store.offset_mode = 0;
instruction->info.load_store.offset.offset = offset_8;
uint32_t offset_8 = ((opcode & 0xf00) >> 4) | (opcode & 0xf);
snprintf(offset, 32, "#%s0x%" PRIx32 "", (U) ? "" : "-", offset_8);
instruction->info.load_store.offset_mode = 0;
instruction->info.load_store.offset.offset = offset_8;
- if (P == 1)
- {
- if (W == 0) /* offset */
- {
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i, %s]",
- address, opcode, operation, COND(opcode), suffix,
- Rd, Rn, offset);
+ if (P == 1) {
+ if (W == 0) { /* offset */
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i, %s]",
+ address,
+ opcode,
+ operation,
+ COND(opcode),
+ suffix,
+ Rd,
+ Rn,
+ offset);
- }
- else /* pre-indexed */
- {
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i, %s]!",
- address, opcode, operation, COND(opcode), suffix,
- Rd, Rn, offset);
+ } else {/* pre-indexed */
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i, %s]!",
+ address,
+ opcode,
+ operation,
+ COND(opcode),
+ suffix,
+ Rd,
+ Rn,
+ offset);
- }
- else /* post-indexed */
- {
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i], %s",
- address, opcode, operation, COND(opcode), suffix,
- Rd, Rn, offset);
+ } else {/* post-indexed */
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, [r%i], %s",
+ address,
+ opcode,
+ operation,
+ COND(opcode),
+ suffix,
+ Rd,
+ Rn,
+ offset);
- reg_list_p += snprintf(reg_list_p, (reg_list + 69 - reg_list_p), "r%i", i);
- }
- else
- {
- reg_list_p += snprintf(reg_list_p, (reg_list + 69 - reg_list_p), ", r%i", i);
- }
+ reg_list_p += snprintf(reg_list_p,
+ (reg_list + 69 - reg_list_p),
+ "r%i",
+ i);
+ } else
+ reg_list_p += snprintf(reg_list_p,
+ (reg_list + 69 - reg_list_p),
+ ", r%i",
+ i);
}
}
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 "\t0x%8.8" PRIx32
"\t%s%s%s r%i%s, {%s}%s",
}
}
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 "\t0x%8.8" PRIx32
"\t%s%s%s r%i%s, {%s}%s",
- address, opcode,
- mnemonic, addressing_mode, COND(opcode),
- Rn, (W) ? "!" : "", reg_list, (S) ? "^" : "");
+ address, opcode,
+ mnemonic, addressing_mode, COND(opcode),
+ Rn, (W) ? "!" : "", reg_list, (S) ? "^" : "");
uint8_t Rm, Rs, Rn, Rd, S;
Rm = opcode & 0xf;
Rs = (opcode & 0xf00) >> 8;
uint8_t Rm, Rs, Rn, Rd, S;
Rm = opcode & 0xf;
Rs = (opcode & 0xf00) >> 8;
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMLA%s%s r%i, r%i, r%i, r%i",
- address, opcode, COND(opcode), (S) ? "S" : "", Rd, Rm, Rs, Rn);
- }
- else
- {
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMLA%s%s r%i, r%i, r%i, r%i",
+ address,
+ opcode,
+ COND(opcode),
+ (S) ? "S" : "",
+ Rd,
+ Rm,
+ Rs,
+ Rn);
+ } else {
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMUL%s%s r%i, r%i, r%i",
- address, opcode, COND(opcode), (S) ? "S" : "", Rd, Rm, Rs);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMUL%s%s r%i, r%i, r%i",
+ address,
+ opcode,
+ COND(opcode),
+ (S) ? "S" : "",
+ Rd,
+ Rm,
+ Rs);
uint8_t Rm, Rs, RdHi, RdLow, S;
Rm = opcode & 0xf;
Rs = (opcode & 0xf00) >> 8;
uint8_t Rm, Rs, RdHi, RdLow, S;
Rm = opcode & 0xf;
Rs = (opcode & 0xf00) >> 8;
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, r%i, r%i, r%i",
- address, opcode, mnemonic, COND(opcode), (S) ? "S" : "",
- RdLow, RdHi, Rm, Rs);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, r%i, r%i, r%i",
+ address,
+ opcode,
+ mnemonic,
+ COND(opcode),
+ (S) ? "S" : "",
+ RdLow,
+ RdHi,
+ Rm,
+ Rs);
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s r%i, r%i, [r%i]",
- address, opcode, (opcode & 0x00400000) ? "SWPB" : "SWP", COND(opcode), Rd, Rm, Rn);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s r%i, r%i, [r%i]",
+ address,
+ opcode,
+ (opcode & 0x00400000) ? "SWPB" : "SWP",
+ COND(opcode),
+ Rd,
+ Rm,
+ Rn);
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMSR%s %s_%s%s%s%s, 0x%8.8" PRIx32 ,
- address, opcode, COND(opcode), PSR,
- (opcode & 0x10000) ? "c" : "",
- (opcode & 0x20000) ? "x" : "",
- (opcode & 0x40000) ? "s" : "",
- (opcode & 0x80000) ? "f" : "",
- ror(immediate, (rotate * 2))
-);
- }
- else /* register variant */
- {
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMSR%s %s_%s%s%s%s, 0x%8.8" PRIx32,
+ address,
+ opcode,
+ COND(opcode),
+ PSR,
+ (opcode & 0x10000) ? "c" : "",
+ (opcode & 0x20000) ? "x" : "",
+ (opcode & 0x40000) ? "s" : "",
+ (opcode & 0x80000) ? "f" : "",
+ ror(immediate, (rotate * 2))
+ );
+ } else {/* register variant */
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMSR%s %s_%s%s%s%s, r%i",
- address, opcode, COND(opcode), PSR,
- (opcode & 0x10000) ? "c" : "",
- (opcode & 0x20000) ? "x" : "",
- (opcode & 0x40000) ? "s" : "",
- (opcode & 0x80000) ? "f" : "",
- Rm
-);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMSR%s %s_%s%s%s%s, r%i",
+ address,
+ opcode,
+ COND(opcode),
+ PSR,
+ (opcode & 0x10000) ? "c" : "",
+ (opcode & 0x20000) ? "x" : "",
+ (opcode & 0x40000) ? "s" : "",
+ (opcode & 0x80000) ? "f" : "",
+ Rm
+ );
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMRS%s r%i, %s",
- address, opcode, COND(opcode), Rd, PSR);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tMRS%s r%i, %s",
+ address,
+ opcode,
+ COND(opcode),
+ Rd,
+ PSR);
uint8_t Rm;
instruction->type = ARM_BX;
Rm = opcode & 0xf;
snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tBX%s r%i",
uint8_t Rm;
instruction->type = ARM_BX;
Rm = opcode & 0xf;
snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tBX%s r%i",
uint8_t Rm;
instruction->type = ARM_BX;
Rm = opcode & 0xf;
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tBXJ%s r%i",
uint8_t Rm;
instruction->type = ARM_BX;
Rm = opcode & 0xf;
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tBXJ%s r%i",
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tCLZ%s r%i, r%i",
- address, opcode, COND(opcode), Rd, Rm);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tCLZ%s r%i, r%i",
+ address,
+ opcode,
+ COND(opcode),
+ Rd,
+ Rm);
uint8_t Rm;
instruction->type = ARM_BLX;
Rm = opcode & 0xf;
snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tBLX%s r%i",
uint8_t Rm;
instruction->type = ARM_BLX;
Rm = opcode & 0xf;
snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tBLX%s r%i",
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s r%i, r%i, r%i",
- address, opcode, mnemonic, COND(opcode), Rd, Rm, Rn);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s r%i, r%i, r%i",
+ address,
+ opcode,
+ mnemonic,
+ COND(opcode),
+ Rd,
+ Rm,
+ Rn);
- /* Software breakpoints */
- if ((opcode & 0x0000000f0) == 0x00000070)
- {
- uint32_t immediate;
- instruction->type = ARM_BKPT;
- immediate = ((opcode & 0x000fff00) >> 4) | (opcode & 0xf);
+ /* exception return */
+ if ((opcode & 0x0000000f0) == 0x00000060) {
+ if (((opcode & 0x600000) >> 21) == 3)
+ instruction->type = ARM_ERET;
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tERET",
+ address,
+ opcode);
+ }
+
+ /* exception generate instructions */
+ if ((opcode & 0x0000000f0) == 0x00000070) {
+ uint32_t immediate = 0;
+ char *mnemonic = NULL;
+
+ switch ((opcode & 0x600000) >> 21) {
+ case 0x1:
+ instruction->type = ARM_BKPT;
+ mnemonic = "BRKT";
+ immediate = ((opcode & 0x000fff00) >> 4) | (opcode & 0xf);
+ break;
+ case 0x2:
+ instruction->type = ARM_HVC;
+ mnemonic = "HVC";
+ immediate = ((opcode & 0x000fff00) >> 4) | (opcode & 0xf);
+ break;
+ case 0x3:
+ instruction->type = ARM_SMC;
+ mnemonic = "SMC";
+ immediate = (opcode & 0xf);
+ break;
+ }
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tBKPT 0x%4.4" PRIx32 "",
- address, opcode, immediate);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s 0x%4.4" PRIx32 "",
+ address,
+ opcode,
+ mnemonic,
+ immediate);
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMLA%s%s%s r%i, r%i, r%i, r%i",
- address, opcode, (x) ? "T" : "B", (y) ? "T" : "B", COND(opcode),
- Rd, Rm, Rs, Rn);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMLA%s%s%s r%i, r%i, r%i, r%i",
+ address,
+ opcode,
+ (x) ? "T" : "B",
+ (y) ? "T" : "B",
+ COND(opcode),
+ Rd,
+ Rm,
+ Rs,
+ Rn);
uint8_t RdLow, RdHi, Rm, Rs;
instruction->type = ARM_SMLAxy;
RdHi = (opcode & 0xf0000) >> 16;
uint8_t RdLow, RdHi, Rm, Rs;
instruction->type = ARM_SMLAxy;
RdHi = (opcode & 0xf0000) >> 16;
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMLA%s%s%s r%i, r%i, r%i, r%i",
- address, opcode, (x) ? "T" : "B", (y) ? "T" : "B", COND(opcode),
- RdLow, RdHi, Rm, Rs);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMLA%s%s%s r%i, r%i, r%i, r%i",
+ address,
+ opcode,
+ (x) ? "T" : "B",
+ (y) ? "T" : "B",
+ COND(opcode),
+ RdLow,
+ RdHi,
+ Rm,
+ Rs);
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMLAW%s%s r%i, r%i, r%i, r%i",
- address, opcode, (y) ? "T" : "B", COND(opcode),
- Rd, Rm, Rs, Rn);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMLAW%s%s r%i, r%i, r%i, r%i",
+ address,
+ opcode,
+ (y) ? "T" : "B",
+ COND(opcode),
+ Rd,
+ Rm,
+ Rs,
+ Rn);
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMULW%s%s%s r%i, r%i, r%i",
- address, opcode, (x) ? "T" : "B", (y) ? "T" : "B", COND(opcode),
- Rd, Rm, Rs);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMULW%s%s%s r%i, r%i, r%i",
+ address,
+ opcode,
+ (x) ? "T" : "B",
+ (y) ? "T" : "B",
+ COND(opcode),
+ Rd,
+ Rm,
+ Rs);
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMULW%s%s r%i, r%i, r%i",
- address, opcode, (y) ? "T" : "B", COND(opcode),
- Rd, Rm, Rs);
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMULW%s%s r%i, r%i, r%i",
+ address,
+ opcode,
+ (y) ? "T" : "B",
+ COND(opcode),
+ Rd,
+ Rm,
+ Rs);
- }
- else
- {
- if (shift == 0x0) /* LSL */
- {
- snprintf(shifter_operand, 32, "r%i, LSL #0x%x", Rm, shift_imm);
- }
- else if (shift == 0x1) /* LSR */
- {
- snprintf(shifter_operand, 32, "r%i, LSR #0x%x", Rm, shift_imm);
- }
- else if (shift == 0x2) /* ASR */
- {
- snprintf(shifter_operand, 32, "r%i, ASR #0x%x", Rm, shift_imm);
- }
- else if (shift == 0x3) /* ROR */
- {
- snprintf(shifter_operand, 32, "r%i, ROR #0x%x", Rm, shift_imm);
- }
- else if (shift == 0x4) /* RRX */
- {
+ else {
+ if (shift == 0x0) /* LSL */
+ snprintf(shifter_operand,
+ 32,
+ "r%i, LSL #0x%x",
+ Rm,
+ shift_imm);
+ else if (shift == 0x1) /* LSR */
+ snprintf(shifter_operand,
+ 32,
+ "r%i, LSR #0x%x",
+ Rm,
+ shift_imm);
+ else if (shift == 0x2) /* ASR */
+ snprintf(shifter_operand,
+ 32,
+ "r%i, ASR #0x%x",
+ Rm,
+ shift_imm);
+ else if (shift == 0x3) /* ROR */
+ snprintf(shifter_operand,
+ 32,
+ "r%i, ROR #0x%x",
+ Rm,
+ shift_imm);
+ else if (shift == 0x4) /* RRX */
- if ((op < 0x8) || (op == 0xc) || (op == 0xe)) /* <opcode3>{<cond>}{S} <Rd>, <Rn>, <shifter_operand> */
- {
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, r%i, %s",
- address, opcode, mnemonic, COND(opcode),
- (S) ? "S" : "", Rd, Rn, shifter_operand);
- }
- else if ((op == 0xd) || (op == 0xf)) /* <opcode1>{<cond>}{S} <Rd>, <shifter_operand> */
- {
- if (opcode == 0xe1a00000) /* print MOV r0,r0 as NOP */
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tNOP",address, opcode);
+ if ((op < 0x8) || (op == 0xc) || (op == 0xe)) { /* <opcode3>{<cond>}{S} <Rd>, <Rn>,
+ *<shifter_operand> */
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, r%i, %s",
+ address,
+ opcode,
+ mnemonic,
+ COND(opcode),
+ (S) ? "S" : "",
+ Rd,
+ Rn,
+ shifter_operand);
+ } else if ((op == 0xd) || (op == 0xf)) { /* <opcode1>{<cond>}{S} <Rd>,
+ *<shifter_operand> */
+ if (opcode == 0xe1a00000) /* print MOV r0,r0 as NOP */
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tNOP",
+ address,
+ opcode);
- snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, %s",
- address, opcode, mnemonic, COND(opcode),
- (S) ? "S" : "", Rd, shifter_operand);
- }
- else /* <opcode2>{<cond>} <Rn>, <shifter_operand> */
- {
+ snprintf(instruction->text,
+ 128,
+ "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\t%s%s%s r%i, %s",
+ address,
+ opcode,
+ mnemonic,
+ COND(opcode),
+ (S) ? "S" : "",
+ Rd,
+ shifter_operand);
+ } else {/* <opcode2>{<cond>} <Rn>, <shifter_operand> */
/* Undefined instruction (or ARMv5E cache preload PLD) */
if ((opcode & 0x08000000) == 0x00000000)
return evaluate_pld(opcode, address, instruction);
/* Undefined instruction (or ARMv5E cache preload PLD) */
if ((opcode & 0x08000000) == 0x00000000)
return evaluate_pld(opcode, address, instruction);
/* Multiplies, extra load/stores */
if ((opcode & 0x00000090) == 0x00000090)
return evaluate_mul_and_extra_ld_st(opcode, address, instruction);
/* Multiplies, extra load/stores */
if ((opcode & 0x00000090) == 0x00000090)
return evaluate_mul_and_extra_ld_st(opcode, address, instruction);
/* Load/store immediate offset */
return evaluate_load_store(opcode, address, instruction);
}
/* catch opcodes with [27:25] = b011 */
/* Load/store immediate offset */
return evaluate_load_store(opcode, address, instruction);
}
/* catch opcodes with [27:25] = b011 */
/* Load/store register offset */
if ((opcode & 0x00000010) == 0x00000000)
return evaluate_load_store(opcode, address, instruction);
/* Load/store register offset */
if ((opcode & 0x00000010) == 0x00000000)
return evaluate_load_store(opcode, address, instruction);
/* Load/store multiple */
return evaluate_ldm_stm(opcode, address, instruction);
}
/* catch opcodes with [27:25] = b101 */
/* Load/store multiple */
return evaluate_ldm_stm(opcode, address, instruction);
}
/* catch opcodes with [27:25] = b101 */
/* Branch and branch with link */
return evaluate_b_bl(opcode, address, instruction);
}
/* catch opcodes with [27:25] = b110 */
/* Branch and branch with link */
return evaluate_b_bl(opcode, address, instruction);
}
/* catch opcodes with [27:25] = b110 */
/* Coprocessor load/store and double register transfers */
return evaluate_ldc_stc_mcrr_mrrc(opcode, address, instruction);
}
/* catch opcodes with [27:25] = b111 */
/* Coprocessor load/store and double register transfers */
return evaluate_ldc_stc_mcrr_mrrc(opcode, address, instruction);
}
/* catch opcodes with [27:25] = b111 */
- "0x%8.8" PRIx32 " 0x%4.4x \t%s\tr%i, r%i, #%d",
- address, opcode, mnemonic, Rd, Rn, Rm_imm);
- }
- else
- {
- instruction->info.data_proc.variant = 1; /*immediate shift*/
+ "0x%8.8" PRIx32 " 0x%4.4x \t%s\tr%i, r%i, #%d",
+ address, opcode, mnemonic, Rd, Rn, Rm_imm);
+ } else {
+ instruction->info.data_proc.variant = 1;/*immediate shift*/
- "0x%8.8" PRIx32 " 0x%4.4x \t%s\tr%i, r%i, r%i",
- address, opcode, mnemonic, Rd, Rn, Rm_imm);
+ "0x%8.8" PRIx32 " 0x%4.4x \t%s\tr%i, r%i, r%i",
+ address, opcode, mnemonic, Rd, Rn, Rm_imm);
instruction->info.data_proc.shifter_operand.immediate_shift.Rm = Rm;
instruction->info.data_proc.shifter_operand.immediate_shift.shift_imm = imm;
snprintf(instruction->text, 128,
instruction->info.data_proc.shifter_operand.immediate_shift.Rm = Rm;
instruction->info.data_proc.shifter_operand.immediate_shift.shift_imm = imm;
snprintf(instruction->text, 128,
address, opcode, mnemonic, Rd, Rm, imm);
return ERROR_OK;
}
static int evaluate_data_proc_imm_thumb(uint16_t opcode,
address, opcode, mnemonic, Rd, Rm, imm);
return ERROR_OK;
}
static int evaluate_data_proc_imm_thumb(uint16_t opcode,
instruction->info.data_proc.shifter_operand.register_shift.shift = 0;
instruction->info.data_proc.shifter_operand.register_shift.Rm = Rd;
instruction->info.data_proc.shifter_operand.register_shift.Rs = Rm;
instruction->info.data_proc.shifter_operand.register_shift.shift = 0;
instruction->info.data_proc.shifter_operand.register_shift.Rm = Rd;
instruction->info.data_proc.shifter_operand.register_shift.Rs = Rm;
instruction->info.data_proc.shifter_operand.register_shift.shift = 1;
instruction->info.data_proc.shifter_operand.register_shift.Rm = Rd;
instruction->info.data_proc.shifter_operand.register_shift.Rs = Rm;
instruction->info.data_proc.shifter_operand.register_shift.shift = 1;
instruction->info.data_proc.shifter_operand.register_shift.Rm = Rd;
instruction->info.data_proc.shifter_operand.register_shift.Rs = Rm;
instruction->info.data_proc.shifter_operand.register_shift.shift = 2;
instruction->info.data_proc.shifter_operand.register_shift.Rm = Rd;
instruction->info.data_proc.shifter_operand.register_shift.Rs = Rm;
instruction->info.data_proc.shifter_operand.register_shift.shift = 2;
instruction->info.data_proc.shifter_operand.register_shift.Rm = Rd;
instruction->info.data_proc.shifter_operand.register_shift.Rs = Rm;
instruction->info.data_proc.shifter_operand.register_shift.shift = 3;
instruction->info.data_proc.shifter_operand.register_shift.Rm = Rd;
instruction->info.data_proc.shifter_operand.register_shift.Rs = Rm;
instruction->info.data_proc.shifter_operand.register_shift.shift = 3;
instruction->info.data_proc.shifter_operand.register_shift.Rm = Rd;
instruction->info.data_proc.shifter_operand.register_shift.Rs = Rm;
else
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 " 0x%4.4x \t%s\tr%i, r%i",
else
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 " 0x%4.4x \t%s\tr%i, r%i",
- "0x%8.8" PRIx32 " 0x%4.4x \t"
- "LDR\tr%i, [pc, #%#" PRIx32 "]\t; %#8.8" PRIx32,
- address, opcode, Rd, immediate,
- thumb_alignpc4(address) + immediate);
+ "0x%8.8" PRIx32 " 0x%4.4x \t"
+ "LDR\tr%i, [pc, #%#" PRIx32 "]\t; %#8.8" PRIx32,
+ address, opcode, Rd, immediate,
+ thumb_alignpc4(address) + immediate);
- "0x%8.8" PRIx32 " 0x%4.4x \t%s%c\tr%i, [r%i, #%#" PRIx32 "]",
- address, opcode, mnemonic, suffix, Rd, Rn, offset << shift);
+ "0x%8.8" PRIx32 " 0x%4.4x \t%s%c\tr%i, [r%i, #%#" PRIx32 "]",
+ address, opcode, mnemonic, suffix, Rd, Rn, offset << shift);
- "0x%8.8" PRIx32 " 0x%4.4x \t%s\tr%i, [SP, #%#" PRIx32 "]",
- address, opcode, mnemonic, Rd, offset*4);
+ "0x%8.8" PRIx32 " 0x%4.4x \t%s\tr%i, [SP, #%#" PRIx32 "]",
+ address, opcode, mnemonic, Rd, offset*4);
- "0x%8.8" PRIx32 " 0x%4.4x \tADD\tr%i, %s, #%#" PRIx32,
- address, opcode, Rd, reg_name, imm * 4);
+ "0x%8.8" PRIx32 " 0x%4.4x \tADD\tr%i, %s, #%#" PRIx32,
+ address, opcode, Rd, reg_name, imm * 4);
"0x%8.8" PRIx32 " 0x%4.4x \t%s\tSP, #%#" PRIx32,
address, opcode, mnemonic, imm*4);
"0x%8.8" PRIx32 " 0x%4.4x \t%s\tSP, #%#" PRIx32,
address, opcode, mnemonic, imm*4);
instruction->type = ARM_STM;
mnemonic = "STM";
}
snprintf(ptr_name, sizeof ptr_name, "r%i%s, ", Rn, wback);
instruction->type = ARM_STM;
mnemonic = "STM";
}
snprintf(ptr_name, sizeof ptr_name, "r%i%s, ", Rn, wback);
instruction->type = ARM_SWI;
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 " 0x%4.4x \tSVC\t%#2.2" PRIx32,
address, opcode, offset);
return ERROR_OK;
instruction->type = ARM_SWI;
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 " 0x%4.4x \tSVC\t%#2.2" PRIx32,
address, opcode, offset);
return ERROR_OK;
}
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 " 0x%4.4x \tREV%s\tr%d, r%d",
}
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 " 0x%4.4x \tREV%s\tr%d, r%d",
/* add/substract register or immediate */
if ((opcode & 0x1800) == 0x1800)
return evaluate_add_sub_thumb(opcode, address, instruction);
/* add/substract register or immediate */
if ((opcode & 0x1800) == 0x1800)
return evaluate_add_sub_thumb(opcode, address, instruction);
- case 0x0:
- return evaluate_adjust_stack_thumb(opcode, address, instruction);
- case 0x1:
- case 0x3:
- case 0x9:
- case 0xb:
- return evaluate_cb_thumb(opcode, address, instruction);
- case 0x2:
- return evaluate_extend_thumb(opcode, address, instruction);
- case 0x4:
- case 0x5:
- case 0xc:
- case 0xd:
- return evaluate_load_store_multiple_thumb(opcode, address,
- instruction);
- case 0x6:
- return evaluate_cps_thumb(opcode, address, instruction);
- case 0xa:
- if ((opcode & 0x00c0) == 0x0080)
- break;
- return evaluate_byterev_thumb(opcode, address, instruction);
- case 0xe:
- return evaluate_breakpoint_thumb(opcode, address, instruction);
- case 0xf:
- if (opcode & 0x000f)
- return evaluate_ifthen_thumb(opcode, address,
- instruction);
- else
- return evaluate_hint_thumb(opcode, address,
- instruction);
+ case 0x0:
+ return evaluate_adjust_stack_thumb(opcode, address, instruction);
+ case 0x1:
+ case 0x3:
+ case 0x9:
+ case 0xb:
+ return evaluate_cb_thumb(opcode, address, instruction);
+ case 0x2:
+ return evaluate_extend_thumb(opcode, address, instruction);
+ case 0x4:
+ case 0x5:
+ case 0xc:
+ case 0xd:
+ return evaluate_load_store_multiple_thumb(opcode, address,
+ instruction);
+ case 0x6:
+ return evaluate_cps_thumb(opcode, address, instruction);
+ case 0xa:
+ if ((opcode & 0x00c0) == 0x0080)
+ break;
+ return evaluate_byterev_thumb(opcode, address, instruction);
+ case 0xe:
+ return evaluate_breakpoint_thumb(opcode, address, instruction);
+ case 0xf:
+ if (opcode & 0x000f)
+ return evaluate_ifthen_thumb(opcode, address,
+ instruction);
+ else
+ return evaluate_hint_thumb(opcode, address,
+ instruction);
instruction->type = ARM_UNDEFINED_INSTRUCTION;
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 " 0x%8.8x\t"
"UNDEFINED INSTRUCTION",
address, opcode);
return ERROR_OK;
instruction->type = ARM_UNDEFINED_INSTRUCTION;
snprintf(instruction->text, 128,
"0x%8.8" PRIx32 " 0x%8.8x\t"
"UNDEFINED INSTRUCTION",
address, opcode);
return ERROR_OK;
- case 0x1:
- case 0x5:
- return t2ev_b_bl(opcode, address, instruction, cp);
- case 0x4:
- goto undef;
- case 0:
- if (((opcode >> 23) & 0x07) != 0x07)
- return t2ev_cond_b(opcode, address, instruction, cp);
- if (opcode & (1 << 26))
+ case 0x1:
+ case 0x5:
+ return t2ev_b_bl(opcode, address, instruction, cp);
+ case 0x4:
- return ERROR_OK;
- case 0x3a:
- return t2ev_hint(opcode, address, instruction, cp);
- case 0x3b:
- return t2ev_misc(opcode, address, instruction, cp);
- case 0x3c:
- sprintf(cp, "BXJ\tr%d", (int) (opcode >> 16) & 0x0f);
- return ERROR_OK;
- case 0x3e:
- case 0x3f:
- sprintf(cp, "MRS\tr%d, %s", (int) (opcode >> 8) & 0x0f,
+ return ERROR_OK;
+ case 0x3a:
+ return t2ev_hint(opcode, address, instruction, cp);
+ case 0x3b:
+ return t2ev_misc(opcode, address, instruction, cp);
+ case 0x3c:
+ sprintf(cp, "BXJ\tr%d", (int) (opcode >> 16) & 0x0f);
+ return ERROR_OK;
+ case 0x3e:
+ case 0x3f:
+ sprintf(cp, "MRS\tr%d, %s", (int) (opcode >> 8) & 0x0f,
- case 0:
- if (rd == 0xf) {
- instruction->type = ARM_TST;
- mnemonic = "TST";
- one = true;
- suffix = "";
- rd = rn;
- } else {
- instruction->type = ARM_AND;
- mnemonic = "AND";
- }
- break;
- case 1:
- instruction->type = ARM_BIC;
- mnemonic = "BIC";
- break;
- case 2:
- if (rn == 0xf) {
- instruction->type = ARM_MOV;
- mnemonic = "MOV";
- one = true;
+ case 0:
+ if (rd == 0xf) {
+ instruction->type = ARM_TST;
+ mnemonic = "TST";
+ one = true;
+ suffix = "";
+ rd = rn;
+ } else {
+ instruction->type = ARM_AND;
+ mnemonic = "AND";
+ }
+ break;
+ case 1:
+ instruction->type = ARM_BIC;
+ mnemonic = "BIC";
+ break;
+ case 2:
+ if (rn == 0xf) {
+ instruction->type = ARM_MOV;
+ mnemonic = "MOV";
+ one = true;
+ suffix2 = ".W";
+ } else {
+ instruction->type = ARM_ORR;
+ mnemonic = "ORR";
+ }
+ break;
+ case 3:
+ if (rn == 0xf) {
+ instruction->type = ARM_MVN;
+ mnemonic = "MVN";
+ one = true;
+ } else {
+ /* instruction->type = ARM_ORN; */
+ mnemonic = "ORN";
+ }
+ break;
+ case 4:
+ if (rd == 0xf) {
+ instruction->type = ARM_TEQ;
+ mnemonic = "TEQ";
+ one = true;
+ suffix = "";
+ rd = rn;
+ } else {
+ instruction->type = ARM_EOR;
+ mnemonic = "EOR";
+ }
+ break;
+ case 8:
+ if (rd == 0xf) {
+ instruction->type = ARM_CMN;
+ mnemonic = "CMN";
+ one = true;
+ suffix = "";
+ rd = rn;
+ } else {
+ instruction->type = ARM_ADD;
+ mnemonic = "ADD";
+ suffix2 = ".W";
+ }
+ break;
+ case 10:
+ instruction->type = ARM_ADC;
+ mnemonic = "ADC";
- } else {
- instruction->type = ARM_ORR;
- mnemonic = "ORR";
- }
- break;
- case 3:
- if (rn == 0xf) {
- instruction->type = ARM_MVN;
- mnemonic = "MVN";
- one = true;
- } else {
- // instruction->type = ARM_ORN;
- mnemonic = "ORN";
- }
- break;
- case 4:
- if (rd == 0xf) {
- instruction->type = ARM_TEQ;
- mnemonic = "TEQ";
- one = true;
- suffix = "";
- rd = rn;
- } else {
- instruction->type = ARM_EOR;
- mnemonic = "EOR";
- }
- break;
- case 8:
- if (rd == 0xf) {
- instruction->type = ARM_CMN;
- mnemonic = "CMN";
- one = true;
- suffix = "";
- rd = rn;
- } else {
- instruction->type = ARM_ADD;
- mnemonic = "ADD";
+ break;
+ case 11:
+ instruction->type = ARM_SBC;
+ mnemonic = "SBC";
+ break;
+ case 13:
+ if (rd == 0xf) {
+ instruction->type = ARM_CMP;
+ mnemonic = "CMP";
+ one = true;
+ suffix = "";
+ rd = rn;
+ } else {
+ instruction->type = ARM_SUB;
+ mnemonic = "SUB";
+ }
- }
- break;
- case 10:
- instruction->type = ARM_ADC;
- mnemonic = "ADC";
- suffix2 = ".W";
- break;
- case 11:
- instruction->type = ARM_SBC;
- mnemonic = "SBC";
- break;
- case 13:
- if (rd == 0xf) {
- instruction->type = ARM_CMP;
- mnemonic = "CMP";
- one = true;
- suffix = "";
- rd = rn;
- } else {
- instruction->type = ARM_SUB;
- mnemonic = "SUB";
- }
- suffix2 = ".W";
- break;
- case 14:
- instruction->type = ARM_RSB;
- mnemonic = "RSB";
- suffix2 = ".W";
- break;
- default:
- return ERROR_INVALID_ARGUMENTS;
+ break;
+ case 14:
+ instruction->type = ARM_RSB;
+ mnemonic = "RSB";
+ suffix2 = ".W";
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
else
sprintf(cp, "%s%s%s\tr%d, r%d, #%d\t; %#8.8x",
mnemonic, suffix, suffix2,
else
sprintf(cp, "%s%s%s\tr%d, r%d, #%d\t; %#8.8x",
mnemonic, suffix, suffix2,
- case 0:
- if (rn == 0xf) {
- add = true;
- goto do_adr;
- }
- mnemonic = "ADDW";
- break;
- case 4:
- immed |= (opcode >> 4) & 0xf000;
- sprintf(cp, "MOVW\tr%d, #%d\t; %#3.3x", rd, immed, immed);
- return ERROR_OK;
- case 0x0a:
- if (rn == 0xf)
- goto do_adr;
- mnemonic = "SUBW";
- break;
- case 0x0c:
- /* move constant to top 16 bits of register */
- immed |= (opcode >> 4) & 0xf000;
- sprintf(cp, "MOVT\tr%d, #%d\t; %#4.4x", rn, immed, immed);
- return ERROR_OK;
- case 0x10:
- case 0x12:
- is_signed = true;
- case 0x18:
- case 0x1a:
- /* signed/unsigned saturated add */
- immed = (opcode >> 6) & 0x03;
- immed |= (opcode >> 10) & 0x1c;
- sprintf(cp, "%sSAT\tr%d, #%d, r%d, %s #%d\t",
- is_signed ? "S" : "U",
- rd, (int) (opcode & 0x1f) + is_signed, rn,
- (opcode & (1 << 21)) ? "ASR" : "LSL",
- immed ? immed : 32);
- return ERROR_OK;
- case 0x14:
- is_signed = true;
- /* FALLTHROUGH */
- case 0x1c:
- /* signed/unsigned bitfield extract */
- immed = (opcode >> 6) & 0x03;
- immed |= (opcode >> 10) & 0x1c;
- sprintf(cp, "%sBFX\tr%d, r%d, #%d, #%d\t",
- is_signed ? "S" : "U",
+ case 0:
+ if (rn == 0xf) {
+ add = true;
+ goto do_adr;
+ }
+ mnemonic = "ADDW";
+ break;
+ case 4:
+ immed |= (opcode >> 4) & 0xf000;
+ sprintf(cp, "MOVW\tr%d, #%d\t; %#3.3x", rd, immed, immed);
+ return ERROR_OK;
+ case 0x0a:
+ if (rn == 0xf)
+ goto do_adr;
+ mnemonic = "SUBW";
+ break;
+ case 0x0c:
+ /* move constant to top 16 bits of register */
+ immed |= (opcode >> 4) & 0xf000;
+ sprintf(cp, "MOVT\tr%d, #%d\t; %#4.4x", rd, immed, immed);
+ return ERROR_OK;
+ case 0x10:
+ case 0x12:
+ is_signed = true;
+ case 0x18:
+ case 0x1a:
+ /* signed/unsigned saturated add */
+ immed = (opcode >> 6) & 0x03;
+ immed |= (opcode >> 10) & 0x1c;
+ sprintf(cp, "%sSAT\tr%d, #%d, r%d, %s #%d\t",
+ is_signed ? "S" : "U",
+ rd, (int) (opcode & 0x1f) + is_signed, rn,
+ (opcode & (1 << 21)) ? "ASR" : "LSL",
+ immed ? immed : 32);
+ return ERROR_OK;
+ case 0x14:
+ is_signed = true;
+ /* FALLTHROUGH */
+ case 0x1c:
+ /* signed/unsigned bitfield extract */
+ immed = (opcode >> 6) & 0x03;
+ immed |= (opcode >> 10) & 0x1c;
+ sprintf(cp, "%sBFX\tr%d, r%d, #%d, #%d\t",
+ is_signed ? "S" : "U",
- return ERROR_OK;
- case 0x16:
- immed = (opcode >> 6) & 0x03;
- immed |= (opcode >> 10) & 0x1c;
- if (rn == 0xf) /* bitfield clear */
- sprintf(cp, "BFC\tr%d, #%d, #%d\t",
- rd, immed,
- (int) (opcode & 0x1f) + 1 - immed);
- else /* bitfield insert */
- sprintf(cp, "BFI\tr%d, r%d, #%d, #%d\t",
- rd, rn, immed,
- (int) (opcode & 0x1f) + 1 - immed);
- return ERROR_OK;
- default:
- return ERROR_INVALID_ARGUMENTS;
+ return ERROR_OK;
+ case 0x16:
+ immed = (opcode >> 6) & 0x03;
+ immed |= (opcode >> 10) & 0x1c;
+ if (rn == 0xf) /* bitfield clear */
+ sprintf(cp, "BFC\tr%d, #%d, #%d\t",
+ rd, immed,
+ (int) (opcode & 0x1f) + 1 - immed);
+ else /* bitfield insert */
+ sprintf(cp, "BFI\tr%d, r%d, #%d, #%d\t",
+ rd, rn, immed,
+ (int) (opcode & 0x1f) + 1 - immed);
+ return ERROR_OK;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
- case 0:
- if (ra == 0xf)
- sprintf(cp, "MUL\tr%d, r%d, r%d",
- (int) (opcode >> 8) & 0xf,
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf);
- else
- sprintf(cp, "MLA\tr%d, r%d, r%d, r%d",
+ case 0:
+ if (ra == 0xf)
+ sprintf(cp, "MUL\tr%d, r%d, r%d",
+ (int) (opcode >> 8) & 0xf,
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf);
+ else
+ sprintf(cp, "MLA\tr%d, r%d, r%d, r%d",
+ (int) (opcode >> 8) & 0xf,
+ (int) (opcode >> 16) & 0xf,
+ (int) (opcode >> 0) & 0xf, ra);
+ break;
+ case 0x10:
+ sprintf(cp, "MLS\tr%d, r%d, r%d, r%d",
(int) (opcode >> 8) & 0xf,
(int) (opcode >> 16) & 0xf,
(int) (opcode >> 0) & 0xf, ra);
(int) (opcode >> 8) & 0xf,
(int) (opcode >> 16) & 0xf,
(int) (opcode >> 0) & 0xf, ra);
- break;
- case 0x10:
- sprintf(cp, "MLS\tr%d, r%d, r%d, r%d",
- (int) (opcode >> 8) & 0xf,
- (int) (opcode >> 16) & 0xf,
- (int) (opcode >> 0) & 0xf, ra);
- break;
- default:
- return ERROR_INVALID_ARGUMENTS;
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
(op & 0x20) ? 'U' : 'S',
infix,
(int) (opcode >> 12) & 0xf,
(int) (opcode >> 8) & 0xf,
(int) (opcode >> 16) & 0xf,
(int) (opcode >> 0) & 0xf);
(op & 0x20) ? 'U' : 'S',
infix,
(int) (opcode >> 12) & 0xf,
(int) (opcode >> 8) & 0xf,
(int) (opcode >> 16) & 0xf,
(int) (opcode >> 0) & 0xf);
(op & 0x20) ? 'U' : 'S',
(int) (opcode >> 8) & 0xf,
(int) (opcode >> 16) & 0xf,
(int) (opcode >> 0) & 0xf);
(op & 0x20) ? 'U' : 'S',
(int) (opcode >> 8) & 0xf,
(int) (opcode >> 16) & 0xf,
(int) (opcode >> 0) & 0xf);
- return ERROR_OK;
- case 2:
- sprintf(cp, "STM.W\tr%d%s, ", rn, t ? "!" : "");
- break;
- case 3:
- if (rn == 13 && t)
- sprintf(cp, "POP.W\t");
- else
- sprintf(cp, "LDM.W\tr%d%s, ", rn, t ? "!" : "");
- break;
- case 4:
- if (rn == 13 && t)
- sprintf(cp, "PUSH.W\t");
- else
- sprintf(cp, "STMDB\tr%d%s, ", rn, t ? "!" : "");
- break;
- case 5:
- sprintf(cp, "LDMDB.W\tr%d%s, ", rn, t ? "!" : "");
- break;
- default:
- return ERROR_INVALID_ARGUMENTS;
+ return ERROR_OK;
+ case 2:
+ sprintf(cp, "STM.W\tr%d%s, ", rn, t ? "!" : "");
+ break;
+ case 3:
+ if (rn == 13 && t)
+ sprintf(cp, "POP.W\t");
+ else
+ sprintf(cp, "LDM.W\tr%d%s, ", rn, t ? "!" : "");
+ break;
+ case 4:
+ if (rn == 13 && t)
+ sprintf(cp, "PUSH.W\t");
+ else
+ sprintf(cp, "STMDB\tr%d%s, ", rn, t ? "!" : "");
+ break;
+ case 5:
+ sprintf(cp, "LDMDB.W\tr%d%s, ", rn, t ? "!" : "");
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
/* load/store dual or exclusive, table branch */
static int t2ev_ldrex_strex(uint32_t opcode, uint32_t address,
/* load/store dual or exclusive, table branch */
static int t2ev_ldrex_strex(uint32_t opcode, uint32_t address,
- mnemonic = "LDREXH";
- break;
- default:
- return ERROR_INVALID_ARGUMENTS;
- }
- imm = 0;
- goto ldrex;
+ switch (op3) {
+ case 0:
+ sprintf(cp, "TBB\t[r%u, r%u]", rn, imm & 0xf);
+ return ERROR_OK;
+ case 1:
+ sprintf(cp, "TBH\t[r%u, r%u, LSL #1]", rn, imm & 0xf);
+ return ERROR_OK;
+ case 4:
+ mnemonic = "LDREXB";
+ break;
+ case 5:
+ mnemonic = "LDREXH";
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+ imm = 0;
+ goto ldrex;
- case 0:
- if (rd == 0xf) {
- if (!(opcode & (1 << 20)))
- return ERROR_INVALID_ARGUMENTS;
- instruction->type = ARM_TST;
- mnemonic = "TST";
- suffix = "";
- goto two;
- }
- instruction->type = ARM_AND;
- mnemonic = "AND";
- break;
- case 1:
- instruction->type = ARM_BIC;
- mnemonic = "BIC";
- break;
- case 2:
- if (rn == 0xf) {
- instruction->type = ARM_MOV;
- switch (type) {
- case 0:
- if (immed == 0) {
- sprintf(cp, "MOV%s.W\tr%d, r%d",
- suffix, rd,
- (int) (opcode & 0xf));
- return ERROR_OK;
- }
- mnemonic = "LSL";
- break;
- case 1:
- mnemonic = "LSR";
- break;
- case 2:
- mnemonic = "ASR";
- break;
- default:
- if (immed == 0) {
- sprintf(cp, "RRX%s\tr%d, r%d",
- suffix, rd,
- (int) (opcode & 0xf));
- return ERROR_OK;
+ case 0:
+ if (rd == 0xf) {
+ if (!(opcode & (1 << 20)))
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ instruction->type = ARM_TST;
+ mnemonic = "TST";
+ suffix = "";
+ goto two;
+ }
+ instruction->type = ARM_AND;
+ mnemonic = "AND";
+ break;
+ case 1:
+ instruction->type = ARM_BIC;
+ mnemonic = "BIC";
+ break;
+ case 2:
+ if (rn == 0xf) {
+ instruction->type = ARM_MOV;
+ switch (type) {
+ case 0:
+ if (immed == 0) {
+ sprintf(cp, "MOV%s.W\tr%d, r%d",
+ suffix, rd,
+ (int) (opcode & 0xf));
+ return ERROR_OK;
+ }
+ mnemonic = "LSL";
+ break;
+ case 1:
+ mnemonic = "LSR";
+ break;
+ case 2:
+ mnemonic = "ASR";
+ break;
+ default:
+ if (immed == 0) {
+ sprintf(cp, "RRX%s\tr%d, r%d",
+ suffix, rd,
+ (int) (opcode & 0xf));
+ return ERROR_OK;
+ }
+ mnemonic = "ROR";
+ break;
- goto immediate;
- } else {
- instruction->type = ARM_ORR;
- mnemonic = "ORR";
- }
- break;
- case 3:
- if (rn == 0xf) {
- instruction->type = ARM_MVN;
- mnemonic = "MVN";
- rn = rd;
- goto two;
- } else {
- // instruction->type = ARM_ORN;
- mnemonic = "ORN";
- }
- break;
- case 4:
- if (rd == 0xf) {
- if (!(opcode & (1 << 20)))
- return ERROR_INVALID_ARGUMENTS;
- instruction->type = ARM_TEQ;
- mnemonic = "TEQ";
- suffix = "";
- goto two;
- }
- instruction->type = ARM_EOR;
- mnemonic = "EOR";
- break;
- case 8:
- if (rd == 0xf) {
- if (!(opcode & (1 << 20)))
- return ERROR_INVALID_ARGUMENTS;
- instruction->type = ARM_CMN;
- mnemonic = "CMN";
- suffix = "";
- goto two;
- }
- instruction->type = ARM_ADD;
- mnemonic = "ADD";
- break;
- case 0xa:
- instruction->type = ARM_ADC;
- mnemonic = "ADC";
- break;
- case 0xb:
- instruction->type = ARM_SBC;
- mnemonic = "SBC";
- break;
- case 0xd:
- if (rd == 0xf) {
- if (!(opcode & (1 << 21)))
- return ERROR_INVALID_ARGUMENTS;
- instruction->type = ARM_CMP;
- mnemonic = "CMP";
- suffix = "";
- goto two;
- }
- instruction->type = ARM_SUB;
- mnemonic = "SUB";
- break;
- case 0xe:
- instruction->type = ARM_RSB;
- mnemonic = "RSB";
- break;
- default:
- return ERROR_INVALID_ARGUMENTS;
+ break;
+ case 3:
+ if (rn == 0xf) {
+ instruction->type = ARM_MVN;
+ mnemonic = "MVN";
+ rn = rd;
+ goto two;
+ } else {
+ /* instruction->type = ARM_ORN; */
+ mnemonic = "ORN";
+ }
+ break;
+ case 4:
+ if (rd == 0xf) {
+ if (!(opcode & (1 << 20)))
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ instruction->type = ARM_TEQ;
+ mnemonic = "TEQ";
+ suffix = "";
+ goto two;
+ }
+ instruction->type = ARM_EOR;
+ mnemonic = "EOR";
+ break;
+ case 8:
+ if (rd == 0xf) {
+ if (!(opcode & (1 << 20)))
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ instruction->type = ARM_CMN;
+ mnemonic = "CMN";
+ suffix = "";
+ goto two;
+ }
+ instruction->type = ARM_ADD;
+ mnemonic = "ADD";
+ break;
+ case 0xa:
+ instruction->type = ARM_ADC;
+ mnemonic = "ADC";
+ break;
+ case 0xb:
+ instruction->type = ARM_SBC;
+ mnemonic = "SBC";
+ break;
+ case 0xd:
+ if (rd == 0xf) {
+ if (!(opcode & (1 << 21)))
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ instruction->type = ARM_CMP;
+ mnemonic = "CMP";
+ suffix = "";
+ goto two;
+ }
+ instruction->type = ARM_SUB;
+ mnemonic = "SUB";
+ break;
+ case 0xe:
+ instruction->type = ARM_RSB;
+ mnemonic = "RSB";
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
sprintf(cp, ", %s #%d", suffix, immed ? immed : 32);
return ERROR_OK;
two:
sprintf(cp, "%s%s.W\tr%d, r%d",
}
sprintf(cp, ", %s #%d", suffix, immed ? immed : 32);
return ERROR_OK;
two:
sprintf(cp, "%s%s.W\tr%d, r%d",
(opcode & (1 << 24)) ? 'U' : 'S',
(opcode & (1 << 26)) ? 'B' : 'H',
(int) (opcode >> 8) & 0xf,
(int) (opcode >> 0) & 0xf,
suffix);
(opcode & (1 << 24)) ? 'U' : 'S',
(opcode & (1 << 26)) ? 'B' : 'H',
(int) (opcode >> 8) & 0xf,
(int) (opcode >> 0) & 0xf,
suffix);
- break;
- case 8:
- case 9:
- case 0xa:
- case 0xb:
- if (opcode & (1 << 6))
- return ERROR_INVALID_ARGUMENTS;
- if (((opcode >> 12) & 0xf) != 0xf)
- return ERROR_INVALID_ARGUMENTS;
- if (!(opcode & (1 << 20)))
- return ERROR_INVALID_ARGUMENTS;
-
- switch (((opcode >> 19) & 0x04)
- | ((opcode >> 4) & 0x3)) {
- case 0:
- mnemonic = "REV.W";
- case 1:
- mnemonic = "REV16.W";
- break;
- case 2:
- mnemonic = "RBIT";
- break;
- case 3:
- mnemonic = "REVSH.W";
- break;
- case 4:
- mnemonic = "CLZ";
- break;
- default:
- return ERROR_INVALID_ARGUMENTS;
- }
- sprintf(cp, "%s\tr%d, r%d",
+ case 8:
+ case 9:
+ case 0xa:
+ case 0xb:
+ if (opcode & (1 << 6))
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ if (((opcode >> 12) & 0xf) != 0xf)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ if (!(opcode & (1 << 20)))
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
+ switch (((opcode >> 19) & 0x04)
+ | ((opcode >> 4) & 0x3)) {
+ case 0:
+ mnemonic = "REV.W";
+ break;
+ case 1:
+ mnemonic = "REV16.W";
+ break;
+ case 2:
+ mnemonic = "RBIT";
+ break;
+ case 3:
+ mnemonic = "REVSH.W";
+ break;
+ case 4:
+ mnemonic = "CLZ";
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+ sprintf(cp, "%s\tr%d, r%d",
- immed = opcode & 0xfff;
- address = thumb_alignpc4(address);
- if (opcode & (1 << 23))
- address += immed;
- else
- address -= immed;
- sprintf(cp, "PLD\tr%d, %#8.8" PRIx32,
- rt, address);
- return ERROR_OK;
- }
- if (rn == 0x0f && rt != 0x0f) {
+ immed = opcode & 0xfff;
+ address = thumb_alignpc4(address);
+ if (opcode & (1 << 23))
+ address += immed;
+ else
+ address -= immed;
+ sprintf(cp, "PLD\tr%d, %#8.8" PRIx32,
+ rt, address);
+ return ERROR_OK;
+ }
+ if (rn == 0x0f && rt != 0x0f) {
- immed = opcode & 0xfff;
- address = thumb_alignpc4(address);
- if (opcode & (1 << 23))
- address += immed;
- else
- address -= immed;
- sprintf(cp, "LDRB\tr%d, %#8.8" PRIx32,
- rt, address);
- return ERROR_OK;
- }
- if (rn == 0x0f)
- break;
- if ((op2 & 0x3c) == 0x38) {
- immed = opcode & 0xff;
- sprintf(cp, "LDRBT\tr%d, [r%d, #%d]\t; %#2.2x",
- rt, rn, immed, immed);
- return ERROR_OK;
- }
- if ((op2 & 0x3c) == 0x30) {
- if (rt == 0x0f) {
+ immed = opcode & 0xfff;
+ address = thumb_alignpc4(address);
+ if (opcode & (1 << 23))
+ address += immed;
+ else
+ address -= immed;
+ sprintf(cp, "LDRB\tr%d, %#8.8" PRIx32,
+ rt, address);
+ return ERROR_OK;
+ }
+ if (rn == 0x0f)
+ break;
+ if ((op2 & 0x3c) == 0x38) {
- sprintf(cp, "%s\tr%d, [r%d%s, #%d%s\t; %#8.8x",
- mnemonic, rt, rn, p1,
- immed, p2, immed);
- return ERROR_OK;
- }
- if ((op2 & 0x24) == 0x24) {
- mnemonic = "LDRB";
- goto ldrxb_immediate_t3;
- }
- if (op2 == 0) {
- int rm = opcode & 0xf;
+ sprintf(cp, "%s\tr%d, [r%d%s, #%d%s\t; %#8.8x",
+ mnemonic, rt, rn, p1,
+ immed, p2, immed);
+ return ERROR_OK;
+ }
+ if ((op2 & 0x24) == 0x24) {
+ mnemonic = "LDRB";
+ goto ldrxb_immediate_t3;
+ }
+ if (op2 == 0) {
+ int rm = opcode & 0xf;
- if (rt == 0x0f)
- sprintf(cp, "PLD\t");
- else
- sprintf(cp, "LDRB.W\tr%d, ", rt);
- immed = (opcode >> 4) & 0x3;
- cp = strchr(cp, 0);
- sprintf(cp, "[r%d, r%d, LSL #%d]", rn, rm, immed);
- return ERROR_OK;
- }
- break;
- case 1:
- if ((rn & rt) == 0xf)
- goto pld_literal;
- if (rt == 0xf) {
- immed = opcode & 0xfff;
- goto preload_immediate;
- }
- if (rn == 0x0f)
- goto ldrb_literal;
- mnemonic = "LDRB.W";
- immed = opcode & 0xfff;
- goto ldrxb_immediate_t2;
- case 2:
- if ((rn & rt) == 0xf) {
- immed = opcode & 0xfff;
- address = thumb_alignpc4(address);
- if (opcode & (1 << 23))
- address += immed;
- else
- address -= immed;
- sprintf(cp, "PLI\t%#8.8" PRIx32, address);
- return ERROR_OK;
- }
- if (rn == 0xf && rt != 0xf) {
-ldrsb_literal:
- immed = opcode & 0xfff;
- address = thumb_alignpc4(address);
- if (opcode & (1 << 23))
- address += immed;
- else
- address -= immed;
- sprintf(cp, "LDRSB\t%#8.8" PRIx32, address);
- return ERROR_OK;
- }
- if (rn == 0xf)
+ if (rt == 0x0f)
+ sprintf(cp, "PLD\t");
+ else
+ sprintf(cp, "LDRB.W\tr%d, ", rt);
+ immed = (opcode >> 4) & 0x3;
+ cp = strchr(cp, 0);
+ sprintf(cp, "[r%d, r%d, LSL #%d]", rn, rm, immed);
+ return ERROR_OK;
+ }
+ immed = opcode & 0xfff;
+ goto preload_immediate;
+ }
+ if (rn == 0x0f)
+ goto ldrb_literal;
+ mnemonic = "LDRB.W";
+ immed = opcode & 0xfff;
+ goto ldrxb_immediate_t2;
+ case 2:
+ if ((rn & rt) == 0xf) {
+ immed = opcode & 0xfff;
+ address = thumb_alignpc4(address);
+ if (opcode & (1 << 23))
+ address += immed;
+ else
+ address -= immed;
+ sprintf(cp, "PLI\t%#8.8" PRIx32, address);
+ return ERROR_OK;
+ }
+ if (rn == 0xf && rt != 0xf) {
+ldrsb_literal:
+ immed = opcode & 0xfff;
+ address = thumb_alignpc4(address);
+ if (opcode & (1 << 23))
+ address += immed;
+ else
+ address -= immed;
+ sprintf(cp, "LDRSB\t%#8.8" PRIx32, address);
+ return ERROR_OK;
+ }
+ if (rn == 0xf)
+ break;
+ if ((op2 & 0x3c) == 0x38) {
- mnemonic = "LDRSB";
- goto ldrxb_immediate_t3;
- }
- if ((op2 & 0x24) == 0x24) {
- mnemonic = "LDRSB";
- goto ldrxb_immediate_t3;
- }
- if (op2 == 0) {
- int rm = opcode & 0xf;
+ if ((op2 & 0x3c) == 0x30) {
+ if (rt == 0xf) {
+ immed = opcode & 0xff;
+ immed = -immed; /* pli */
+ sprintf(cp, "PLI\t[r%d, #%d]\t; -%#2.2x",
+ rn, immed, -immed);
+ return ERROR_OK;
+ }
+ mnemonic = "LDRSB";
+ goto ldrxb_immediate_t3;
+ }
+ if ((op2 & 0x24) == 0x24) {
+ mnemonic = "LDRSB";
+ goto ldrxb_immediate_t3;
+ }
+ if (op2 == 0) {
+ int rm = opcode & 0xf;
- if (rt == 0x0f)
- sprintf(cp, "PLI\t");
- else
- sprintf(cp, "LDRSB.W\tr%d, ", rt);
- immed = (opcode >> 4) & 0x3;
- cp = strchr(cp, 0);
- sprintf(cp, "[r%d, r%d, LSL #%d]", rn, rm, immed);
- return ERROR_OK;
- }
- break;
- case 3:
- if (rt == 0xf) {
+ if (rt == 0x0f)
+ sprintf(cp, "PLI\t");
+ else
+ sprintf(cp, "LDRSB.W\tr%d, ", rt);
+ immed = (opcode >> 4) & 0x3;
+ cp = strchr(cp, 0);
+ sprintf(cp, "[r%d, r%d, LSL #%d]", rn, rm, immed);
+ return ERROR_OK;
+ }
+ break;
+ case 3:
+ if (rt == 0xf) {
+ immed = opcode & 0xfff;
+ sprintf(cp, "PLI\t[r%d, #%d]\t; %#3.3x",
+ rn, immed, immed);
+ return ERROR_OK;
+ }
+ if (rn == 0xf)
+ goto ldrsb_literal;
- case 0xf800:
- case 0xf000:
- case 0xe800:
- /* 32-bit instructions */
- instruction->instruction_size = 4;
- opcode = op << 16;
- retval = target_read_u16(target, address + 2, &op);
- if (retval != ERROR_OK)
- return retval;
- opcode |= op;
- instruction->opcode = opcode;
- break;
- default:
- /* 16-bit: Thumb1 + IT + CBZ/CBNZ + ... */
- return thumb_evaluate_opcode(op, address, instruction);
+ case 0xf800:
+ case 0xf000:
+ case 0xe800:
+ /* 32-bit instructions */
+ instruction->instruction_size = 4;
+ opcode = op << 16;
+ retval = target_read_u16(target, address + 2, &op);
+ if (retval != ERROR_OK)
+ return retval;
+ opcode |= op;
+ instruction->opcode = opcode;
+ break;
+ default:
+ /* 16-bit: Thumb1 + IT + CBZ/CBNZ + ... */
+ return thumb_evaluate_opcode(op, address, instruction);
retval = t2ev_data_shift(opcode, address, instruction, cp);
/* ARMv7-M: A5.3.12 Data processing (register)
retval = t2ev_data_shift(opcode, address, instruction, cp);
/* ARMv7-M: A5.3.12 Data processing (register)
- || (instruction->type == ARM_LDRBT)
- || (instruction->type == ARM_LDRSB)
- || (instruction->type == ARM_STRB)
- || (instruction->type == ARM_STRBT))
- {
+ || (instruction->type == ARM_LDRBT)
+ || (instruction->type == ARM_LDRSB)
+ || (instruction->type == ARM_STRB)
+ || (instruction->type == ARM_STRBT))