3
* pancake <nopcode.org>
5
* radare is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* radare is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with radare; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
/* code analysis functions */
23
#include "../../code.h"
28
int arch_8051_aop(ut64 addr, const ut8 *bytes, struct aop_t *aop)
39
memset (aop, '\0', sizeof (struct aop_t));
40
aop->type = AOP_TYPE_UNK;
42
ptr = dis51_inst1 (bytes, 0, &type);
43
if ((ptr == -1)&&(bytes[0]!=0x73)&&((bytes[0] & 0xef)!=0x22)) {
44
eprintf ("Invalid instruction %02x %02x\n",
46
aop->type = AOP_TYPE_TRAP;
47
return 1; // skip instruction..
49
ilen = dis51_inst2 (str, bytes, 0);
53
aop->type = AOP_TYPE_JMP;
54
aop->jump = ilen + addr + ptr;
58
aop->type = AOP_TYPE_CALL;
62
aop->type = AOP_TYPE_CJMP;
63
aop->jump = ilen + addr + ptr;
64
aop->fail = ilen + addr;
74
int dis51_udis (char *str, const ut8 *bytes, int len, ut64 seek) {
77
// TODO: add += seek somewhere :)
78
ptr = dis51_inst1 (bytes, 0, &type);
80
sprintf (str, "(invalid instruction)");
83
return dis51_inst2 (str, bytes, 0);