Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1998, Andrew Cagney <cagney@highland.com.au> | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
3fd725ef | 7 | the Free Software Foundation; either version 3 of the License, or |
c906108c SS |
8 | (at your option) any later version. |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
51b318de | 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
17 | |
18 | */ | |
19 | ||
6df01ab8 MF |
20 | /* This must come before any other includes. */ |
21 | #include "defs.h" | |
22 | ||
c906108c SS |
23 | #include "sim-main.h" |
24 | #include "m16_idecode.h" | |
25 | #include "m32_idecode.h" | |
26 | #include "bfd.h" | |
27 | ||
28 | ||
29 | #define SD sd | |
30 | #define CPU cpu | |
31 | ||
32 | void | |
33 | sim_engine_run (SIM_DESC sd, | |
34 | int next_cpu_nr, | |
35 | int nr_cpus, /* ignore */ | |
36 | int siggnal) /* ignore */ | |
37 | { | |
38 | sim_cpu *cpu = STATE_CPU (sd, next_cpu_nr); | |
034685f9 | 39 | address_word cia = CPU_PC_GET (cpu); |
c906108c SS |
40 | |
41 | while (1) | |
42 | { | |
43 | address_word nia; | |
44 | ||
45 | #if defined (ENGINE_ISSUE_PREFIX_HOOK) | |
46 | ENGINE_ISSUE_PREFIX_HOOK (); | |
47 | #endif | |
48 | ||
49 | if ((cia & 1)) | |
50 | { | |
51 | m16_instruction_word instruction_0 = IMEM16 (cia); | |
52 | nia = m16_idecode_issue (sd, instruction_0, cia); | |
53 | } | |
54 | else | |
55 | { | |
56 | m32_instruction_word instruction_0 = IMEM32 (cia); | |
57 | nia = m32_idecode_issue (sd, instruction_0, cia); | |
58 | } | |
59 | ||
60 | #if defined (ENGINE_ISSUE_POSTFIX_HOOK) | |
61 | ENGINE_ISSUE_POSTFIX_HOOK (); | |
62 | #endif | |
63 | ||
64 | /* Update the instruction address */ | |
65 | cia = nia; | |
66 | ||
67 | /* process any events */ | |
68 | if (sim_events_tick (sd)) | |
69 | { | |
034685f9 | 70 | CPU_PC_SET (CPU, cia); |
c906108c | 71 | sim_events_process (sd); |
034685f9 | 72 | cia = CPU_PC_GET (CPU); |
c906108c SS |
73 | } |
74 | ||
75 | } | |
76 | } |