Add documentation for the MIPS assembler's -march=from-abi command line option
[binutils-gdb.git] / sim / m32c / int.c
blobabb7578fd188ead4965bd16b32becdcb87848778
1 /* int.c --- M32C interrupt handling.
3 Copyright (C) 2005-2023 Free Software Foundation, Inc.
4 Contributed by Red Hat, Inc.
6 This file is part of the GNU simulators.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* This must come before any other includes. */
22 #include "defs.h"
24 #include "int.h"
25 #include "cpu.h"
26 #include "mem.h"
28 static void
29 trigger_interrupt (int addr, int clear_u)
31 int s = get_reg (sp);
32 int f = get_reg (flags);
33 int p = get_reg (pc);
35 if (clear_u)
36 set_flags (FLAGBIT_U, 0);
37 set_flags (FLAGBIT_I | FLAGBIT_D, 0);
39 if (A16)
41 s -= 4;
42 put_reg (sp, s);
43 mem_put_hi (s, p);
44 mem_put_qi (s + 2, f);
45 mem_put_qi (s + 3, ((f >> 4) & 0x0f) | (p >> 16));
47 else
49 s -= 6;
50 put_reg (sp, s);
51 mem_put_si (s, p);
52 mem_put_hi (s + 4, f);
54 put_reg (pc, mem_get_psi (addr));
57 void
58 trigger_fixed_interrupt (int addr)
60 trigger_interrupt (addr, 1);
63 void
64 trigger_based_interrupt (int vector)
66 int addr = get_reg (intb) + vector * 4;
67 trigger_interrupt (addr, vector <= 31);
70 void
71 trigger_peripheral_interrupt (int vector, int icaddr)
73 unsigned char old_ic = mem_get_qi (icaddr);
74 int addr = get_reg (intb) + vector * 4;
75 trigger_interrupt (addr, 1);
76 put_reg (flags, (get_reg (flags) & 0x8fff) | ((old_ic & 7) << 12));
77 mem_put_qi (icaddr, old_ic & ~ 0x08);