]>
Commit | Line | Data |
---|---|---|
0fda6bd2 | 1 | /* Simulator for Motorola's MCore processor |
3666a048 | 2 | Copyright (C) 1999-2021 Free Software Foundation, Inc. |
2d514e6f SS |
3 | Contributed by Cygnus Solutions. |
4 | ||
5 | This file is part of GDB, the GNU debugger. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
4744ac1b JB |
9 | the Free Software Foundation; either version 3 of the License, or |
10 | (at your option) any later version. | |
2d514e6f SS |
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 | ||
4744ac1b JB |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
2d514e6f | 19 | |
3550b236 | 20 | #include "config.h" |
2d514e6f | 21 | #include <signal.h> |
dc049bf4 MF |
22 | #include <stdlib.h> |
23 | #include <string.h> | |
2d514e6f | 24 | #include <sys/param.h> |
4185814e | 25 | #include <unistd.h> |
2d514e6f | 26 | #include "bfd.h" |
df68e12b | 27 | #include "sim/callback.h" |
2d514e6f | 28 | #include "libiberty.h" |
df68e12b | 29 | #include "sim/sim.h" |
2d514e6f | 30 | |
ea6b7543 MF |
31 | #include "sim-main.h" |
32 | #include "sim-base.h" | |
61a0c964 | 33 | #include "sim-syscall.h" |
ea6b7543 MF |
34 | #include "sim-options.h" |
35 | ||
ea6b7543 | 36 | #define target_big_endian (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) |
2d514e6f SS |
37 | |
38 | ||
feb703b3 MF |
39 | static unsigned long |
40 | mcore_extract_unsigned_integer (unsigned char *addr, int len) | |
2d514e6f SS |
41 | { |
42 | unsigned long retval; | |
43 | unsigned char * p; | |
44 | unsigned char * startaddr = (unsigned char *)addr; | |
45 | unsigned char * endaddr = startaddr + len; | |
ba14f941 | 46 | |
2d514e6f | 47 | if (len > (int) sizeof (unsigned long)) |
feb703b3 | 48 | printf ("That operation is not available on integers of more than %zu bytes.", |
2d514e6f | 49 | sizeof (unsigned long)); |
ba14f941 | 50 | |
2d514e6f SS |
51 | /* Start at the most significant end of the integer, and work towards |
52 | the least significant. */ | |
53 | retval = 0; | |
cd0fc7c3 | 54 | |
63a027a3 NC |
55 | if (! target_big_endian) |
56 | { | |
57 | for (p = endaddr; p > startaddr;) | |
58 | retval = (retval << 8) | * -- p; | |
59 | } | |
60 | else | |
cd0fc7c3 SS |
61 | { |
62 | for (p = startaddr; p < endaddr;) | |
63 | retval = (retval << 8) | * p ++; | |
64 | } | |
ba14f941 | 65 | |
2d514e6f SS |
66 | return retval; |
67 | } | |
68 | ||
feb703b3 MF |
69 | static void |
70 | mcore_store_unsigned_integer (unsigned char *addr, int len, unsigned long val) | |
2d514e6f SS |
71 | { |
72 | unsigned char * p; | |
73 | unsigned char * startaddr = (unsigned char *)addr; | |
74 | unsigned char * endaddr = startaddr + len; | |
cd0fc7c3 | 75 | |
63a027a3 NC |
76 | if (! target_big_endian) |
77 | { | |
78 | for (p = startaddr; p < endaddr;) | |
79 | { | |
80 | * p ++ = val & 0xff; | |
81 | val >>= 8; | |
82 | } | |
83 | } | |
84 | else | |
2d514e6f | 85 | { |
cd0fc7c3 SS |
86 | for (p = endaddr; p > startaddr;) |
87 | { | |
88 | * -- p = val & 0xff; | |
89 | val >>= 8; | |
90 | } | |
2d514e6f SS |
91 | } |
92 | } | |
93 | ||
ea6b7543 | 94 | static int memcycles = 1; |
2d514e6f | 95 | |
7eed1055 MF |
96 | #define gr cpu->active_gregs |
97 | #define cr cpu->regs.cregs | |
98 | #define sr cr[0] | |
99 | #define vbr cr[1] | |
100 | #define esr cr[2] | |
101 | #define fsr cr[3] | |
102 | #define epc cr[4] | |
103 | #define fpc cr[5] | |
104 | #define ss0 cr[6] | |
105 | #define ss1 cr[7] | |
106 | #define ss2 cr[8] | |
107 | #define ss3 cr[9] | |
108 | #define ss4 cr[10] | |
109 | #define gcr cr[11] | |
110 | #define gsr cr[12] | |
2d514e6f SS |
111 | |
112 | /* maniuplate the carry bit */ | |
7eed1055 MF |
113 | #define C_ON() (sr & 1) |
114 | #define C_VALUE() (sr & 1) | |
115 | #define C_OFF() ((sr & 1) == 0) | |
116 | #define SET_C() {sr |= 1;} | |
117 | #define CLR_C() {sr &= 0xfffffffe;} | |
118 | #define NEW_C(v) {CLR_C(); sr |= ((v) & 1);} | |
119 | ||
120 | #define SR_AF() ((sr >> 1) & 1) | |
121 | static void set_active_regs (SIM_CPU *cpu) | |
122 | { | |
123 | if (SR_AF()) | |
124 | cpu->active_gregs = cpu->regs.alt_gregs; | |
125 | else | |
126 | cpu->active_gregs = cpu->regs.gregs; | |
127 | } | |
2d514e6f SS |
128 | |
129 | #define TRAPCODE 1 /* r1 holds which function we want */ | |
130 | #define PARM1 2 /* first parameter */ | |
131 | #define PARM2 3 | |
132 | #define PARM3 4 | |
133 | #define PARM4 5 | |
134 | #define RET1 2 /* register for return values. */ | |
135 | ||
4cd93614 | 136 | /* Default to a 8 Mbyte (== 2^23) memory space. */ |
f63036b8 | 137 | #define DEFAULT_MEMORY_SIZE 0x800000 |
2d514e6f SS |
138 | |
139 | static void | |
7eed1055 | 140 | set_initial_gprs (SIM_CPU *cpu) |
2d514e6f | 141 | { |
2d514e6f | 142 | /* Set up machine just out of reset. */ |
7eed1055 MF |
143 | CPU_PC_SET (cpu, 0); |
144 | sr = 0; | |
ba14f941 | 145 | |
2d514e6f | 146 | /* Clean out the GPRs and alternate GPRs. */ |
7eed1055 MF |
147 | memset (&cpu->regs.gregs, 0, sizeof(cpu->regs.gregs)); |
148 | memset (&cpu->regs.alt_gregs, 0, sizeof(cpu->regs.alt_gregs)); | |
ba14f941 | 149 | |
2d514e6f | 150 | /* Make our register set point to the right place. */ |
7eed1055 | 151 | set_active_regs (cpu); |
ba14f941 | 152 | |
2d514e6f | 153 | /* ABI specifies initial values for these registers. */ |
7eed1055 | 154 | gr[0] = DEFAULT_MEMORY_SIZE - 4; |
ba14f941 | 155 | |
2d514e6f | 156 | /* dac fix, the stack address must be 8-byte aligned! */ |
7eed1055 MF |
157 | gr[0] = gr[0] - gr[0] % 8; |
158 | gr[PARM1] = 0; | |
159 | gr[PARM2] = 0; | |
160 | gr[PARM3] = 0; | |
161 | gr[PARM4] = gr[0]; | |
2d514e6f SS |
162 | } |
163 | ||
767e68f1 MF |
164 | /* Simulate a monitor trap. */ |
165 | ||
2d514e6f | 166 | static void |
7eed1055 | 167 | handle_trap1 (SIM_DESC sd, SIM_CPU *cpu) |
2d514e6f | 168 | { |
767e68f1 | 169 | /* XXX: We don't pass back the actual errno value. */ |
7eed1055 MF |
170 | gr[RET1] = sim_syscall (cpu, gr[TRAPCODE], gr[PARM1], gr[PARM2], gr[PARM3], |
171 | gr[PARM4]); | |
2d514e6f SS |
172 | } |
173 | ||
174 | static void | |
7eed1055 | 175 | process_stub (SIM_DESC sd, SIM_CPU *cpu, int what) |
2d514e6f SS |
176 | { |
177 | /* These values should match those in libgloss/mcore/syscalls.s. */ | |
178 | switch (what) | |
179 | { | |
180 | case 3: /* _read */ | |
cd0fc7c3 | 181 | case 4: /* _write */ |
2d514e6f SS |
182 | case 5: /* _open */ |
183 | case 6: /* _close */ | |
184 | case 10: /* _unlink */ | |
185 | case 19: /* _lseek */ | |
186 | case 43: /* _times */ | |
7eed1055 MF |
187 | gr[TRAPCODE] = what; |
188 | handle_trap1 (sd, cpu); | |
2d514e6f | 189 | break; |
ba14f941 | 190 | |
2d514e6f | 191 | default: |
f63036b8 | 192 | if (STATE_VERBOSE_P (sd)) |
2d514e6f SS |
193 | fprintf (stderr, "Unhandled stub opcode: %d\n", what); |
194 | break; | |
195 | } | |
196 | } | |
197 | ||
198 | static void | |
7eed1055 | 199 | util (SIM_DESC sd, SIM_CPU *cpu, unsigned what) |
2d514e6f SS |
200 | { |
201 | switch (what) | |
202 | { | |
203 | case 0: /* exit */ | |
7eed1055 | 204 | sim_engine_halt (sd, cpu, NULL, cpu->regs.pc, sim_exited, gr[PARM1]); |
2d514e6f SS |
205 | break; |
206 | ||
207 | case 1: /* printf */ | |
f63036b8 MF |
208 | if (STATE_VERBOSE_P (sd)) |
209 | fprintf (stderr, "WARNING: printf unimplemented\n"); | |
2d514e6f | 210 | break; |
ba14f941 | 211 | |
2d514e6f | 212 | case 2: /* scanf */ |
f63036b8 | 213 | if (STATE_VERBOSE_P (sd)) |
2d514e6f SS |
214 | fprintf (stderr, "WARNING: scanf unimplemented\n"); |
215 | break; | |
ba14f941 | 216 | |
2d514e6f | 217 | case 3: /* utime */ |
7eed1055 | 218 | gr[RET1] = cpu->insts; |
2d514e6f SS |
219 | break; |
220 | ||
221 | case 0xFF: | |
7eed1055 | 222 | process_stub (sd, cpu, gr[1]); |
2d514e6f | 223 | break; |
ba14f941 | 224 | |
2d514e6f | 225 | default: |
f63036b8 | 226 | if (STATE_VERBOSE_P (sd)) |
2d514e6f SS |
227 | fprintf (stderr, "Unhandled util code: %x\n", what); |
228 | break; | |
229 | } | |
ba14f941 | 230 | } |
2d514e6f SS |
231 | |
232 | /* For figuring out whether we carried; addc/subc use this. */ | |
233 | static int | |
feb703b3 | 234 | iu_carry (unsigned long a, unsigned long b, int cin) |
2d514e6f SS |
235 | { |
236 | unsigned long x; | |
ba14f941 | 237 | |
2d514e6f SS |
238 | x = (a & 0xffff) + (b & 0xffff) + cin; |
239 | x = (x >> 16) + (a >> 16) + (b >> 16); | |
240 | x >>= 16; | |
241 | ||
242 | return (x != 0); | |
243 | } | |
244 | ||
e53e5aab MF |
245 | /* TODO: Convert to common watchpoints. */ |
246 | #undef WATCHFUNCTIONS | |
2d514e6f SS |
247 | #ifdef WATCHFUNCTIONS |
248 | ||
249 | #define MAXWL 80 | |
250 | word WL[MAXWL]; | |
251 | char * WLstr[MAXWL]; | |
252 | ||
253 | int ENDWL=0; | |
254 | int WLincyc; | |
255 | int WLcyc[MAXWL]; | |
256 | int WLcnts[MAXWL]; | |
257 | int WLmax[MAXWL]; | |
258 | int WLmin[MAXWL]; | |
259 | word WLendpc; | |
260 | int WLbcyc; | |
261 | int WLW; | |
262 | #endif | |
263 | ||
264 | #define RD (inst & 0xF) | |
265 | #define RS ((inst >> 4) & 0xF) | |
266 | #define RX ((inst >> 8) & 0xF) | |
267 | #define IMM5 ((inst >> 4) & 0x1F) | |
268 | #define IMM4 ((inst) & 0xF) | |
269 | ||
7eed1055 MF |
270 | #define rbat(X) sim_core_read_1 (cpu, 0, read_map, X) |
271 | #define rhat(X) sim_core_read_2 (cpu, 0, read_map, X) | |
272 | #define rlat(X) sim_core_read_4 (cpu, 0, read_map, X) | |
273 | #define wbat(X, D) sim_core_write_1 (cpu, 0, write_map, X, D) | |
274 | #define what(X, D) sim_core_write_2 (cpu, 0, write_map, X, D) | |
275 | #define wlat(X, D) sim_core_write_4 (cpu, 0, write_map, X, D) | |
f63036b8 | 276 | |
2d514e6f SS |
277 | static int tracing = 0; |
278 | ||
02962cd9 | 279 | #define ILLEGAL() \ |
7eed1055 | 280 | sim_engine_halt (sd, cpu, NULL, pc, sim_stopped, SIM_SIGILL) |
02962cd9 MF |
281 | |
282 | static void | |
7eed1055 | 283 | step_once (SIM_DESC sd, SIM_CPU *cpu) |
2d514e6f SS |
284 | { |
285 | int needfetch; | |
286 | word ibuf; | |
287 | word pc; | |
288 | unsigned short inst; | |
2d514e6f SS |
289 | int memops; |
290 | int bonus_cycles; | |
291 | int insts; | |
292 | int w; | |
293 | int cycs; | |
e53e5aab | 294 | #ifdef WATCHFUNCTIONS |
2d514e6f | 295 | word WLhash; |
e53e5aab | 296 | #endif |
2d514e6f | 297 | |
7eed1055 | 298 | pc = CPU_PC_GET (cpu); |
2d514e6f | 299 | |
cd0fc7c3 | 300 | /* Fetch the initial instructions that we'll decode. */ |
2d514e6f SS |
301 | ibuf = rlat (pc & 0xFFFFFFFC); |
302 | needfetch = 0; | |
303 | ||
304 | memops = 0; | |
305 | bonus_cycles = 0; | |
306 | insts = 0; | |
ba14f941 | 307 | |
2d514e6f | 308 | /* make our register set point to the right place */ |
7eed1055 | 309 | set_active_regs (cpu); |
ba14f941 | 310 | |
e53e5aab | 311 | #ifdef WATCHFUNCTIONS |
2d514e6f SS |
312 | /* make a hash to speed exec loop, hope it's nonzero */ |
313 | WLhash = 0xFFFFFFFF; | |
314 | ||
315 | for (w = 1; w <= ENDWL; w++) | |
316 | WLhash = WLhash & WL[w]; | |
e53e5aab | 317 | #endif |
2d514e6f | 318 | |
02962cd9 | 319 | /* TODO: Unindent this block. */ |
2d514e6f | 320 | { |
cd0fc7c3 | 321 | word oldpc; |
ba14f941 | 322 | |
2d514e6f | 323 | insts ++; |
ba14f941 | 324 | |
2d514e6f SS |
325 | if (pc & 02) |
326 | { | |
63a027a3 NC |
327 | if (! target_big_endian) |
328 | inst = ibuf >> 16; | |
329 | else | |
cd0fc7c3 | 330 | inst = ibuf & 0xFFFF; |
2d514e6f SS |
331 | needfetch = 1; |
332 | } | |
333 | else | |
334 | { | |
63a027a3 NC |
335 | if (! target_big_endian) |
336 | inst = ibuf & 0xFFFF; | |
337 | else | |
cd0fc7c3 | 338 | inst = ibuf >> 16; |
2d514e6f SS |
339 | } |
340 | ||
341 | #ifdef WATCHFUNCTIONS | |
342 | /* now scan list of watch addresses, if match, count it and | |
343 | note return address and count cycles until pc=return address */ | |
ba14f941 | 344 | |
2d514e6f SS |
345 | if ((WLincyc == 1) && (pc == WLendpc)) |
346 | { | |
7eed1055 | 347 | cycs = (cpu->cycles + (insts + bonus_cycles + |
2d514e6f | 348 | (memops * memcycles)) - WLbcyc); |
ba14f941 | 349 | |
2d514e6f SS |
350 | if (WLcnts[WLW] == 1) |
351 | { | |
352 | WLmax[WLW] = cycs; | |
353 | WLmin[WLW] = cycs; | |
354 | WLcyc[WLW] = 0; | |
355 | } | |
ba14f941 | 356 | |
2d514e6f SS |
357 | if (cycs > WLmax[WLW]) |
358 | { | |
359 | WLmax[WLW] = cycs; | |
360 | } | |
ba14f941 | 361 | |
2d514e6f SS |
362 | if (cycs < WLmin[WLW]) |
363 | { | |
364 | WLmin[WLW] = cycs; | |
365 | } | |
ba14f941 | 366 | |
2d514e6f SS |
367 | WLcyc[WLW] += cycs; |
368 | WLincyc = 0; | |
369 | WLendpc = 0; | |
ba14f941 | 370 | } |
2d514e6f | 371 | |
cd0fc7c3 | 372 | /* Optimize with a hash to speed loop. */ |
2d514e6f SS |
373 | if (WLincyc == 0) |
374 | { | |
375 | if ((WLhash == 0) || ((WLhash & pc) != 0)) | |
376 | { | |
377 | for (w=1; w <= ENDWL; w++) | |
378 | { | |
379 | if (pc == WL[w]) | |
380 | { | |
381 | WLcnts[w]++; | |
7eed1055 | 382 | WLbcyc = cpu->cycles + insts |
2d514e6f | 383 | + bonus_cycles + (memops * memcycles); |
7eed1055 | 384 | WLendpc = gr[15]; |
2d514e6f SS |
385 | WLincyc = 1; |
386 | WLW = w; | |
387 | break; | |
388 | } | |
389 | } | |
390 | } | |
391 | } | |
392 | #endif | |
393 | ||
394 | if (tracing) | |
43236bb2 | 395 | fprintf (stderr, "%.4lx: inst = %.4x ", pc, inst); |
cd0fc7c3 SS |
396 | |
397 | oldpc = pc; | |
ba14f941 | 398 | |
2d514e6f | 399 | pc += 2; |
ba14f941 | 400 | |
2d514e6f SS |
401 | switch (inst >> 8) |
402 | { | |
403 | case 0x00: | |
404 | switch RS | |
405 | { | |
406 | case 0x0: | |
407 | switch RD | |
408 | { | |
409 | case 0x0: /* bkpt */ | |
9e086581 | 410 | pc -= 2; |
7eed1055 | 411 | sim_engine_halt (sd, cpu, NULL, pc - 2, |
02962cd9 | 412 | sim_stopped, SIM_SIGTRAP); |
2d514e6f | 413 | break; |
ba14f941 | 414 | |
2d514e6f SS |
415 | case 0x1: /* sync */ |
416 | break; | |
ba14f941 | 417 | |
2d514e6f | 418 | case 0x2: /* rte */ |
7eed1055 MF |
419 | pc = epc; |
420 | sr = esr; | |
2d514e6f | 421 | needfetch = 1; |
ba14f941 | 422 | |
7eed1055 | 423 | set_active_regs (cpu); |
2d514e6f SS |
424 | break; |
425 | ||
426 | case 0x3: /* rfi */ | |
7eed1055 MF |
427 | pc = fpc; |
428 | sr = fsr; | |
2d514e6f SS |
429 | needfetch = 1; |
430 | ||
7eed1055 | 431 | set_active_regs (cpu); |
2d514e6f | 432 | break; |
ba14f941 | 433 | |
2d514e6f | 434 | case 0x4: /* stop */ |
f63036b8 | 435 | if (STATE_VERBOSE_P (sd)) |
2d514e6f SS |
436 | fprintf (stderr, "WARNING: stop unimplemented\n"); |
437 | break; | |
ba14f941 | 438 | |
2d514e6f | 439 | case 0x5: /* wait */ |
f63036b8 | 440 | if (STATE_VERBOSE_P (sd)) |
2d514e6f SS |
441 | fprintf (stderr, "WARNING: wait unimplemented\n"); |
442 | break; | |
ba14f941 | 443 | |
2d514e6f | 444 | case 0x6: /* doze */ |
f63036b8 | 445 | if (STATE_VERBOSE_P (sd)) |
cd0fc7c3 | 446 | fprintf (stderr, "WARNING: doze unimplemented\n"); |
2d514e6f | 447 | break; |
ba14f941 | 448 | |
2d514e6f | 449 | case 0x7: |
02962cd9 | 450 | ILLEGAL (); /* illegal */ |
2d514e6f | 451 | break; |
ba14f941 | 452 | |
2d514e6f SS |
453 | case 0x8: /* trap 0 */ |
454 | case 0xA: /* trap 2 */ | |
455 | case 0xB: /* trap 3 */ | |
7eed1055 | 456 | sim_engine_halt (sd, cpu, NULL, pc, |
02962cd9 | 457 | sim_stopped, SIM_SIGTRAP); |
2d514e6f | 458 | break; |
ba14f941 | 459 | |
2d514e6f SS |
460 | case 0xC: /* trap 4 */ |
461 | case 0xD: /* trap 5 */ | |
462 | case 0xE: /* trap 6 */ | |
02962cd9 | 463 | ILLEGAL (); /* illegal */ |
2d514e6f | 464 | break; |
ba14f941 | 465 | |
2d514e6f | 466 | case 0xF: /* trap 7 */ |
7eed1055 | 467 | sim_engine_halt (sd, cpu, NULL, pc, /* integer div-by-0 */ |
02962cd9 | 468 | sim_stopped, SIM_SIGTRAP); |
2d514e6f | 469 | break; |
ba14f941 | 470 | |
2d514e6f | 471 | case 0x9: /* trap 1 */ |
7eed1055 | 472 | handle_trap1 (sd, cpu); |
2d514e6f SS |
473 | break; |
474 | } | |
475 | break; | |
ba14f941 | 476 | |
2d514e6f | 477 | case 0x1: |
02962cd9 | 478 | ILLEGAL (); /* illegal */ |
2d514e6f | 479 | break; |
ba14f941 | 480 | |
2d514e6f | 481 | case 0x2: /* mvc */ |
7eed1055 | 482 | gr[RD] = C_VALUE(); |
2d514e6f SS |
483 | break; |
484 | case 0x3: /* mvcv */ | |
7eed1055 | 485 | gr[RD] = C_OFF(); |
2d514e6f SS |
486 | break; |
487 | case 0x4: /* ldq */ | |
488 | { | |
7eed1055 | 489 | word addr = gr[RD]; |
2d514e6f | 490 | int regno = 4; /* always r4-r7 */ |
ba14f941 | 491 | |
2d514e6f SS |
492 | bonus_cycles++; |
493 | memops += 4; | |
494 | do | |
495 | { | |
7eed1055 | 496 | gr[regno] = rlat (addr); |
2d514e6f SS |
497 | addr += 4; |
498 | regno++; | |
499 | } | |
500 | while ((regno&0x3) != 0); | |
501 | } | |
502 | break; | |
503 | case 0x5: /* stq */ | |
504 | { | |
7eed1055 | 505 | word addr = gr[RD]; |
2d514e6f | 506 | int regno = 4; /* always r4-r7 */ |
ba14f941 | 507 | |
2d514e6f SS |
508 | memops += 4; |
509 | bonus_cycles++; | |
510 | do | |
511 | { | |
7eed1055 | 512 | wlat (addr, gr[regno]); |
2d514e6f SS |
513 | addr += 4; |
514 | regno++; | |
515 | } | |
516 | while ((regno & 0x3) != 0); | |
517 | } | |
518 | break; | |
519 | case 0x6: /* ldm */ | |
520 | { | |
7eed1055 | 521 | word addr = gr[0]; |
2d514e6f | 522 | int regno = RD; |
ba14f941 | 523 | |
2d514e6f SS |
524 | /* bonus cycle is really only needed if |
525 | the next insn shifts the last reg loaded. | |
ba14f941 | 526 | |
2d514e6f SS |
527 | bonus_cycles++; |
528 | */ | |
529 | memops += 16-regno; | |
530 | while (regno <= 0xF) | |
531 | { | |
7eed1055 | 532 | gr[regno] = rlat (addr); |
2d514e6f SS |
533 | addr += 4; |
534 | regno++; | |
535 | } | |
536 | } | |
537 | break; | |
538 | case 0x7: /* stm */ | |
539 | { | |
7eed1055 | 540 | word addr = gr[0]; |
2d514e6f | 541 | int regno = RD; |
ba14f941 | 542 | |
2d514e6f SS |
543 | /* this should be removed! */ |
544 | /* bonus_cycles ++; */ | |
545 | ||
546 | memops += 16 - regno; | |
547 | while (regno <= 0xF) | |
548 | { | |
7eed1055 | 549 | wlat (addr, gr[regno]); |
2d514e6f SS |
550 | addr += 4; |
551 | regno++; | |
552 | } | |
553 | } | |
554 | break; | |
555 | ||
556 | case 0x8: /* dect */ | |
7eed1055 | 557 | gr[RD] -= C_VALUE(); |
2d514e6f SS |
558 | break; |
559 | case 0x9: /* decf */ | |
7eed1055 | 560 | gr[RD] -= C_OFF(); |
2d514e6f SS |
561 | break; |
562 | case 0xA: /* inct */ | |
7eed1055 | 563 | gr[RD] += C_VALUE(); |
2d514e6f SS |
564 | break; |
565 | case 0xB: /* incf */ | |
7eed1055 | 566 | gr[RD] += C_OFF(); |
2d514e6f SS |
567 | break; |
568 | case 0xC: /* jmp */ | |
7eed1055 | 569 | pc = gr[RD]; |
392a587b | 570 | if (tracing && RD == 15) |
43236bb2 | 571 | fprintf (stderr, "Func return, r2 = %lxx, r3 = %lx\n", |
7eed1055 | 572 | gr[2], gr[3]); |
2d514e6f SS |
573 | bonus_cycles++; |
574 | needfetch = 1; | |
575 | break; | |
576 | case 0xD: /* jsr */ | |
7eed1055 MF |
577 | gr[15] = pc; |
578 | pc = gr[RD]; | |
2d514e6f SS |
579 | bonus_cycles++; |
580 | needfetch = 1; | |
581 | break; | |
582 | case 0xE: /* ff1 */ | |
583 | { | |
584 | word tmp, i; | |
7eed1055 | 585 | tmp = gr[RD]; |
2d514e6f SS |
586 | for (i = 0; !(tmp & 0x80000000) && i < 32; i++) |
587 | tmp <<= 1; | |
7eed1055 | 588 | gr[RD] = i; |
2d514e6f SS |
589 | } |
590 | break; | |
591 | case 0xF: /* brev */ | |
592 | { | |
593 | word tmp; | |
7eed1055 | 594 | tmp = gr[RD]; |
2d514e6f SS |
595 | tmp = ((tmp & 0xaaaaaaaa) >> 1) | ((tmp & 0x55555555) << 1); |
596 | tmp = ((tmp & 0xcccccccc) >> 2) | ((tmp & 0x33333333) << 2); | |
597 | tmp = ((tmp & 0xf0f0f0f0) >> 4) | ((tmp & 0x0f0f0f0f) << 4); | |
598 | tmp = ((tmp & 0xff00ff00) >> 8) | ((tmp & 0x00ff00ff) << 8); | |
7eed1055 | 599 | gr[RD] = ((tmp & 0xffff0000) >> 16) | ((tmp & 0x0000ffff) << 16); |
2d514e6f SS |
600 | } |
601 | break; | |
602 | } | |
603 | break; | |
604 | case 0x01: | |
605 | switch RS | |
606 | { | |
ba14f941 | 607 | case 0x0: /* xtrb3 */ |
7eed1055 MF |
608 | gr[1] = (gr[RD]) & 0xFF; |
609 | NEW_C (gr[RD] != 0); | |
2d514e6f SS |
610 | break; |
611 | case 0x1: /* xtrb2 */ | |
7eed1055 MF |
612 | gr[1] = (gr[RD]>>8) & 0xFF; |
613 | NEW_C (gr[RD] != 0); | |
2d514e6f SS |
614 | break; |
615 | case 0x2: /* xtrb1 */ | |
7eed1055 MF |
616 | gr[1] = (gr[RD]>>16) & 0xFF; |
617 | NEW_C (gr[RD] != 0); | |
2d514e6f SS |
618 | break; |
619 | case 0x3: /* xtrb0 */ | |
7eed1055 MF |
620 | gr[1] = (gr[RD]>>24) & 0xFF; |
621 | NEW_C (gr[RD] != 0); | |
2d514e6f SS |
622 | break; |
623 | case 0x4: /* zextb */ | |
7eed1055 | 624 | gr[RD] &= 0x000000FF; |
2d514e6f SS |
625 | break; |
626 | case 0x5: /* sextb */ | |
627 | { | |
628 | long tmp; | |
7eed1055 | 629 | tmp = gr[RD]; |
2d514e6f SS |
630 | tmp <<= 24; |
631 | tmp >>= 24; | |
7eed1055 | 632 | gr[RD] = tmp; |
2d514e6f SS |
633 | } |
634 | break; | |
635 | case 0x6: /* zexth */ | |
7eed1055 | 636 | gr[RD] &= 0x0000FFFF; |
2d514e6f SS |
637 | break; |
638 | case 0x7: /* sexth */ | |
639 | { | |
640 | long tmp; | |
7eed1055 | 641 | tmp = gr[RD]; |
2d514e6f SS |
642 | tmp <<= 16; |
643 | tmp >>= 16; | |
7eed1055 | 644 | gr[RD] = tmp; |
2d514e6f SS |
645 | } |
646 | break; | |
ba14f941 | 647 | case 0x8: /* declt */ |
7eed1055 MF |
648 | --gr[RD]; |
649 | NEW_C ((long)gr[RD] < 0); | |
2d514e6f SS |
650 | break; |
651 | case 0x9: /* tstnbz */ | |
652 | { | |
7eed1055 | 653 | word tmp = gr[RD]; |
2d514e6f SS |
654 | NEW_C ((tmp & 0xFF000000) != 0 && |
655 | (tmp & 0x00FF0000) != 0 && (tmp & 0x0000FF00) != 0 && | |
656 | (tmp & 0x000000FF) != 0); | |
657 | } | |
ba14f941 | 658 | break; |
2d514e6f | 659 | case 0xA: /* decgt */ |
7eed1055 MF |
660 | --gr[RD]; |
661 | NEW_C ((long)gr[RD] > 0); | |
2d514e6f SS |
662 | break; |
663 | case 0xB: /* decne */ | |
7eed1055 MF |
664 | --gr[RD]; |
665 | NEW_C ((long)gr[RD] != 0); | |
2d514e6f SS |
666 | break; |
667 | case 0xC: /* clrt */ | |
668 | if (C_ON()) | |
7eed1055 | 669 | gr[RD] = 0; |
2d514e6f SS |
670 | break; |
671 | case 0xD: /* clrf */ | |
672 | if (C_OFF()) | |
7eed1055 | 673 | gr[RD] = 0; |
2d514e6f SS |
674 | break; |
675 | case 0xE: /* abs */ | |
7eed1055 MF |
676 | if (gr[RD] & 0x80000000) |
677 | gr[RD] = ~gr[RD] + 1; | |
2d514e6f SS |
678 | break; |
679 | case 0xF: /* not */ | |
7eed1055 | 680 | gr[RD] = ~gr[RD]; |
2d514e6f SS |
681 | break; |
682 | } | |
683 | break; | |
684 | case 0x02: /* movt */ | |
685 | if (C_ON()) | |
7eed1055 | 686 | gr[RD] = gr[RS]; |
2d514e6f SS |
687 | break; |
688 | case 0x03: /* mult */ | |
689 | /* consume 2 bits per cycle from rs, until rs is 0 */ | |
690 | { | |
7eed1055 | 691 | unsigned int t = gr[RS]; |
2d514e6f | 692 | int ticks; |
ba14f941 | 693 | for (ticks = 0; t != 0 ; t >>= 2) |
2d514e6f SS |
694 | ticks++; |
695 | bonus_cycles += ticks; | |
696 | } | |
697 | bonus_cycles += 2; /* min. is 3, so add 2, plus ticks above */ | |
392a587b | 698 | if (tracing) |
43236bb2 | 699 | fprintf (stderr, " mult %lx by %lx to give %lx", |
7eed1055 MF |
700 | gr[RD], gr[RS], gr[RD] * gr[RS]); |
701 | gr[RD] = gr[RD] * gr[RS]; | |
2d514e6f SS |
702 | break; |
703 | case 0x04: /* loopt */ | |
704 | if (C_ON()) | |
705 | { | |
706 | pc += (IMM4 << 1) - 32; | |
707 | bonus_cycles ++; | |
708 | needfetch = 1; | |
709 | } | |
7eed1055 MF |
710 | --gr[RS]; /* not RD! */ |
711 | NEW_C (((long)gr[RS]) > 0); | |
ba14f941 | 712 | break; |
2d514e6f | 713 | case 0x05: /* subu */ |
7eed1055 | 714 | gr[RD] -= gr[RS]; |
2d514e6f SS |
715 | break; |
716 | case 0x06: /* addc */ | |
717 | { | |
718 | unsigned long tmp, a, b; | |
7eed1055 MF |
719 | a = gr[RD]; |
720 | b = gr[RS]; | |
721 | gr[RD] = a + b + C_VALUE (); | |
2d514e6f SS |
722 | tmp = iu_carry (a, b, C_VALUE ()); |
723 | NEW_C (tmp); | |
724 | } | |
725 | break; | |
726 | case 0x07: /* subc */ | |
727 | { | |
728 | unsigned long tmp, a, b; | |
7eed1055 MF |
729 | a = gr[RD]; |
730 | b = gr[RS]; | |
731 | gr[RD] = a - b + C_VALUE () - 1; | |
2d514e6f SS |
732 | tmp = iu_carry (a,~b, C_VALUE ()); |
733 | NEW_C (tmp); | |
734 | } | |
735 | break; | |
736 | case 0x08: /* illegal */ | |
737 | case 0x09: /* illegal*/ | |
02962cd9 | 738 | ILLEGAL (); |
2d514e6f SS |
739 | break; |
740 | case 0x0A: /* movf */ | |
741 | if (C_OFF()) | |
7eed1055 | 742 | gr[RD] = gr[RS]; |
2d514e6f SS |
743 | break; |
744 | case 0x0B: /* lsr */ | |
ba14f941 | 745 | { |
2d514e6f | 746 | unsigned long dst, src; |
7eed1055 MF |
747 | dst = gr[RD]; |
748 | src = gr[RS]; | |
c5394b80 JM |
749 | /* We must not rely solely upon the native shift operations, since they |
750 | may not match the M*Core's behaviour on boundary conditions. */ | |
751 | dst = src > 31 ? 0 : dst >> src; | |
7eed1055 | 752 | gr[RD] = dst; |
2d514e6f SS |
753 | } |
754 | break; | |
755 | case 0x0C: /* cmphs */ | |
7eed1055 MF |
756 | NEW_C ((unsigned long )gr[RD] >= |
757 | (unsigned long)gr[RS]); | |
2d514e6f SS |
758 | break; |
759 | case 0x0D: /* cmplt */ | |
7eed1055 | 760 | NEW_C ((long)gr[RD] < (long)gr[RS]); |
2d514e6f SS |
761 | break; |
762 | case 0x0E: /* tst */ | |
7eed1055 | 763 | NEW_C ((gr[RD] & gr[RS]) != 0); |
2d514e6f SS |
764 | break; |
765 | case 0x0F: /* cmpne */ | |
7eed1055 | 766 | NEW_C (gr[RD] != gr[RS]); |
2d514e6f SS |
767 | break; |
768 | case 0x10: case 0x11: /* mfcr */ | |
769 | { | |
770 | unsigned r; | |
771 | r = IMM5; | |
772 | if (r <= LAST_VALID_CREG) | |
7eed1055 | 773 | gr[RD] = cr[r]; |
2d514e6f | 774 | else |
02962cd9 | 775 | ILLEGAL (); |
2d514e6f SS |
776 | } |
777 | break; | |
778 | ||
779 | case 0x12: /* mov */ | |
7eed1055 | 780 | gr[RD] = gr[RS]; |
392a587b | 781 | if (tracing) |
7eed1055 | 782 | fprintf (stderr, "MOV %lx into reg %d", gr[RD], RD); |
2d514e6f SS |
783 | break; |
784 | ||
785 | case 0x13: /* bgenr */ | |
7eed1055 MF |
786 | if (gr[RS] & 0x20) |
787 | gr[RD] = 0; | |
2d514e6f | 788 | else |
7eed1055 | 789 | gr[RD] = 1 << (gr[RS] & 0x1F); |
2d514e6f SS |
790 | break; |
791 | ||
792 | case 0x14: /* rsub */ | |
7eed1055 | 793 | gr[RD] = gr[RS] - gr[RD]; |
2d514e6f SS |
794 | break; |
795 | ||
796 | case 0x15: /* ixw */ | |
7eed1055 | 797 | gr[RD] += gr[RS]<<2; |
2d514e6f SS |
798 | break; |
799 | ||
800 | case 0x16: /* and */ | |
7eed1055 | 801 | gr[RD] &= gr[RS]; |
2d514e6f SS |
802 | break; |
803 | ||
804 | case 0x17: /* xor */ | |
7eed1055 | 805 | gr[RD] ^= gr[RS]; |
2d514e6f SS |
806 | break; |
807 | ||
808 | case 0x18: case 0x19: /* mtcr */ | |
809 | { | |
810 | unsigned r; | |
811 | r = IMM5; | |
812 | if (r <= LAST_VALID_CREG) | |
7eed1055 | 813 | cr[r] = gr[RD]; |
2d514e6f | 814 | else |
02962cd9 | 815 | ILLEGAL (); |
ba14f941 | 816 | |
2d514e6f | 817 | /* we might have changed register sets... */ |
7eed1055 | 818 | set_active_regs (cpu); |
2d514e6f SS |
819 | } |
820 | break; | |
821 | ||
822 | case 0x1A: /* asr */ | |
c5394b80 JM |
823 | /* We must not rely solely upon the native shift operations, since they |
824 | may not match the M*Core's behaviour on boundary conditions. */ | |
7eed1055 MF |
825 | if (gr[RS] > 30) |
826 | gr[RD] = ((long) gr[RD]) < 0 ? -1 : 0; | |
c5394b80 | 827 | else |
7eed1055 | 828 | gr[RD] = (long) gr[RD] >> gr[RS]; |
2d514e6f SS |
829 | break; |
830 | ||
831 | case 0x1B: /* lsl */ | |
c5394b80 JM |
832 | /* We must not rely solely upon the native shift operations, since they |
833 | may not match the M*Core's behaviour on boundary conditions. */ | |
7eed1055 | 834 | gr[RD] = gr[RS] > 31 ? 0 : gr[RD] << gr[RS]; |
2d514e6f SS |
835 | break; |
836 | ||
837 | case 0x1C: /* addu */ | |
7eed1055 | 838 | gr[RD] += gr[RS]; |
2d514e6f SS |
839 | break; |
840 | ||
841 | case 0x1D: /* ixh */ | |
7eed1055 | 842 | gr[RD] += gr[RS] << 1; |
2d514e6f SS |
843 | break; |
844 | ||
845 | case 0x1E: /* or */ | |
7eed1055 | 846 | gr[RD] |= gr[RS]; |
2d514e6f SS |
847 | break; |
848 | ||
849 | case 0x1F: /* andn */ | |
7eed1055 | 850 | gr[RD] &= ~gr[RS]; |
2d514e6f SS |
851 | break; |
852 | case 0x20: case 0x21: /* addi */ | |
7eed1055 MF |
853 | gr[RD] = |
854 | gr[RD] + (IMM5 + 1); | |
2d514e6f SS |
855 | break; |
856 | case 0x22: case 0x23: /* cmplti */ | |
857 | { | |
858 | int tmp = (IMM5 + 1); | |
7eed1055 | 859 | if (gr[RD] < tmp) |
2d514e6f SS |
860 | { |
861 | SET_C(); | |
862 | } | |
863 | else | |
864 | { | |
865 | CLR_C(); | |
866 | } | |
867 | } | |
868 | break; | |
869 | case 0x24: case 0x25: /* subi */ | |
7eed1055 MF |
870 | gr[RD] = |
871 | gr[RD] - (IMM5 + 1); | |
2d514e6f SS |
872 | break; |
873 | case 0x26: case 0x27: /* illegal */ | |
02962cd9 | 874 | ILLEGAL (); |
2d514e6f SS |
875 | break; |
876 | case 0x28: case 0x29: /* rsubi */ | |
7eed1055 MF |
877 | gr[RD] = |
878 | IMM5 - gr[RD]; | |
2d514e6f SS |
879 | break; |
880 | case 0x2A: case 0x2B: /* cmpnei */ | |
7eed1055 | 881 | if (gr[RD] != IMM5) |
2d514e6f SS |
882 | { |
883 | SET_C(); | |
884 | } | |
885 | else | |
886 | { | |
887 | CLR_C(); | |
888 | } | |
889 | break; | |
ba14f941 | 890 | |
2d514e6f SS |
891 | case 0x2C: case 0x2D: /* bmaski, divu */ |
892 | { | |
893 | unsigned imm = IMM5; | |
ba14f941 | 894 | |
2d514e6f SS |
895 | if (imm == 1) |
896 | { | |
897 | int exe; | |
898 | int rxnlz, r1nlz; | |
899 | unsigned int rx, r1; | |
900 | ||
7eed1055 MF |
901 | rx = gr[RD]; |
902 | r1 = gr[1]; | |
2d514e6f SS |
903 | exe = 0; |
904 | ||
905 | /* unsigned divide */ | |
7eed1055 | 906 | gr[RD] = (word) ((unsigned int) gr[RD] / (unsigned int)gr[1] ); |
ba14f941 | 907 | |
2d514e6f SS |
908 | /* compute bonus_cycles for divu */ |
909 | for (r1nlz = 0; ((r1 & 0x80000000) == 0) && (r1nlz < 32); r1nlz ++) | |
910 | r1 = r1 << 1; | |
911 | ||
912 | for (rxnlz = 0; ((rx & 0x80000000) == 0) && (rxnlz < 32); rxnlz ++) | |
913 | rx = rx << 1; | |
914 | ||
915 | if (r1nlz < rxnlz) | |
916 | exe += 4; | |
917 | else | |
918 | exe += 5 + r1nlz - rxnlz; | |
919 | ||
920 | if (exe >= (2 * memcycles - 1)) | |
921 | { | |
922 | bonus_cycles += exe - (2 * memcycles) + 1; | |
923 | } | |
924 | } | |
925 | else if (imm == 0 || imm >= 8) | |
926 | { | |
927 | /* bmaski */ | |
928 | if (imm == 0) | |
7eed1055 | 929 | gr[RD] = -1; |
2d514e6f | 930 | else |
7eed1055 | 931 | gr[RD] = (1 << imm) - 1; |
2d514e6f SS |
932 | } |
933 | else | |
934 | { | |
935 | /* illegal */ | |
02962cd9 | 936 | ILLEGAL (); |
2d514e6f SS |
937 | } |
938 | } | |
939 | break; | |
940 | case 0x2E: case 0x2F: /* andi */ | |
7eed1055 | 941 | gr[RD] = gr[RD] & IMM5; |
2d514e6f SS |
942 | break; |
943 | case 0x30: case 0x31: /* bclri */ | |
7eed1055 | 944 | gr[RD] = gr[RD] & ~(1<<IMM5); |
2d514e6f SS |
945 | break; |
946 | case 0x32: case 0x33: /* bgeni, divs */ | |
947 | { | |
948 | unsigned imm = IMM5; | |
949 | if (imm == 1) | |
950 | { | |
951 | int exe,sc; | |
952 | int rxnlz, r1nlz; | |
953 | signed int rx, r1; | |
ba14f941 | 954 | |
2d514e6f | 955 | /* compute bonus_cycles for divu */ |
7eed1055 MF |
956 | rx = gr[RD]; |
957 | r1 = gr[1]; | |
2d514e6f | 958 | exe = 0; |
ba14f941 | 959 | |
2d514e6f SS |
960 | if (((rx < 0) && (r1 > 0)) || ((rx >= 0) && (r1 < 0))) |
961 | sc = 1; | |
962 | else | |
963 | sc = 0; | |
ba14f941 | 964 | |
2d514e6f SS |
965 | rx = abs (rx); |
966 | r1 = abs (r1); | |
ba14f941 | 967 | |
2d514e6f | 968 | /* signed divide, general registers are of type int, so / op is OK */ |
7eed1055 | 969 | gr[RD] = gr[RD] / gr[1]; |
ba14f941 | 970 | |
2d514e6f SS |
971 | for (r1nlz = 0; ((r1 & 0x80000000) == 0) && (r1nlz < 32) ; r1nlz ++ ) |
972 | r1 = r1 << 1; | |
ba14f941 | 973 | |
2d514e6f SS |
974 | for (rxnlz = 0; ((rx & 0x80000000) == 0) && (rxnlz < 32) ; rxnlz ++ ) |
975 | rx = rx << 1; | |
ba14f941 | 976 | |
2d514e6f SS |
977 | if (r1nlz < rxnlz) |
978 | exe += 5; | |
979 | else | |
980 | exe += 6 + r1nlz - rxnlz + sc; | |
ba14f941 | 981 | |
2d514e6f SS |
982 | if (exe >= (2 * memcycles - 1)) |
983 | { | |
984 | bonus_cycles += exe - (2 * memcycles) + 1; | |
985 | } | |
986 | } | |
987 | else if (imm >= 7) | |
988 | { | |
989 | /* bgeni */ | |
7eed1055 | 990 | gr[RD] = (1 << IMM5); |
2d514e6f SS |
991 | } |
992 | else | |
993 | { | |
994 | /* illegal */ | |
02962cd9 | 995 | ILLEGAL (); |
2d514e6f SS |
996 | } |
997 | break; | |
998 | } | |
999 | case 0x34: case 0x35: /* bseti */ | |
7eed1055 | 1000 | gr[RD] = gr[RD] | (1 << IMM5); |
2d514e6f SS |
1001 | break; |
1002 | case 0x36: case 0x37: /* btsti */ | |
7eed1055 | 1003 | NEW_C (gr[RD] >> IMM5); |
2d514e6f SS |
1004 | break; |
1005 | case 0x38: case 0x39: /* xsr, rotli */ | |
1006 | { | |
1007 | unsigned imm = IMM5; | |
7eed1055 | 1008 | unsigned long tmp = gr[RD]; |
2d514e6f SS |
1009 | if (imm == 0) |
1010 | { | |
1011 | word cbit; | |
1012 | cbit = C_VALUE(); | |
1013 | NEW_C (tmp); | |
7eed1055 | 1014 | gr[RD] = (cbit << 31) | (tmp >> 1); |
2d514e6f SS |
1015 | } |
1016 | else | |
7eed1055 | 1017 | gr[RD] = (tmp << imm) | (tmp >> (32 - imm)); |
2d514e6f SS |
1018 | } |
1019 | break; | |
1020 | case 0x3A: case 0x3B: /* asrc, asri */ | |
1021 | { | |
1022 | unsigned imm = IMM5; | |
7eed1055 | 1023 | long tmp = gr[RD]; |
2d514e6f SS |
1024 | if (imm == 0) |
1025 | { | |
1026 | NEW_C (tmp); | |
7eed1055 | 1027 | gr[RD] = tmp >> 1; |
2d514e6f SS |
1028 | } |
1029 | else | |
7eed1055 | 1030 | gr[RD] = tmp >> imm; |
2d514e6f SS |
1031 | } |
1032 | break; | |
1033 | case 0x3C: case 0x3D: /* lslc, lsli */ | |
1034 | { | |
1035 | unsigned imm = IMM5; | |
7eed1055 | 1036 | unsigned long tmp = gr[RD]; |
2d514e6f SS |
1037 | if (imm == 0) |
1038 | { | |
1039 | NEW_C (tmp >> 31); | |
7eed1055 | 1040 | gr[RD] = tmp << 1; |
2d514e6f SS |
1041 | } |
1042 | else | |
7eed1055 | 1043 | gr[RD] = tmp << imm; |
2d514e6f SS |
1044 | } |
1045 | break; | |
1046 | case 0x3E: case 0x3F: /* lsrc, lsri */ | |
1047 | { | |
1048 | unsigned imm = IMM5; | |
7eed1055 | 1049 | unsigned long tmp = gr[RD]; |
2d514e6f SS |
1050 | if (imm == 0) |
1051 | { | |
1052 | NEW_C (tmp); | |
7eed1055 | 1053 | gr[RD] = tmp >> 1; |
2d514e6f SS |
1054 | } |
1055 | else | |
7eed1055 | 1056 | gr[RD] = tmp >> imm; |
2d514e6f SS |
1057 | } |
1058 | break; | |
1059 | case 0x40: case 0x41: case 0x42: case 0x43: | |
1060 | case 0x44: case 0x45: case 0x46: case 0x47: | |
1061 | case 0x48: case 0x49: case 0x4A: case 0x4B: | |
1062 | case 0x4C: case 0x4D: case 0x4E: case 0x4F: | |
02962cd9 | 1063 | ILLEGAL (); |
2d514e6f SS |
1064 | break; |
1065 | case 0x50: | |
7eed1055 | 1066 | util (sd, cpu, inst & 0xFF); |
2d514e6f SS |
1067 | break; |
1068 | case 0x51: case 0x52: case 0x53: | |
1069 | case 0x54: case 0x55: case 0x56: case 0x57: | |
1070 | case 0x58: case 0x59: case 0x5A: case 0x5B: | |
1071 | case 0x5C: case 0x5D: case 0x5E: case 0x5F: | |
02962cd9 | 1072 | ILLEGAL (); |
2d514e6f SS |
1073 | break; |
1074 | case 0x60: case 0x61: case 0x62: case 0x63: /* movi */ | |
1075 | case 0x64: case 0x65: case 0x66: case 0x67: | |
7eed1055 | 1076 | gr[RD] = (inst >> 4) & 0x7F; |
2d514e6f SS |
1077 | break; |
1078 | case 0x68: case 0x69: case 0x6A: case 0x6B: | |
1079 | case 0x6C: case 0x6D: case 0x6E: case 0x6F: /* illegal */ | |
02962cd9 | 1080 | ILLEGAL (); |
2d514e6f SS |
1081 | break; |
1082 | case 0x71: case 0x72: case 0x73: | |
1083 | case 0x74: case 0x75: case 0x76: case 0x77: | |
1084 | case 0x78: case 0x79: case 0x7A: case 0x7B: | |
1085 | case 0x7C: case 0x7D: case 0x7E: /* lrw */ | |
7eed1055 | 1086 | gr[RX] = rlat ((pc + ((inst & 0xFF) << 2)) & 0xFFFFFFFC); |
2d514e6f | 1087 | if (tracing) |
43236bb2 | 1088 | fprintf (stderr, "LRW of 0x%x from 0x%lx to reg %d", |
2d514e6f SS |
1089 | rlat ((pc + ((inst & 0xFF) << 2)) & 0xFFFFFFFC), |
1090 | (pc + ((inst & 0xFF) << 2)) & 0xFFFFFFFC, RX); | |
1091 | memops++; | |
1092 | break; | |
1093 | case 0x7F: /* jsri */ | |
7eed1055 | 1094 | gr[15] = pc; |
392a587b | 1095 | if (tracing) |
43236bb2 MF |
1096 | fprintf (stderr, |
1097 | "func call: r2 = %lx r3 = %lx r4 = %lx r5 = %lx r6 = %lx r7 = %lx\n", | |
7eed1055 | 1098 | gr[2], gr[3], gr[4], gr[5], gr[6], gr[7]); |
2d514e6f SS |
1099 | case 0x70: /* jmpi */ |
1100 | pc = rlat ((pc + ((inst & 0xFF) << 2)) & 0xFFFFFFFC); | |
1101 | memops++; | |
1102 | bonus_cycles++; | |
1103 | needfetch = 1; | |
1104 | break; | |
1105 | ||
1106 | case 0x80: case 0x81: case 0x82: case 0x83: | |
1107 | case 0x84: case 0x85: case 0x86: case 0x87: | |
1108 | case 0x88: case 0x89: case 0x8A: case 0x8B: | |
1109 | case 0x8C: case 0x8D: case 0x8E: case 0x8F: /* ld */ | |
7eed1055 | 1110 | gr[RX] = rlat (gr[RD] + ((inst >> 2) & 0x003C)); |
2d514e6f | 1111 | if (tracing) |
43236bb2 | 1112 | fprintf (stderr, "load reg %d from 0x%lx with 0x%lx", |
2d514e6f | 1113 | RX, |
7eed1055 | 1114 | gr[RD] + ((inst >> 2) & 0x003C), gr[RX]); |
2d514e6f SS |
1115 | memops++; |
1116 | break; | |
1117 | case 0x90: case 0x91: case 0x92: case 0x93: | |
1118 | case 0x94: case 0x95: case 0x96: case 0x97: | |
1119 | case 0x98: case 0x99: case 0x9A: case 0x9B: | |
1120 | case 0x9C: case 0x9D: case 0x9E: case 0x9F: /* st */ | |
7eed1055 | 1121 | wlat (gr[RD] + ((inst >> 2) & 0x003C), gr[RX]); |
2d514e6f | 1122 | if (tracing) |
43236bb2 | 1123 | fprintf (stderr, "store reg %d (containing 0x%lx) to 0x%lx", |
7eed1055 MF |
1124 | RX, gr[RX], |
1125 | gr[RD] + ((inst >> 2) & 0x003C)); | |
2d514e6f SS |
1126 | memops++; |
1127 | break; | |
1128 | case 0xA0: case 0xA1: case 0xA2: case 0xA3: | |
1129 | case 0xA4: case 0xA5: case 0xA6: case 0xA7: | |
1130 | case 0xA8: case 0xA9: case 0xAA: case 0xAB: | |
1131 | case 0xAC: case 0xAD: case 0xAE: case 0xAF: /* ld.b */ | |
7eed1055 | 1132 | gr[RX] = rbat (gr[RD] + RS); |
2d514e6f SS |
1133 | memops++; |
1134 | break; | |
1135 | case 0xB0: case 0xB1: case 0xB2: case 0xB3: | |
1136 | case 0xB4: case 0xB5: case 0xB6: case 0xB7: | |
1137 | case 0xB8: case 0xB9: case 0xBA: case 0xBB: | |
1138 | case 0xBC: case 0xBD: case 0xBE: case 0xBF: /* st.b */ | |
7eed1055 | 1139 | wbat (gr[RD] + RS, gr[RX]); |
2d514e6f SS |
1140 | memops++; |
1141 | break; | |
1142 | case 0xC0: case 0xC1: case 0xC2: case 0xC3: | |
1143 | case 0xC4: case 0xC5: case 0xC6: case 0xC7: | |
1144 | case 0xC8: case 0xC9: case 0xCA: case 0xCB: | |
1145 | case 0xCC: case 0xCD: case 0xCE: case 0xCF: /* ld.h */ | |
7eed1055 | 1146 | gr[RX] = rhat (gr[RD] + ((inst >> 3) & 0x001E)); |
2d514e6f SS |
1147 | memops++; |
1148 | break; | |
1149 | case 0xD0: case 0xD1: case 0xD2: case 0xD3: | |
1150 | case 0xD4: case 0xD5: case 0xD6: case 0xD7: | |
1151 | case 0xD8: case 0xD9: case 0xDA: case 0xDB: | |
1152 | case 0xDC: case 0xDD: case 0xDE: case 0xDF: /* st.h */ | |
7eed1055 | 1153 | what (gr[RD] + ((inst >> 3) & 0x001E), gr[RX]); |
2d514e6f SS |
1154 | memops++; |
1155 | break; | |
1156 | case 0xE8: case 0xE9: case 0xEA: case 0xEB: | |
ba14f941 | 1157 | case 0xEC: case 0xED: case 0xEE: case 0xEF: /* bf */ |
2d514e6f SS |
1158 | if (C_OFF()) |
1159 | { | |
1160 | int disp; | |
1161 | disp = inst & 0x03FF; | |
1162 | if (inst & 0x0400) | |
1163 | disp |= 0xFFFFFC00; | |
1164 | pc += disp<<1; | |
1165 | bonus_cycles++; | |
1166 | needfetch = 1; | |
1167 | } | |
1168 | break; | |
1169 | case 0xE0: case 0xE1: case 0xE2: case 0xE3: | |
1170 | case 0xE4: case 0xE5: case 0xE6: case 0xE7: /* bt */ | |
1171 | if (C_ON()) | |
1172 | { | |
1173 | int disp; | |
1174 | disp = inst & 0x03FF; | |
1175 | if (inst & 0x0400) | |
1176 | disp |= 0xFFFFFC00; | |
1177 | pc += disp<<1; | |
1178 | bonus_cycles++; | |
1179 | needfetch = 1; | |
1180 | } | |
1181 | break; | |
1182 | ||
1183 | case 0xF8: case 0xF9: case 0xFA: case 0xFB: | |
ba14f941 | 1184 | case 0xFC: case 0xFD: case 0xFE: case 0xFF: /* bsr */ |
7eed1055 | 1185 | gr[15] = pc; |
2d514e6f SS |
1186 | case 0xF0: case 0xF1: case 0xF2: case 0xF3: |
1187 | case 0xF4: case 0xF5: case 0xF6: case 0xF7: /* br */ | |
1188 | { | |
1189 | int disp; | |
1190 | disp = inst & 0x03FF; | |
1191 | if (inst & 0x0400) | |
1192 | disp |= 0xFFFFFC00; | |
1193 | pc += disp<<1; | |
1194 | bonus_cycles++; | |
1195 | needfetch = 1; | |
1196 | } | |
1197 | break; | |
1198 | ||
1199 | } | |
1200 | ||
1201 | if (tracing) | |
1202 | fprintf (stderr, "\n"); | |
cd0fc7c3 | 1203 | |
ba14f941 | 1204 | if (needfetch) |
2d514e6f | 1205 | { |
f63036b8 MF |
1206 | ibuf = rlat (pc & 0xFFFFFFFC); |
1207 | needfetch = 0; | |
2d514e6f SS |
1208 | } |
1209 | } | |
2d514e6f SS |
1210 | |
1211 | /* Hide away the things we've cached while executing. */ | |
7eed1055 MF |
1212 | CPU_PC_SET (cpu, pc); |
1213 | cpu->insts += insts; /* instructions done ... */ | |
1214 | cpu->cycles += insts; /* and each takes a cycle */ | |
1215 | cpu->cycles += bonus_cycles; /* and extra cycles for branches */ | |
1216 | cpu->cycles += memops * memcycles; /* and memop cycle delays */ | |
2d514e6f SS |
1217 | } |
1218 | ||
02962cd9 MF |
1219 | void |
1220 | sim_engine_run (SIM_DESC sd, | |
1221 | int next_cpu_nr, /* ignore */ | |
1222 | int nr_cpus, /* ignore */ | |
1223 | int siggnal) /* ignore */ | |
1224 | { | |
7eed1055 | 1225 | sim_cpu *cpu; |
02962cd9 MF |
1226 | |
1227 | SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); | |
1228 | ||
7eed1055 | 1229 | cpu = STATE_CPU (sd, 0); |
02962cd9 MF |
1230 | |
1231 | while (1) | |
1232 | { | |
7eed1055 | 1233 | step_once (sd, cpu); |
02962cd9 MF |
1234 | if (sim_events_tick (sd)) |
1235 | sim_events_process (sd); | |
1236 | } | |
1237 | } | |
1238 | ||
9ef4651c | 1239 | static int |
7eed1055 | 1240 | mcore_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length) |
2d514e6f | 1241 | { |
2d514e6f SS |
1242 | if (rn < NUM_MCORE_REGS && rn >= 0) |
1243 | { | |
1244 | if (length == 4) | |
1245 | { | |
2d514e6f | 1246 | long ival; |
ba14f941 | 1247 | |
cd0fc7c3 SS |
1248 | /* misalignment safe */ |
1249 | ival = mcore_extract_unsigned_integer (memory, 4); | |
7eed1055 | 1250 | cpu->asints[rn] = ival; |
2d514e6f SS |
1251 | } |
1252 | ||
1253 | return 4; | |
1254 | } | |
1255 | else | |
1256 | return 0; | |
1257 | } | |
1258 | ||
9ef4651c | 1259 | static int |
7eed1055 | 1260 | mcore_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length) |
2d514e6f | 1261 | { |
2d514e6f SS |
1262 | if (rn < NUM_MCORE_REGS && rn >= 0) |
1263 | { | |
1264 | if (length == 4) | |
1265 | { | |
7eed1055 | 1266 | long ival = cpu->asints[rn]; |
cd0fc7c3 SS |
1267 | |
1268 | /* misalignment-safe */ | |
1269 | mcore_store_unsigned_integer (memory, 4, ival); | |
2d514e6f | 1270 | } |
ba14f941 | 1271 | |
2d514e6f SS |
1272 | return 4; |
1273 | } | |
1274 | else | |
1275 | return 0; | |
1276 | } | |
1277 | ||
2d514e6f | 1278 | void |
feb703b3 | 1279 | sim_info (SIM_DESC sd, int verbose) |
2d514e6f | 1280 | { |
7eed1055 | 1281 | SIM_CPU *cpu = STATE_CPU (sd, 0); |
2d514e6f SS |
1282 | #ifdef WATCHFUNCTIONS |
1283 | int w, wcyc; | |
1284 | #endif | |
7eed1055 | 1285 | double virttime = cpu->cycles / 36.0e6; |
ea6b7543 | 1286 | host_callback *callback = STATE_CALLBACK (sd); |
2d514e6f | 1287 | |
cd0fc7c3 | 1288 | callback->printf_filtered (callback, "\n\n# instructions executed %10d\n", |
7eed1055 | 1289 | cpu->insts); |
cd0fc7c3 | 1290 | callback->printf_filtered (callback, "# cycles %10d\n", |
7eed1055 | 1291 | cpu->cycles); |
cd0fc7c3 | 1292 | callback->printf_filtered (callback, "# pipeline stalls %10d\n", |
7eed1055 | 1293 | cpu->stalls); |
cd0fc7c3 SS |
1294 | callback->printf_filtered (callback, "# virtual time taken %10.4f\n", |
1295 | virttime); | |
2d514e6f SS |
1296 | |
1297 | #ifdef WATCHFUNCTIONS | |
cd0fc7c3 SS |
1298 | callback->printf_filtered (callback, "\nNumber of watched functions: %d\n", |
1299 | ENDWL); | |
2d514e6f SS |
1300 | |
1301 | wcyc = 0; | |
ba14f941 | 1302 | |
2d514e6f SS |
1303 | for (w = 1; w <= ENDWL; w++) |
1304 | { | |
1305 | callback->printf_filtered (callback, "WL = %s %8x\n",WLstr[w],WL[w]); | |
cd0fc7c3 SS |
1306 | callback->printf_filtered (callback, " calls = %d, cycles = %d\n", |
1307 | WLcnts[w],WLcyc[w]); | |
ba14f941 | 1308 | |
2d514e6f | 1309 | if (WLcnts[w] != 0) |
cd0fc7c3 SS |
1310 | callback->printf_filtered (callback, |
1311 | " maxcpc = %d, mincpc = %d, avecpc = %d\n", | |
1312 | WLmax[w],WLmin[w],WLcyc[w]/WLcnts[w]); | |
2d514e6f SS |
1313 | wcyc += WLcyc[w]; |
1314 | } | |
ba14f941 | 1315 | |
cd0fc7c3 SS |
1316 | callback->printf_filtered (callback, |
1317 | "Total cycles for watched functions: %d\n",wcyc); | |
2d514e6f SS |
1318 | #endif |
1319 | } | |
1320 | ||
4c0cab1e MF |
1321 | static sim_cia |
1322 | mcore_pc_get (sim_cpu *cpu) | |
1323 | { | |
7eed1055 | 1324 | return cpu->regs.pc; |
4c0cab1e MF |
1325 | } |
1326 | ||
1327 | static void | |
1328 | mcore_pc_set (sim_cpu *cpu, sim_cia pc) | |
1329 | { | |
7eed1055 | 1330 | cpu->regs.pc = pc; |
4c0cab1e MF |
1331 | } |
1332 | ||
ea6b7543 MF |
1333 | static void |
1334 | free_state (SIM_DESC sd) | |
1335 | { | |
1336 | if (STATE_MODULES (sd) != NULL) | |
1337 | sim_module_uninstall (sd); | |
1338 | sim_cpu_free_all (sd); | |
1339 | sim_state_free (sd); | |
1340 | } | |
1341 | ||
2d514e6f | 1342 | SIM_DESC |
2e3d4f4d MF |
1343 | sim_open (SIM_OPEN_KIND kind, host_callback *cb, |
1344 | struct bfd *abfd, char * const *argv) | |
2d514e6f | 1345 | { |
f63036b8 | 1346 | int i; |
ea6b7543 | 1347 | SIM_DESC sd = sim_state_alloc (kind, cb); |
ea6b7543 MF |
1348 | SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); |
1349 | ||
1350 | /* The cpu data is kept in a separately allocated chunk of memory. */ | |
d5a71b11 | 1351 | if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) |
ea6b7543 MF |
1352 | { |
1353 | free_state (sd); | |
1354 | return 0; | |
1355 | } | |
1356 | ||
1357 | if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK) | |
1358 | { | |
1359 | free_state (sd); | |
1360 | return 0; | |
1361 | } | |
1362 | ||
77cf2ef5 | 1363 | /* The parser will print an error message for us, so we silently return. */ |
ea6b7543 MF |
1364 | if (sim_parse_args (sd, argv) != SIM_RC_OK) |
1365 | { | |
1366 | free_state (sd); | |
1367 | return 0; | |
1368 | } | |
1369 | ||
1370 | /* Check for/establish the a reference program image. */ | |
1371 | if (sim_analyze_program (sd, | |
1372 | (STATE_PROG_ARGV (sd) != NULL | |
1373 | ? *STATE_PROG_ARGV (sd) | |
1374 | : NULL), abfd) != SIM_RC_OK) | |
1375 | { | |
1376 | free_state (sd); | |
1377 | return 0; | |
1378 | } | |
1379 | ||
1380 | /* Configure/verify the target byte order and other runtime | |
1381 | configuration options. */ | |
1382 | if (sim_config (sd) != SIM_RC_OK) | |
1383 | { | |
1384 | sim_module_uninstall (sd); | |
1385 | return 0; | |
1386 | } | |
1387 | ||
1388 | if (sim_post_argv_init (sd) != SIM_RC_OK) | |
1389 | { | |
1390 | /* Uninstall the modules to avoid memory leaks, | |
1391 | file descriptor leaks, etc. */ | |
1392 | sim_module_uninstall (sd); | |
1393 | return 0; | |
1394 | } | |
1395 | ||
ea6b7543 MF |
1396 | /* CPU specific initialization. */ |
1397 | for (i = 0; i < MAX_NR_PROCESSORS; ++i) | |
1398 | { | |
1399 | SIM_CPU *cpu = STATE_CPU (sd, i); | |
4c0cab1e | 1400 | |
9ef4651c MF |
1401 | CPU_REG_FETCH (cpu) = mcore_reg_fetch; |
1402 | CPU_REG_STORE (cpu) = mcore_reg_store; | |
4c0cab1e MF |
1403 | CPU_PC_FETCH (cpu) = mcore_pc_get; |
1404 | CPU_PC_STORE (cpu) = mcore_pc_set; | |
1405 | ||
ea6b7543 MF |
1406 | set_initial_gprs (cpu); /* Reset the GPR registers. */ |
1407 | } | |
ba14f941 | 1408 | |
f63036b8 MF |
1409 | /* Default to a 8 Mbyte (== 2^23) memory space. */ |
1410 | sim_do_commandf (sd, "memory-size %#x", DEFAULT_MEMORY_SIZE); | |
1411 | ||
ea6b7543 | 1412 | return sd; |
2d514e6f SS |
1413 | } |
1414 | ||
2d514e6f | 1415 | SIM_RC |
2e3d4f4d MF |
1416 | sim_create_inferior (SIM_DESC sd, struct bfd *prog_bfd, |
1417 | char * const *argv, char * const *env) | |
2d514e6f | 1418 | { |
7eed1055 | 1419 | SIM_CPU *cpu = STATE_CPU (sd, 0); |
91eea121 | 1420 | char * const *avp; |
2d514e6f SS |
1421 | int nargs = 0; |
1422 | int nenv = 0; | |
1423 | int s_length; | |
1424 | int l; | |
1425 | unsigned long strings; | |
1426 | unsigned long pointers; | |
1427 | unsigned long hi_stack; | |
1428 | ||
1429 | ||
1430 | /* Set the initial register set. */ | |
7eed1055 | 1431 | set_initial_gprs (cpu); |
ba14f941 | 1432 | |
f63036b8 | 1433 | hi_stack = DEFAULT_MEMORY_SIZE - 4; |
7eed1055 | 1434 | CPU_PC_SET (cpu, bfd_get_start_address (prog_bfd)); |
2d514e6f SS |
1435 | |
1436 | /* Calculate the argument and environment strings. */ | |
1437 | s_length = 0; | |
1438 | nargs = 0; | |
1439 | avp = argv; | |
1440 | while (avp && *avp) | |
1441 | { | |
1442 | l = strlen (*avp) + 1; /* include the null */ | |
1443 | s_length += (l + 3) & ~3; /* make it a 4 byte boundary */ | |
1444 | nargs++; avp++; | |
1445 | } | |
1446 | ||
1447 | nenv = 0; | |
1448 | avp = env; | |
1449 | while (avp && *avp) | |
1450 | { | |
1451 | l = strlen (*avp) + 1; /* include the null */ | |
1452 | s_length += (l + 3) & ~ 3;/* make it a 4 byte boundary */ | |
1453 | nenv++; avp++; | |
1454 | } | |
1455 | ||
1456 | /* Claim some memory for the pointers and strings. */ | |
1457 | pointers = hi_stack - sizeof(word) * (nenv+1+nargs+1); | |
1458 | pointers &= ~3; /* must be 4-byte aligned */ | |
7eed1055 | 1459 | gr[0] = pointers; |
2d514e6f | 1460 | |
7eed1055 | 1461 | strings = gr[0] - s_length; |
2d514e6f | 1462 | strings &= ~3; /* want to make it 4-byte aligned */ |
7eed1055 | 1463 | gr[0] = strings; |
2d514e6f | 1464 | /* dac fix, the stack address must be 8-byte aligned! */ |
7eed1055 | 1465 | gr[0] = gr[0] - gr[0] % 8; |
2d514e6f SS |
1466 | |
1467 | /* Loop through the arguments and fill them in. */ | |
7eed1055 | 1468 | gr[PARM1] = nargs; |
2d514e6f SS |
1469 | if (nargs == 0) |
1470 | { | |
1471 | /* No strings to fill in. */ | |
7eed1055 | 1472 | gr[PARM2] = 0; |
2d514e6f SS |
1473 | } |
1474 | else | |
1475 | { | |
7eed1055 | 1476 | gr[PARM2] = pointers; |
2d514e6f SS |
1477 | avp = argv; |
1478 | while (avp && *avp) | |
1479 | { | |
1480 | /* Save where we're putting it. */ | |
1481 | wlat (pointers, strings); | |
1482 | ||
1483 | /* Copy the string. */ | |
1484 | l = strlen (* avp) + 1; | |
7eed1055 | 1485 | sim_core_write_buffer (sd, cpu, write_map, *avp, strings, l); |
2d514e6f SS |
1486 | |
1487 | /* Bump the pointers. */ | |
1488 | avp++; | |
1489 | pointers += 4; | |
1490 | strings += l+1; | |
1491 | } | |
ba14f941 | 1492 | |
2d514e6f SS |
1493 | /* A null to finish the list. */ |
1494 | wlat (pointers, 0); | |
1495 | pointers += 4; | |
1496 | } | |
1497 | ||
1498 | /* Now do the environment pointers. */ | |
1499 | if (nenv == 0) | |
1500 | { | |
1501 | /* No strings to fill in. */ | |
7eed1055 | 1502 | gr[PARM3] = 0; |
2d514e6f SS |
1503 | } |
1504 | else | |
1505 | { | |
7eed1055 | 1506 | gr[PARM3] = pointers; |
2d514e6f | 1507 | avp = env; |
ba14f941 | 1508 | |
2d514e6f SS |
1509 | while (avp && *avp) |
1510 | { | |
1511 | /* Save where we're putting it. */ | |
1512 | wlat (pointers, strings); | |
1513 | ||
1514 | /* Copy the string. */ | |
1515 | l = strlen (* avp) + 1; | |
7eed1055 | 1516 | sim_core_write_buffer (sd, cpu, write_map, *avp, strings, l); |
2d514e6f SS |
1517 | |
1518 | /* Bump the pointers. */ | |
1519 | avp++; | |
1520 | pointers += 4; | |
1521 | strings += l+1; | |
1522 | } | |
ba14f941 | 1523 | |
2d514e6f SS |
1524 | /* A null to finish the list. */ |
1525 | wlat (pointers, 0); | |
1526 | pointers += 4; | |
1527 | } | |
ba14f941 | 1528 | |
2d514e6f SS |
1529 | return SIM_RC_OK; |
1530 | } |