6 #include "opcode/d10v.h"
8 #define DEBUG_TRACE 0x00000001
9 #define DEBUG_VALUES 0x00000002
10 #define DEBUG_LINE_NUMBER 0x00000004
11 #define DEBUG_MEMSIZE 0x00000008
12 #define DEBUG_INSTRUCTION 0x00000010
15 #define DEBUG (DEBUG_TRACE | DEBUG_VALUES | DEBUG_LINE_NUMBER)
18 extern int d10v_debug
;
21 typedef unsigned char uint8
;
22 typedef signed char int8
;
24 #error "Char is not an 8-bit type"
28 typedef unsigned short uint16
;
29 typedef signed short int16
;
31 #error "Short is not a 16-bit type"
34 #if INT_MAX == 2147483647
35 typedef unsigned int uint32
;
36 typedef signed int int32
;
38 #elif LONG_MAX == 2147483647
39 typedef unsigned long uint32
;
40 typedef signed long int32
;
43 #error "Neither int nor long is a 32-bit type"
46 #if LONG_MAX > 2147483647
47 typedef unsigned long uint64
;
48 typedef signed long int64
;
51 typedef unsigned long long uint64
;
52 typedef signed long long int64
;
55 #error "Can't find an appropriate 64-bit type"
58 /* FIXME: D10V defines */
85 extern long ins_type_counters
[ (int)INS_MAX
];
86 extern long left_nops
, right_nops
;
90 reg_t regs
[16]; /* general-purpose registers */
91 reg_t cregs
[16]; /* control registers */
92 int64 a
[2]; /* accumulators */
110 enum _ins_type ins_type
;
113 extern host_callback
*d10v_callback
;
115 extern struct simops Simops
[];
117 #define PC (State.cregs[2])
118 #define PSW (State.cregs[0])
119 #define BPSW (State.cregs[1])
120 #define BPC (State.cregs[3])
121 #define RPT_C (State.cregs[7])
122 #define RPT_S (State.cregs[8])
123 #define RPT_E (State.cregs[9])
124 #define MOD_S (State.cregs[10])
125 #define MOD_E (State.cregs[11])
126 #define IBA (State.cregs[14])
128 #define SIG_D10V_STOP -1
129 #define SIG_D10V_EXIT -2
131 #define SEXT3(x) ((((x)&0x7)^(~3))+4)
133 /* sign-extend a 4-bit number */
134 #define SEXT4(x) ((((x)&0xf)^(~7))+8)
136 /* sign-extend an 8-bit number */
137 #define SEXT8(x) ((((x)&0xff)^(~0x7f))+0x80)
139 /* sign-extend a 16-bit number */
140 #define SEXT16(x) ((((x)&0xffff)^(~0x7fff))+0x8000)
142 /* sign-extend a 32-bit number */
143 #define SEXT32(x) ((((x)&0xffffffffLL)^(~0x7fffffffLL))+0x80000000LL)
145 /* sign extend a 40 bit number */
146 #define SEXT40(x) ((((x)&0xffffffffffLL)^(~0x7fffffffffLL))+0x8000000000LL)
148 /* sign extend a 44 bit number */
149 #define SEXT44(x) ((((x)&0xfffffffffffLL)^(~0x7ffffffffffLL))+0x80000000000LL)
151 /* sign extend a 60 bit number */
152 #define SEXT60(x) ((((x)&0xfffffffffffffffLL)^(~0x7ffffffffffffffLL))+0x800000000000000LL)
154 #define MAX32 0x7fffffffLL
155 #define MIN32 0xff80000000LL
156 #define MASK32 0xffffffffLL
157 #define MASK40 0xffffffffffLL
159 #define INC_ADDR(x,i) x = ((State.MD && x == MOD_E) ? MOD_S : (x)+(i))
161 #define RB(x) (*((uint8 *)((x)+State.imem)))
162 #define SB(addr,data) ( RB(addr) = (data & 0xff))
164 #if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(NO_ENDIAN_INLINE)
165 #define ENDIAN_INLINE static __inline__
170 extern uint32 get_longword
PARAMS ((uint8
*));
171 extern uint16 get_word
PARAMS ((uint8
*));
172 extern int64 get_longlong
PARAMS ((uint8
*));
173 extern void write_word
PARAMS ((uint8
*addr
, uint16 data
));
174 extern void write_longword
PARAMS ((uint8
*addr
, uint32 data
));
175 extern void write_longlong
PARAMS ((uint8
*addr
, int64 data
));
178 #define SW(addr,data) write_word((long)(addr)+State.imem,data)
179 #define RW(x) get_word((long)(x)+State.imem)
180 #define SLW(addr,data) write_longword((long)(addr)+State.imem,data)
181 #define RLW(x) get_longword((long)(x)+State.imem)
182 #define READ_16(x) get_word(x)
183 #define WRITE_16(addr,data) write_word(addr,data)
184 #define READ_64(x) get_longlong(x)
185 #define WRITE_64(addr,data) write_longlong(addr,data)
This page took 0.033396 seconds and 4 git commands to generate.