20 |
|
|
21 |
|
#include "sysdeps.h" |
22 |
|
|
23 |
+ |
#include <assert.h> |
24 |
|
#include <stdarg.h> |
25 |
|
|
26 |
|
#include "mon.h" |
169 |
|
|
170 |
|
return num; |
171 |
|
} |
172 |
+ |
|
173 |
+ |
int disass_mips(FILE *f, uint32 adr, int little_endian) |
174 |
+ |
{ |
175 |
+ |
// Initialize info for GDB disassembler |
176 |
+ |
disassemble_info info; |
177 |
+ |
char buf[1024]; |
178 |
+ |
SFILE sfile = {buf, buf}; |
179 |
+ |
sfile.buffer = buf; |
180 |
+ |
sfile.current = buf; |
181 |
+ |
INIT_DISASSEMBLE_INFO(info, (FILE *)&sfile, (fprintf_ftype)mon_sprintf); |
182 |
+ |
|
183 |
+ |
// Disassemble instruction |
184 |
+ |
lookup_lowmem = false; |
185 |
+ |
int num = little_endian ? print_insn_little_mips(adr, &info) : print_insn_big_mips(adr, &info); |
186 |
+ |
|
187 |
+ |
assert(num == 4); |
188 |
+ |
for (int i=0; i<4; i++) |
189 |
+ |
fprintf(f, " %02x", mon_read_byte(adr + i)); |
190 |
+ |
|
191 |
+ |
fprintf(f, " %s\n", buf); |
192 |
+ |
|
193 |
+ |
return num; |
194 |
+ |
} |
195 |
|
|
196 |
|
int disass_x86(FILE *f, uint32 adr, uint32 bits) |
197 |
|
{ |