CACAO
disasm.c
Go to the documentation of this file.
1 /* vm disassembler wrapper
2 
3  Copyright (C) 2001,2002,2003 Free Software Foundation, Inc.
4 
5  This file is part of Gforth.
6 
7  Gforth is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License
9  as published by the Free Software Foundation; either version 2
10  of the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20 */
21 
22 #include "intrp.h"
23 
24 #define IP (ip+1)
25 #define IPTOS IP[0]
26 
27 #define STATIC_PROFILING 0
28 
29 #if STATIC_PROFILING
30 #define add_inst(_b,_s) fputs(_s,vm_out)
31 
32 /* for purely static "profiles" for selecting static superinstructions */
34 {
35 #define return do {fputs(" \n 0\t",vm_out); goto _endif2_; } while (0)
36 #include <java-profile.i>
37 #undef return
38  /* else */
39  {
40  add_inst(b,"unknown");
41  ip++;
42  }
43  _endif_:
44  fputc(' ',vm_out);
45  _endif2_:
46  return ip;
47 }
48 #else
50 {
51  fprintf(vm_out,"%p: ",(void *)ip);
52 #include <java-disasm.i>
53  {
54  fprintf(vm_out,"unknown instruction %p",ip[0]);
55  ip++;
56  }
57  _endif_:
58  fputc('\n',vm_out);
59  return ip;
60 }
61 #endif
62 
63 
65 {
66 #if STATIC_PROFILING
67  fputs(" 0\t",vm_out);
68 #endif
69  while (ip<endp) {
70  ip = vm_disassemble_inst(ip, vm_prim);
71  }
72 #if STATIC_PROFILING
73  fputc('\n',vm_out);
74 #endif
75 }
Inst * vm_prim
Definition: md.c:48
void * Inst
Definition: intrp.h:58
void add_inst(block_count *b, char *inst)
Definition: profile.c:79
Inst * vm_disassemble_inst(Inst *ip, Inst vm_prim[])
Definition: disasm.c:49
void vm_disassemble(Inst *ip, Inst *endp, Inst vm_prim[])
Definition: disasm.c:64
FILE * vm_out
Definition: md.c:49
#define ip
Definition: md-asm.hpp:59