-/** @file main.c
- pic16 specific general functions.
+/*-------------------------------------------------------------------------
+
+ main.c - pic16 specific general functions.
+
+ Written by - Scott Dattalo scott@dattalo.com
+ Ported to PIC16 by - Martin Dubuc m.debuc@rogers.com
+
+ Note that mlh prepended _pic16_ on the static functions. Makes
+ it easier to set a breakpoint using the debugger.
+
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+-------------------------------------------------------------------------*/
- Note that mlh prepended _pic16_ on the static functions. Makes
- it easier to set a breakpoint using the debugger.
-*/
#include "common.h"
#include "main.h"
#include "ralloc.h"
#include "device.h"
#include "SDCCutil.h"
+#include "glue.h"
//#include "gen.h"
{
asm_addTree (&asm_asxxxx_mapping);
pic16_pCodeInitRegisters();
+ maxInterrupts = 2;
}
static void
static int
_pic16_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
{
+#if 0
int i;
+#endif
- if (options.model != MODEL_FLAT24)
- {
- /* Let the default code handle it. */
- return FALSE;
- }
+#if 0
+ if (options.model != MODEL_FLAT24) {
+ /* Let the default code handle it. */
+ return FALSE;
+ }
+#endif
+
+ /* PIC18F family has only two interrupts, the high and the low
+ * priority interrupts, which reside at 0x0008 and 0x0018 respectively - VR */
- fprintf (of, "\t;ajmp\t__sdcc_gsinit_startup\n");
+ fprintf(of, "; RESET vector\n");
+ fprintf(of, "\tgoto\t__sdcc_gsinit_startup\n");
+ fprintf(of, "\tres 6\n");
+
+ fprintf(of, "; High priority interrupt vector 0x0008\n");
+ if(interrupts[1]) {
+ fprintf(of, "\tgoto\t%s\n", interrupts[1]->rname);
+ fprintf(of, "\tres\t8\n");
+ } else {
+ fprintf(of, "\tretfie\n");
+ fprintf(of, "\tres\t8\n");
+ }
+
+ fprintf(of, "; Low priority interrupt vector 0x0018\n");
+ if(interrupts[2]) {
+ fprintf(of, "\tgoto\t%s\n", interrupts[2]->rname);
+ } else {
+ fprintf(of, "\tretfie\n");
+ }
+#if 0
/* now for the other interrupts */
for (i = 0; i < maxInterrupts; i++)
{
+ fprintf(of, "; %s priority interrupt vector 0x%s\n", (i==0)?"high":"low", (i==0)?"0008":"0018");
if (interrupts[i])
{
- fprintf (of, "\t;ljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
+ fprintf (of, "\tgoto\t%s\n\tres\t4\n", interrupts[i]->rname);
}
else
{
- fprintf (of, "\t;reti\n\t.ds\t7\n");
+ fprintf (of, "\tretfie\n\tres\t7\n");
}
}
+#endif
return TRUE;
}
*/
static const char *_asmCmd[] =
{
- "gpasm", "-c -I /usr/local/share/gputils/header", "\"$1.asm\"", NULL
+ "gpasm", "-c -I/usr/local/share/gputils/header", "\"$1.asm\"", NULL
};
TARGET_ID_PIC16,
"pic16",
"MCU PIC16", /* Target name */
- "p18f452", /* Processor */
+ "p18f442", /* Processor */
{
+ pic16glue,
TRUE, /* Emit glue around main */
MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
MODEL_SMALL
*/
},
{
- "XSEG (XDATA)",
- "STACK (DATA)",
- "CSEG (CODE)",
- "DSEG (DATA)",
- "ISEG (DATA)",
- "XSEG (XDATA)",
- "BSEG (BIT)",
- "RSEG (DATA)",
- "GSINIT (CODE)",
- "OSEG (OVR,DATA)",
- "GSFINAL (CODE)",
- "HOME (CODE)",
- NULL, // xidata
- NULL, // xinit
- NULL,
- NULL,
- 1 // code is read only
+ "XSEG (XDATA)", // xstack
+ "STACK (DATA)", // istack
+ "CSEG (CODE)", // code
+ "DSEG (DATA)", // data
+ "ISEG (DATA)", // idata
+ "XSEG (XDATA)", // xdata
+ "BSEG (BIT)", // bit
+ "RSEG (DATA)", // reg
+ "GSINIT (CODE)", // static
+ "OSEG (OVR,DATA)", // overlay
+ "GSFINAL (CODE)", // post static
+ "HOME (CODE)", // home
+ NULL, // xidata
+ NULL, // xinit
+ NULL, // default location for auto vars
+ NULL, // default location for global vars
+ 1 // code is read only
},
+ { NULL, NULL },
{
+1, 1, 4, 1, 1, 0
},
NULL,
_hasNativeMulFor,
FALSE,
+ TRUE, /* little endian */
0, /* leave lt */
0, /* leave gt */
1, /* transform <= to ! > */