72 return (instr >> 4) & 3;
76 return (instr >> 6) & 1;
80 return (instr >> 7) & 1;
84 return (instr >> 8) & 0xF;
92 if (strchr(
cmd->operands,
',')) {
93 memmove(
cmd->operands, strchr(
cmd->operands,
',') + 2,
94 strlen(strchr(
cmd->operands,
',') + 2) + 1);
99 if (strchr(
cmd->operands,
',')) {
101 *strchr(
cmd->operands,
',') =
'\0';
119 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"adc.b" :
"adc");
124 cmd->operands[0] =
'\0';
126 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"clr.b" :
"clr");
134 cmd->operands[0] =
'\0';
136 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"pop.b" :
"pop");
144 cmd->operands[0] =
'\0';
147 cmd->operands[0] =
'\0';
150 cmd->operands[0] =
'\0';
153 cmd->operands[0] =
'\0';
155 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"dadc.b" :
"dadc");
158 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"dec.b" :
"dec");
161 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"decd.b" :
"decd");
164 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"inc.b" :
"inc");
167 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"incd.b" :
"incd");
170 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"inv.b" :
"inv");
173 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"rla.b" :
"rla");
176 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"rlc.b" :
"rlc");
179 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"sbc.b" :
"sbc");
183 cmd->operands[0] =
'\0';
186 cmd->operands[0] =
'\0';
189 cmd->operands[0] =
'\0';
191 snprintf(
cmd->instr,
sizeof(
cmd->instr),
"%s", bw ?
"tst.b" :
"tst");
200 int ret = 0, srcOperInCodeWord = 0;
205 memset(dstbuf, 0,
sizeof(dstbuf));
229 srcOperInCodeWord = 1;
237 srcOperInCodeWord = 1;
241 srcOperInCodeWord = 1;
268 srcOperInCodeWord = 1;
284 if (srcOperInCodeWord != 0) {
293 snprintf(dstbuf,
sizeof(dstbuf),
", 0x%04x",
op);
296 snprintf(dstbuf,
sizeof(dstbuf),
", &0x%04x",
op);
304 strncat(
cmd->operands, dstbuf,
sizeof(
cmd->operands) - 1 - strlen(
cmd->operands));
314 strncat(
cmd->instr,
".b",
sizeof(
cmd->instr) - 1 - strlen(
cmd->instr));
317 cmd->opcode = opcode;
326 return (instr >> 10) & 7;
334 addr = instr & 0x3FF;
337 snprintf(
cmd->operands,
sizeof(
cmd->operands),
"$%c0x%04x",
addr >= 0x300 ?
'-' :
'+',
338 addr >= 0x300 ? 0x400 - ((
addr & 0x1FF) * 2 + 2) : (
addr & 0x1FF) * 2 + 2);
346 return (instr >> 7) & 0x7;
425 cmd->operands[0] =
'\0';
443 ut16 operand1 = 0, operand2 = 0;
456 if ((instr & 0x0f80) <= 0x0300) {
488 cmd->operands[0] =
'\0';
const lzma_allocator const uint8_t * in
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
return memset(p, 0, total)
static const char * two_op_instrs[]
int msp430_decode_command(const ut8 *in, int len, struct msp430_cmd *cmd)
@ MSP430_TWOOP_OPCODE_JUMP3
@ MSP430_TWOOP_OPCODE_INVALID
@ MSP430_TWOOP_OPCODE_JUMP2
@ MSP430_TWOOP_OPCODE_SINGLEOP
static void remove_second_operand(struct msp430_cmd *cmd)
static ut8 get_twoop_opcode(ut16 instr)
static int get_src(ut16 instr)
static const char * jmp_instrs[]
static ut8 get_bw(ut16 instr)
static int get_dst(ut16 instr)
static const char * one_op_instrs[]
static ut8 get_jmp_opcode(ut16 instr)
static ut8 get_as(ut16 instr)
static ut8 get_jmp_cond(ut16 instr)
static void decode_jmp(ut16 instr, struct msp430_cmd *cmd)
static int get_oneop_opcode(ut16 instr)
static int decode_emulation(ut16 instr, struct msp430_cmd *cmd)
static int decode_addressing_mode(ut16 instr, ut16 op1, ut16 op2, struct msp430_cmd *cmd)
static int decode_oneop_opcode(ut16 instr, ut16 op, struct msp430_cmd *cmd)
static void remove_first_operand(struct msp430_cmd *cmd)
static ut8 get_ad(ut16 instr)
static int decode_twoop_opcode(ut16 instr, ut16 op1, ut16 op2, struct msp430_cmd *cmd)
static const char * msp430_register_names[]
static ut16 rz_read_at_le16(const void *src, size_t offset)
static ut16 rz_read_le16(const void *src)