fix printf is a macro in gcc 3
[fw/sdcc] / sim / ucsim / s51.src / interrupt.cc
1 /*
2  * Simulator of microcontrollers (interrupt.cc)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING.  If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
27
28 // sim
29 #include "itsrccl.h"
30
31 // local
32 #include "interruptcl.h"
33 #include "regs51.h"
34
35
36 cl_interrupt::cl_interrupt(class cl_uc *auc):
37   cl_hw(auc, HW_INTERRUPT, 0, "irq")
38 {}
39
40 /*int
41 cl_interrupt::init(void)
42 {
43   return(0);
44 }*/
45
46 void
47 cl_interrupt::print_info(class cl_console *con)
48 {
49   int ie= uc->get_mem(MEM_SFR, IE);
50   int i;
51
52   con->dd_printf("Interrupts are %s. Interrupt sources:\n",
53                  (ie&bmEA)?"enabled":"disabled");
54   con->dd_printf("  Handler  En  Pr Req Act Name\n");
55   for (i= 0; i < uc->it_sources->count; i++)
56     {
57       class cl_it_src *is= (class cl_it_src *)(uc->it_sources->at(i));
58       con->dd_printf("  0x%06x", is->addr);
59       con->dd_printf(" %-3s", (ie&(is->ie_mask))?"en":"dis");
60       con->dd_printf(" %2d", uc->it_priority(is->ie_mask));
61       con->dd_printf(" %-3s",
62                      (uc->get_mem(MEM_SFR, is->src_reg)&(is->src_mask))?
63                      "YES":"no");
64       con->dd_printf(" %-3s", (is->active)?"act":"no");
65       con->dd_printf(" %s", is->name);
66       con->dd_printf("\n");
67     }
68   con->dd_printf("Active interrupt service(s):\n");
69   con->dd_printf("  Pr Handler  PC       Source\n");
70   for (i= 0; i < uc->it_levels->count; i++)
71     {
72       class it_level *il= (class it_level *)(uc->it_levels->at(i));
73       if (il->level >= 0)
74         {
75           con->dd_printf("  %2d", il->level);
76           con->dd_printf(" 0x%06x", il->addr);
77           con->dd_printf(" 0x%06x", il->PC);
78           con->dd_printf(" %s", (il->source)?(il->source->name):"nothing");
79           con->dd_printf("\n");
80         }
81     }
82 }
83
84
85 /* End of s51.src/interrupt.cc */