]>
Commit | Line | Data |
---|---|---|
5826e519 SW |
1 | /* |
2 | * Tiny Code Interpreter for QEMU - disassembler | |
3 | * | |
4 | * Copyright (c) 2011 Stefan Weil | |
5 | * | |
6 | * This program is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
16c1321b | 20 | #include "qemu-common.h" |
76cad711 | 21 | #include "disas/bfd.h" |
5826e519 SW |
22 | #include "tcg/tcg.h" |
23 | ||
24 | /* Disassemble TCI bytecode. */ | |
25 | int print_insn_tci(bfd_vma addr, disassemble_info *info) | |
26 | { | |
27 | int length; | |
28 | uint8_t byte; | |
29 | int status; | |
30 | TCGOpcode op; | |
31 | ||
32 | status = info->read_memory_func(addr, &byte, 1, info); | |
33 | if (status != 0) { | |
34 | info->memory_error_func(status, addr, info); | |
35 | return -1; | |
36 | } | |
37 | op = byte; | |
38 | ||
39 | addr++; | |
40 | status = info->read_memory_func(addr, &byte, 1, info); | |
41 | if (status != 0) { | |
42 | info->memory_error_func(status, addr, info); | |
43 | return -1; | |
44 | } | |
45 | length = byte; | |
46 | ||
47 | if (op >= tcg_op_defs_max) { | |
48 | info->fprintf_func(info->stream, "illegal opcode %d", op); | |
49 | } else { | |
50 | const TCGOpDef *def = &tcg_op_defs[op]; | |
51 | int nb_oargs = def->nb_oargs; | |
52 | int nb_iargs = def->nb_iargs; | |
53 | int nb_cargs = def->nb_cargs; | |
54 | /* TODO: Improve disassembler output. */ | |
55 | info->fprintf_func(info->stream, "%s\to=%d i=%d c=%d", | |
56 | def->name, nb_oargs, nb_iargs, nb_cargs); | |
57 | } | |
58 | ||
59 | return length; | |
60 | } |