mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 10:33:30 +00:00
This commit is contained in:
parent
dcfc44a329
commit
31dee0c52c
@ -1538,21 +1538,6 @@ static bool esil_goto(RAnalEsil *esil) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool esil_repeat(RAnalEsil *esil) {
|
||||
char *dst = r_anal_esil_pop (esil); // destaintion of the goto
|
||||
char *src = r_anal_esil_pop (esil); // value of the counter
|
||||
ut64 n, num = 0;
|
||||
if (r_anal_esil_get_parm (esil, src, &n) && r_anal_esil_get_parm (esil, dst, &num)) {
|
||||
if (n > 1) {
|
||||
esil->parse_goto = num;
|
||||
r_anal_esil_pushnum (esil, n - 1);
|
||||
}
|
||||
}
|
||||
free (dst);
|
||||
free (src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool esil_pop(RAnalEsil *esil) {
|
||||
char *dst = r_anal_esil_pop (esil);
|
||||
free (dst);
|
||||
@ -3552,9 +3537,6 @@ static int evalWord(RAnalEsil *esil, const char *ostr, const char **str) {
|
||||
if ((*str)[0] && (*str)[1] == ',') {
|
||||
return 2;
|
||||
}
|
||||
if (esil->repeat) {
|
||||
return 0;
|
||||
}
|
||||
if (esil->parse_goto != -1) {
|
||||
// TODO: detect infinite loop??? how??
|
||||
*str = gotoWord (ostr, esil->parse_goto);
|
||||
@ -3609,7 +3591,6 @@ R_API bool r_anal_esil_parse(RAnalEsil *esil, const char *str) {
|
||||
}
|
||||
}
|
||||
loop:
|
||||
esil->repeat = 0;
|
||||
esil->skip = 0;
|
||||
esil->parse_goto = -1;
|
||||
esil->parse_stop = 0;
|
||||
@ -3882,7 +3863,6 @@ static void r_anal_esil_setup_ops(RAnalEsil *esil) {
|
||||
OP ("[8]", esil_peek8, 1, 1, OT_MEMR);
|
||||
OP ("[16]", esil_peek16, 1, 1, OT_MEMR);
|
||||
OP ("STACK", r_anal_esil_dumpstack, 0, 0, OT_UNK);
|
||||
OP ("REPEAT", esil_repeat, 0, 2, OT_CTR);
|
||||
OP ("POP", esil_pop, 0, 1, OT_UNK);
|
||||
OP ("TODO", esil_todo, 0, 0, OT_UNK);
|
||||
OP ("GOTO", esil_goto, 0, 1, OT_CTR);
|
||||
|
@ -1452,9 +1452,11 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
|
||||
* by creating a mask on the stack and applying it, returning
|
||||
* result if bit is set.
|
||||
*/
|
||||
esilprintf (op, "%s,!,?{,1,zf,=,BREAK,},0,zf,=,"
|
||||
"%d,DUP,%d,-,1,<<,%s,&,?{,%d,-,%s,=,BREAK,},12,REPEAT",
|
||||
src, bits, bits, src, bits, dst);
|
||||
esilprintf (op, "%s,!,?{,1,zf,=,0,%s,=,BREAK,},0,zf,=,1,"
|
||||
"DUP,1,<<,%s,&,?{,1,+,%s,=,BREAK,},"
|
||||
"DUP,0,<,?{,1,+,DUP,%d,>,${,15,GOTO,},}",
|
||||
src, dst,
|
||||
dst, dst, bits);
|
||||
}
|
||||
break;
|
||||
case X86_INS_BSR:
|
||||
@ -1468,9 +1470,11 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
|
||||
* need to subtract anything to create
|
||||
* a mask and return the result.
|
||||
*/
|
||||
esilprintf (op, "%s,!,?{,1,zf,=,BREAK,},0,zf,=,"
|
||||
"%d,DUP,1,<<,%s,&,?{,%s,=,BREAK,},12,REPEAT",
|
||||
src, bits, src, dst);
|
||||
esilprintf (op, "%s,!,?{,1,zf,=,0,%s,=,BREAK,},0,zf,=,1,"
|
||||
"DUP,1,<<,%s,&,?{,1,+,%s,=,BREAK,},"
|
||||
"DUP,0,<,?{,1,+,DUP,%d,>,${,15,GOTO,},}",
|
||||
src, dst,
|
||||
dst, dst, bits);
|
||||
}
|
||||
break;
|
||||
case X86_INS_BSWAP:
|
||||
|
@ -1140,7 +1140,6 @@ typedef struct r_anal_esil_t {
|
||||
int nowrite;
|
||||
int iotrap;
|
||||
int exectrap;
|
||||
int repeat;
|
||||
int parse_stop;
|
||||
int parse_goto;
|
||||
int parse_goto_count;
|
||||
|
@ -2380,33 +2380,46 @@ wa bsf eax, ebx
|
||||
aer eax=0x00000000
|
||||
aer ebx=0x00000000
|
||||
aer zf=0
|
||||
sr PC=0
|
||||
aes
|
||||
aer eax,zf
|
||||
#
|
||||
# BSF: test lowest bit
|
||||
#
|
||||
aeim
|
||||
aer eax=0x00000000
|
||||
aer ebx=0xffffffff
|
||||
aer eax=42
|
||||
aer ebx=4
|
||||
aer zf=0
|
||||
sr PC=0
|
||||
aes
|
||||
aer eax,zf
|
||||
#
|
||||
# BSF: fffff
|
||||
#
|
||||
aer eax=42
|
||||
aer ebx=0xfffff
|
||||
sr PC=0
|
||||
pd 1@e:asm.flags=false
|
||||
aes
|
||||
|
||||
#
|
||||
# BSF: test highest bit
|
||||
#
|
||||
aeim
|
||||
aer eax=0x00000000
|
||||
aer ebx=0x80000000
|
||||
aer eax=42
|
||||
aer ebx=4
|
||||
aer zf=0
|
||||
sr PC=0
|
||||
aes
|
||||
aer eax,zf
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0x00000000
|
||||
0x00000001
|
||||
0x00000002
|
||||
0x00000000
|
||||
0x00000000
|
||||
0x0000001f
|
||||
0x00000000 0fbcc3 bsf eax, ebx
|
||||
0x00000002
|
||||
0x00000000
|
||||
EOF
|
||||
RUN
|
||||
@ -2452,7 +2465,7 @@ EXPECT=<<EOF
|
||||
0x00000001
|
||||
0x00000000
|
||||
0x00000000
|
||||
0x0000001f
|
||||
0x00000000
|
||||
0x00000000
|
||||
EOF
|
||||
RUN
|
||||
|
Loading…
Reference in New Issue
Block a user