aboutsummaryrefslogtreecommitdiff
path: root/disas/tci.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-12-19 17:15:39 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2012-12-19 17:15:39 -0600
commit27dd7730582be85c7d4f680f5f71146629809c86 (patch)
tree3a36db2e407711ed222de28b839744db48a75059 /disas/tci.c
parent914606d26e654d4c01bd5186f4d05e3fd445e219 (diff)
parentec5e016c9a68588bd01be387416923c7dcafb951 (diff)
Merge remote-tracking branch 'bonzini/header-dirs' into staging
* bonzini/header-dirs: (45 commits) janitor: move remaining public headers to include/ hw: move executable format header files to hw/ fpu: move public header file to include/fpu softmmu: move remaining include files to include/ subdirectories softmmu: move include files to include/sysemu/ misc: move include files to include/qemu/ qom: move include files to include/qom/ migration: move include files to include/migration/ monitor: move include files to include/monitor/ exec: move include files to include/exec/ block: move include files to include/block/ qapi: move include files to include/qobject/ janitor: add guards to headers qapi: make struct Visitor opaque qapi: remove qapi/qapi-types-core.h qapi: move inclusions of qemu-common.h from headers to .c files ui: move files to ui/ and include/ui/ qemu-ga: move qemu-ga files to qga/ net: reorganize headers net: move net.c to net/ ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'disas/tci.c')
-rw-r--r--disas/tci.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/disas/tci.c b/disas/tci.c
new file mode 100644
index 0000000000..a606b63a2a
--- /dev/null
+++ b/disas/tci.c
@@ -0,0 +1,59 @@
+/*
+ * Tiny Code Interpreter for QEMU - disassembler
+ *
+ * Copyright (c) 2011 Stefan Weil
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "disas/bfd.h"
+#include "tcg/tcg.h"
+
+/* Disassemble TCI bytecode. */
+int print_insn_tci(bfd_vma addr, disassemble_info *info)
+{
+ int length;
+ uint8_t byte;
+ int status;
+ TCGOpcode op;
+
+ status = info->read_memory_func(addr, &byte, 1, info);
+ if (status != 0) {
+ info->memory_error_func(status, addr, info);
+ return -1;
+ }
+ op = byte;
+
+ addr++;
+ status = info->read_memory_func(addr, &byte, 1, info);
+ if (status != 0) {
+ info->memory_error_func(status, addr, info);
+ return -1;
+ }
+ length = byte;
+
+ if (op >= tcg_op_defs_max) {
+ info->fprintf_func(info->stream, "illegal opcode %d", op);
+ } else {
+ const TCGOpDef *def = &tcg_op_defs[op];
+ int nb_oargs = def->nb_oargs;
+ int nb_iargs = def->nb_iargs;
+ int nb_cargs = def->nb_cargs;
+ /* TODO: Improve disassembler output. */
+ info->fprintf_func(info->stream, "%s\to=%d i=%d c=%d",
+ def->name, nb_oargs, nb_iargs, nb_cargs);
+ }
+
+ return length;
+}