Fix mnemonic mask for bf

This commit is contained in:
wargio 2023-06-10 00:16:53 +08:00 committed by Anton Kochkov
parent 5f30f1c966
commit b52ebcc62f

View file

@ -186,6 +186,9 @@ static int bf_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *b
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = bf_llimit(analysis, addr, op->jump);
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("while [ptr]");
}
op->type = RZ_ANALYSIS_OP_TYPE_CJMP;
op->fail = addr + 1;
break;
@ -195,6 +198,9 @@ static int bf_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *b
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = bf_rlimit(analysis, addr, op->jump);
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("loop");
}
op->type = RZ_ANALYSIS_OP_TYPE_UJMP;
break;
case '>':
@ -202,46 +208,70 @@ static int bf_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *b
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = bf_right_arrow();
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("inc ptr");
}
break;
case '<':
op->type = RZ_ANALYSIS_OP_TYPE_SUB;
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = bf_left_arrow();
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("dec ptr");
}
break;
case '+':
op->type = RZ_ANALYSIS_OP_TYPE_ADD;
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = bf_inc();
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("inc [ptr]");
}
break;
case '-':
op->type = RZ_ANALYSIS_OP_TYPE_SUB;
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = bf_dec();
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("dec [ptr]");
}
break;
case '.':
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = bf_out();
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("out [ptr]");
}
op->type = RZ_ANALYSIS_OP_TYPE_STORE;
break;
case ',':
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = bf_in();
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("in [ptr]");
}
op->type = RZ_ANALYSIS_OP_TYPE_LOAD;
break;
case 0x00:
case 0xff:
op->type = RZ_ANALYSIS_OP_TYPE_TRAP;
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("trap");
}
break;
default:
op->type = RZ_ANALYSIS_OP_TYPE_NOP;
if (mask & RZ_ANALYSIS_OP_MASK_IL) {
op->il_op = rz_il_op_new_nop();
}
if (mask & RZ_ANALYSIS_OP_MASK_DISASM) {
op->mnemonic = strdup("nop");
}
break;
}
return op->size;