X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fpic16%2Fmain.c;h=d41540df164003a7ae6cffa13e7752ad09ce08cf;hb=002b45e47d2e16535faf6ac10a84ebcb0e9091fc;hp=d236fe6df74e292a2d2c8b4ee71e8ed4b3768349;hpb=856b88b89030bb496aaf9e21e39d98e5b48b9869;p=fw%2Fsdcc diff --git a/src/pic16/main.c b/src/pic16/main.c index d236fe6d..d41540df 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -1,14 +1,35 @@ -/** @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" @@ -56,6 +77,7 @@ _pic16_init (void) { asm_addTree (&asm_asxxxx_mapping); pic16_pCodeInitRegisters(); + maxInterrupts = 2; } static void @@ -262,28 +284,55 @@ _pic16_genAssemblerPreamble (FILE * of) 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; } @@ -359,8 +408,9 @@ PORT pic16_port = 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 @@ -394,23 +444,23 @@ PORT pic16_port = */ }, { - "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 }, { @@ -439,6 +489,7 @@ PORT pic16_port = NULL, _hasNativeMulFor, FALSE, + TRUE, /* little endian */ 0, /* leave lt */ 0, /* leave gt */ 1, /* transform <= to ! > */