1 /* Disassemble Zylin ZPU instructions.
2 Copyright 1995, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #include "opcode/zpu.h"
27 static fprintf_ftype fpr
;
29 static struct disassemble_info
*local_info
;
35 #define GETINFO(size,type,pcrel)\
36 case ADDR_PCREL: size = 0;type=-1;pcrel=1;break;\
37 case ADDR_IMMEDIATE: size = 0;type=-1;pcrel=0;break;\
38 case ADDR_IMPLIED: size = 0;type=-1;pcrel=0;break;\
42 static void print_operand PARAMS ((int, char *, unsigned int *));
45 print_operand (lookup
, format
, args
)
55 switch (c
= *format
++)
58 val
= args
[(*format
++) - '0'];
62 name
= findname (val
);
64 fpr (stream
, "%s", name
);
67 local_info
->print_address_func (val
, local_info
);
70 fpr (stream
, "0x%x", val
);
74 fpr (stream
, "%c", c
);
81 print_insn_zpu (memaddr
, info
)
83 struct disassemble_info
*info
;
86 unsigned char insn
[4];
87 const struct zpu_opcode
*op
=NULL
;
90 stream
= info
->stream
;
91 fpr
= info
->fprintf_func
;
93 for (i
= 0; i
< 4 && status
== 0; i
++)
95 status
= info
->read_memory_func (memaddr
+ i
, insn
+ i
, 1, info
);
98 for (i
=0; i
<zpu_num_opcodes
; i
++)
100 if ((zpu_opcodes
[i
].code
==insn
[0])||((zpu_opcodes
[i
].code
&insn
[0]&0x80)!=0))
107 if ((insn
[0]>=ZPU_storesp
)&&(insn
[0]<ZPU_storesp
+32))
109 fpr (stream
, "storesp %d", ((insn
[0]-ZPU_storesp
)^0x10)*4);
110 } else if ((insn
[0]>=ZPU_loadsp
)&&(insn
[0]<ZPU_loadsp
+32))
112 fpr (stream
, "loadsp %d", ((insn
[0]-ZPU_loadsp
)^0x10)*4);
133 fpr (stream
, "addsp %d", (insn
[0]-ZPU_addsp
)*4);
141 fpr (stream
, ".byte %d", insn
[0]);
142 } else if ((insn
[0]&0x80)!=0)
145 t
=(int)((signed char)((insn
[0]<<1)&0xff));\
148 fpr (stream
, "im %d", t
);
151 fpr (stream
, "%s", op
->name
);
153 /* Prepare all the posible operand values. */
161 t
=(int)((signed char)((insn
[0]<<1)&0xff));
164 print_operand (0, " $0", args
);
177 return 1; // size is always 1