+/* src/vm/jit/m68k/disass.c - wrapper functions for GNU binutils disassembler
+
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
+
+ This file is part of CACAO.
+
+ 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, 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ $Id: arch.h 5330 2006-09-05 18:43:12Z edwin $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <dis-asm.h>
+#include <stdarg.h>
+
+#include "vm/types.h"
+
+#include "vm/global.h"
+#include "vm/jit/disass.h"
+
+
+/* disassinstr *****************************************************************
+
+ Outputs a disassembler listing of one machine code instruction on
+ 'stdout'.
+
+ code: instructions machine code
+
+*******************************************************************************/
+
+u1 *disassinstr(u1 *code)
+{
+ s4 seqlen;
+ s4 i;
+
+ if (!disass_initialized) {
+ INIT_DISASSEMBLE_INFO(info, NULL, disass_printf);
+
+ /* setting the struct members must be done after
+ INIT_DISASSEMBLE_INFO */
+
+ info.mach = bfd_mach_mcf_isa_b_float_emac; /* this is optimistic */
+ info.read_memory_func = &disass_buffer_read_memory;
+
+ disass_initialized = 1;
+ }
+
+ /* must be reset */
+ disass_len = 0;
+
+ printf("0x%08x: ", (s4) code);
+
+ /* 0x51fc is tpf "trap false" but not recognized correctly by binutils, make output more readable by skipping it */
+ if (*((u2*)code) == 0x51fc) {
+ printf("%04x\n", *((u2*)code));
+ return (code+2);
+ }
+
+ seqlen = print_insn_m68k((bfd_vma) (ptrint) code, &info);
+
+ for (i = 0; i < seqlen; i+=2, code+=2) {
+ printf("%04x ", *((u2*)code));
+ }
+
+ for (; i < 6; i+=2) {
+ printf(" ");
+ }
+
+ printf(" %s\n", disass_buf);
+
+ return code;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */