6 #include "opcode/d10v.h"
8 #define DEBUG_TRACE 0x00000001
9 #define DEBUG_VALUES 0x00000002
10 #define DEBUG_MEMSIZE 0x00000004
11 #define DEBUG_INSTRUCTION 0x00000008
13 extern int d10v_debug
;
16 typedef unsigned char uint8
;
17 typedef signed char int8
;
19 #error "Char is not an 8-bit type"
23 typedef unsigned short uint16
;
24 typedef signed short int16
;
26 #error "Short is not a 16-bit type"
29 #if INT_MAX == 2147483647
30 typedef unsigned int uint32
;
31 typedef signed int int32
;
33 #elif LONG_MAX == 2147483647
34 typedef unsigned long uint32
;
35 typedef signed long int32
;
38 #error "Neither int nor long is a 32-bit type"
41 #if LONG_MAX > 2147483647
42 typedef unsigned long uint64
;
43 typedef signed long int64
;
46 typedef unsigned long long uint64
;
47 typedef signed long long int64
;
50 #error "Can't find an appropriate 64-bit type"
53 /* FIXME: D10V defines */
80 extern long ins_type_counters
[ (int)INS_MAX
];
81 extern long left_nops
, right_nops
;
85 reg_t regs
[16]; /* general-purpose registers */
86 reg_t cregs
[16]; /* control registers */
87 int64 a
[2]; /* accumulators */
103 enum _ins_type ins_type
;
106 extern host_callback
*d10v_callback
;
108 extern struct simops Simops
[];
110 #define PC (State.cregs[2])
111 #define PSW (State.cregs[0])
112 #define BPSW (State.cregs[1])
113 #define BPC (State.cregs[3])
114 #define RPT_C (State.cregs[7])
115 #define RPT_S (State.cregs[8])
116 #define RPT_E (State.cregs[9])
117 #define MOD_S (State.cregs[10])
118 #define MOD_E (State.cregs[11])
119 #define IBA (State.cregs[14])
121 #define SEXT3(x) ((((x)&0x7)^(~3))+4)
123 /* sign-extend a 4-bit number */
124 #define SEXT4(x) ((((x)&0xf)^(~7))+8)
126 /* sign-extend an 8-bit number */
127 #define SEXT8(x) ((((x)&0xff)^(~0x7f))+0x80)
129 /* sign-extend a 16-bit number */
130 #define SEXT16(x) ((((x)&0xffff)^(~0x7fff))+0x8000)
132 /* sign-extend a 32-bit number */
133 #define SEXT32(x) ((((x)&0xffffffffLL)^(~0x7fffffffLL))+0x80000000LL)
135 /* sign extend a 40 bit number */
136 #define SEXT40(x) ((((x)&0xffffffffffLL)^(~0x7fffffffffLL))+0x8000000000LL)
138 /* sign extend a 44 bit number */
139 #define SEXT44(x) ((((x)&0xfffffffffffLL)^(~0x7ffffffffffLL))+0x80000000000LL)
141 /* sign extend a 60 bit number */
142 #define SEXT60(x) ((((x)&0xfffffffffffffffLL)^(~0x7ffffffffffffffLL))+0x800000000000000LL)
144 #define MAX32 0x7fffffffLL
145 #define MIN32 0xff80000000LL
146 #define MASK32 0xffffffffLL
147 #define MASK40 0xffffffffffLL
149 #define INC_ADDR(x,i) x = ((State.MD && x == MOD_E) ? MOD_S : (x)+(i))
151 #define RB(x) (*((uint8 *)((x)+State.imem)))
152 #define SB(addr,data) ( RB(addr) = (data & 0xff))
154 #ifdef WORDS_BIGENDIAN
156 #define RW(x) (*((uint16 *)((x)+State.imem)))
157 #define RLW(x) (*((uint32 *)((x)+State.imem)))
158 #define SW(addr,data) RW(addr)=data
159 #define SLW(addr,data) RLW(addr)=data
160 #define READ_16(x) (*((int16 *)(x)))
161 #define WRITE_16(addr,data) (*(int16 *)(addr)=data)
162 #define READ_64(x) (*((int64 *)(x)))
163 #define WRITE_64(addr,data) (*(int64 *)(addr)=data)
167 uint32 get_longword
PARAMS ((uint8
*));
168 uint16 get_word
PARAMS ((uint8
*));
169 int64 get_longlong
PARAMS ((uint8
*));
170 void write_word
PARAMS ((uint8
*addr
, uint16 data
));
171 void write_longword
PARAMS ((uint8
*addr
, uint32 data
));
172 void write_longlong
PARAMS ((uint8
*addr
, int64 data
));
174 #define SW(addr,data) write_word((long)(addr)+State.imem,data)
175 #define RW(x) get_word((long)(x)+State.imem)
176 #define SLW(addr,data) write_longword((long)(addr)+State.imem,data)
177 #define RLW(x) get_longword((long)(x)+State.imem)
178 #define READ_16(x) get_word(x)
179 #define WRITE_16(addr,data) write_word(addr,data)
180 #define READ_64(x) get_longlong(x)
181 #define WRITE_64(addr,data) write_longlong(addr,data)
183 #endif /* not WORDS_BIGENDIAN */
This page took 0.033876 seconds and 4 git commands to generate.