From f869af296bc5940bf580932b9f5b1ffd89d5de1f Mon Sep 17 00:00:00 2001 From: sdattalo Date: Mon, 4 Dec 2000 07:31:12 +0000 Subject: [PATCH] TSD PIC port git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@513 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCmain.c | 11 +++++++ src/pic/glue.c | 2 +- src/pic/main.c | 63 +++++++++++++++++++++++++++-------------- src/port.h | 4 +++ src/regression/Makefile | 2 +- 5 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/SDCCmain.c b/src/SDCCmain.c index ffb05361..9ae9871d 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -146,10 +146,18 @@ static PORT *_ports[] = { #if !OPT_DISABLE_DS390 &ds390_port, #endif +#if !OPT_DISABLE_PIC + &pic14_port, +#endif }; #define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0])) +/** + remove me - TSD a hack to force sdcc to generate gpasm format .asm files. + */ +extern void pic14glue(); + /** Sets the port to the one given by the command line option. @param The name minus the option (eg 'mcs51') @return 0 on success. @@ -1391,6 +1399,9 @@ int main ( int argc, char **argv , char **envp) if (!fatalError) { + if(IS_PIC_PORT) + pic14glue(); + else glue(); if (fatalError) { diff --git a/src/pic/glue.c b/src/pic/glue.c index f06e3467..59d53c9e 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -191,7 +191,7 @@ static void pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag) if (IS_AGGREGATE (sym->type)) ival = initAggregates (sym, sym->ival, NULL); else - ival = newNode ('=', newAst (EX_VALUE, symbolVal (sym)), + ival = newNode ('=', newAst_VALUE(symbolVal (sym)), decorateType (resolveSymbols (list2expr (sym->ival)))); codeOutFile = statsg->oFile; eBBlockFromiCode (iCodeFromAst (ival)); diff --git a/src/pic/main.c b/src/pic/main.c index 7d37f321..7fde90c9 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -14,7 +14,7 @@ static char _defaultRules[] = #include "peeph.rul" }; -/* list of key words used by pic14 */ +/* list of key words used by msc51 */ static char *_pic14_keywords[] = { "at", "bit", @@ -46,6 +46,11 @@ void pic14_assignRegisters (eBBlock **ebbs, int count); static int regParmFlg = 0; /* determine if we can register a parameter */ +static void _pic14_init(void) +{ + asm_addTree(&asm_asxxxx_mapping); +} + static void _pic14_reset_regparm() { regParmFlg = 0; @@ -77,6 +82,11 @@ static void _pic14_finaliseOptions(void) */ if (options.model == MODEL_FLAT24) { + + fprintf(stderr, "*** WARNING: you should use the '-mds390' option " + "for DS80C390 support. This code generator is " + "badly out of date and probably broken.\n"); + port->s.fptr_size = 3; port->s.gptr_size = 4; port->stack.isr_overhead++; /* Will save dpx on ISR entry. */ @@ -91,7 +101,7 @@ static void _pic14_finaliseOptions(void) fReturnSize = 5; } - if (options.model) { + if (options.model == MODEL_LARGE) { port->mem.default_local_map = xdata; port->mem.default_globl_map = xdata; } else { @@ -123,11 +133,6 @@ static void _pic14_setDefaultOptions(void) { } -static void _pic14_init(void) -{ - printf("cool init was called for pic14\n"); - -} static const char *_pic14_getRegName(struct regs *reg) { if (reg) @@ -140,7 +145,6 @@ static void _pic14_genAssemblerPreamble(FILE *of) fprintf(of,"\tlist\tp=16c84\n"); fprintf(of,"\t__config _wdt_off\n"); fprintf(of,"\ninclude \"p16c84.inc\"\n"); - } /* Generate interrupt vector table. */ @@ -154,18 +158,18 @@ static int _pic14_genIVT(FILE *of, symbol **interrupts, int maxInterrupts) return FALSE; } - fprintf (of, ";\tajmp\t__sdcc_gsinit_startup\n"); + fprintf (of, "\t;ajmp\t__sdcc_gsinit_startup\n"); /* now for the other interrupts */ for (i = 0; i < maxInterrupts; i++) { if (interrupts[i]) { - fprintf(of, ";\tljmp\t%s\n;\t.ds\t4\n", interrupts[i]->rname); + fprintf(of, "\t;ljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname); } else { - fprintf(of, ";\treti\n;\t.ds\t7\n"); + fprintf(of, "\t;reti\n\t.ds\t7\n"); } } @@ -183,23 +187,31 @@ static const char *_linkCmd[] = { }; static const char *_asmCmd[] = { - "asxpic14", "-plosgffc", "$1.asm", NULL + "gpasm", NULL, NULL, NULL + }; /* Globals */ PORT pic14_port = { "pic14", - "MCU pic14", /* Target name */ + "MCU pic", /* Target name */ { TRUE, /* Emit glue around main */ + MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24, + MODEL_SMALL }, { - _asmCmd, - "-plosgffc", /* Options with debug */ - "-plosgff", /* Options without debug */ + _asmCmd, + NULL, + NULL, + //"-plosgffc", /* Options with debug */ + //"-plosgff", /* Options without debug */ + 0 }, { - _linkCmd + _linkCmd, + NULL, + ".rel" }, { _defaultRules @@ -220,17 +232,19 @@ PORT pic14_port = { "GSINIT (CODE)", "OSEG (OVR,DATA)", "GSFINAL (CODE)", + "HOME (CODE)", NULL, NULL, 1 }, { - +1, 1, 4, 1, 1 + +1, 1, 4, 1, 1, 0 }, - /* pic14 does not have an 8 bit mul */ + /* pic14 has an 8 bit mul */ { - 0 + 1, 0 }, + "_", _pic14_init, _pic14_parseOptions, _pic14_finaliseOptions, @@ -242,6 +256,13 @@ PORT pic14_port = { _pic14_genIVT , _pic14_reset_regparm, _pic14_regparm, - NULL + NULL, + FALSE, + 0, /* leave lt */ + 0, /* leave gt */ + 1, /* transform <= to ! > */ + 1, /* transform >= to ! < */ + 1, /* transform != to !(a == b) */ + 0 /* leave == */ }; diff --git a/src/port.h b/src/port.h index b98eee53..b41e0f82 100644 --- a/src/port.h +++ b/src/port.h @@ -188,6 +188,9 @@ extern PORT avr_port; #if !OPT_DISABLE_DS390 extern PORT ds390_port; #endif +#if !OPT_DISABLE_PIC +extern PORT pic14_port; +#endif /* Test to see if we are current compiling in DS390 mode. */ #define IS_MCS51_PORT (port == &mcs51_port) @@ -195,5 +198,6 @@ extern PORT ds390_port; #define IS_Z80_PORT (port == &z80_port) #define IS_AVR_PORT (port == &avr_port) #define IS_DS390_PORT (port == &ds390_port) +#define IS_PIC_PORT (port == &pic14_port) #endif diff --git a/src/regression/Makefile b/src/regression/Makefile index 834cff10..073129fa 100644 --- a/src/regression/Makefile +++ b/src/regression/Makefile @@ -66,7 +66,7 @@ all: test # The asm files are generated by sdcc .c.asm: - $(CC) -mpic -c $*.c + $(CC) -mpic14 -c $*.c # The .cod files are generated by gpasm # these get loaded by gpsim. -- 2.30.2