Commit | Line | Data |
---|---|---|
b8a9943d DE |
1 | # Simulator main loop for m32rx. -*- C -*- |
2 | # Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. | |
3 | # | |
4 | # This file is part of the GNU Simulators. | |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 2, or (at your option) | |
9 | # any later version. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License along | |
17 | # with this program; if not, write to the Free Software Foundation, Inc., | |
18 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
19 | ||
20 | # Syntax: | |
21 | # /bin/sh mainloop.in init|support|{full,fast}-{extract,exec}-{scache,noscache} | |
22 | ||
23 | # ??? After a few more ports are done, revisit. | |
24 | # Will eventually need to machine generate a lot of this. | |
25 | ||
26 | case "x$1" in | |
27 | ||
28 | xsupport) | |
29 | ||
30 | cat <<EOF | |
31 | ||
32 | EOF | |
33 | ||
34 | ;; | |
35 | ||
36 | xinit) | |
37 | ||
38 | cat <<EOF | |
39 | USI insn,insn1,insn2; | |
40 | DECODE *decode,*d1,*d2; | |
41 | int icount,icount2; | |
42 | ARGBUF abufs[MAX_PARALLEL_INSNS]; | |
43 | SEM_ARG sem_arg; | |
44 | ||
45 | EOF | |
46 | ||
47 | ;; | |
48 | ||
49 | xfull-extract-* | xfast-extract-*) | |
50 | ||
51 | cat <<EOF | |
52 | { | |
53 | PCADDR pc = CPU (h_pc); | |
54 | ||
55 | if ((pc & 3) != 0) | |
56 | { | |
57 | insn1 = GETIMEMUHI (current_cpu, pc); | |
58 | insn1 &= 0x7fff; | |
59 | d1 = m32rx_decode (current_cpu, pc, insn1); | |
60 | icount = 1; | |
61 | } | |
62 | else | |
63 | { | |
64 | insn1 = GETIMEMUSI (current_cpu, pc); | |
65 | if ((SI) insn1 < 0) | |
66 | { | |
67 | d1 = m32rx_decode (current_cpu, pc, insn1 >> 16); | |
68 | icount = 1; | |
69 | } | |
70 | else | |
71 | { | |
72 | if (insn & 0x8000) | |
73 | { | |
74 | insn2 = insn1 & 0x7fff; | |
75 | insn1 = insn1 >> 16; | |
76 | d1 = m32rx_decode (current_cpu, pc, insn1); | |
77 | d2 = m32rx_decode (current_cpu, pc, insn2); | |
78 | icount = 2; | |
79 | } | |
80 | else | |
81 | { | |
82 | insn1 = insn1 >> 16; | |
83 | d1 = m32rx_decode (current_cpu, pc, insn1); | |
84 | icount = 1; | |
85 | } | |
86 | } | |
87 | } | |
88 | ||
89 | icount2 = icount; | |
90 | insn = insn1; | |
91 | decode = d1; | |
92 | do | |
93 | { | |
94 | #define DEFINE_SWITCH | |
95 | #include "readx.c" | |
96 | ||
97 | insn = insn2; | |
98 | decode = d2; | |
99 | } | |
100 | while (--icount2 > 0); | |
101 | } | |
102 | EOF | |
103 | ||
104 | ;; | |
105 | ||
106 | xfull-exec-* | xfast-exec-*) | |
107 | ||
108 | cat <<EOF | |
109 | { | |
110 | decode = d1; | |
111 | do | |
112 | { | |
113 | PCADDR new_pc; | |
114 | TRACE_INSN_INIT (current_cpu); | |
115 | TRACE_INSN (current_cpu, sc->argbuf.opcode, (const struct argbuf *) &sc->argbuf, sc->argbuf.addr); | |
116 | new_pc = (*decode->semantic) (current_cpu, &sc->argbuf); | |
117 | TRACE_INSN_FINI (current_cpu); | |
118 | PROFILE_COUNT_INSN (current_cpu, pc, CGEN_INSN_INDEX (sc->argbuf.opcode)); | |
119 | CPU (h_pc) = new_pc; | |
120 | decode = d2; | |
121 | } | |
122 | while (--icount > 0); | |
123 | } | |
124 | EOF | |
125 | ||
126 | ;; | |
127 | ||
128 | *) | |
129 | echo "Invalid argument to mainloop.in: $1" >&2 | |
130 | exit 1 | |
131 | ;; | |
132 | ||
133 | esac |