From 2817542c3072299402d4a58a77541779c1baa1b6 Mon Sep 17 00:00:00 2001 From: kbongers Date: Tue, 28 Aug 2001 04:28:58 +0000 Subject: [PATCH 1/1] allow compile of small large model git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1182 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/ds390/gen.c | 67 +++++++++++++++++++++++++++++++++------------- src/ds390/main.c | 55 +++++++++++++++++++++---------------- src/ds390/ralloc.c | 6 ++++- 3 files changed, 86 insertions(+), 42 deletions(-) diff --git a/src/ds390/gen.c b/src/ds390/gen.c index c47b0302..1984a2e9 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -64,8 +64,11 @@ static char *spname; #define D(x) x unsigned fReturnSizeDS390 = 5; /* shared with ralloc.c */ -static char *fReturn[] = +static char *fReturn24[] = {"dpl", "dph", "dpx", "b", "a"}; +static char *fReturn16[] = +{"dpl", "dph", "b", "a"}; +static char **fReturn = fReturn24; static char *accUse[] = {"a", "b"}; @@ -456,13 +459,15 @@ aopForSym (iCode * ic, symbol * sym, bool result, bool useDP2) if (useDP2) { - emitcode ("mov", "dpx1,#0x40"); + if (options.model == MODEL_FLAT24) + emitcode ("mov", "dpx1,#0x40"); emitcode ("mov", "dph1,#0x00"); emitcode ("mov", "dpl1, a"); } else { - emitcode ("mov", "dpx,#0x40"); + if (options.model == MODEL_FLAT24) + emitcode ("mov", "dpx,#0x40"); emitcode ("mov", "dph,#0x00"); emitcode ("mov", "dpl, a"); } @@ -8258,7 +8263,8 @@ genFarPointerGet (operand * left, { emitcode ("mov", "dpl,%s", aopGet (AOP (left), 0, FALSE, FALSE, TRUE)); emitcode ("mov", "dph,%s", aopGet (AOP (left), 1, FALSE, FALSE, TRUE)); - emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE)); + if (options.model == MODEL_FLAT24) + emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE)); } else { @@ -8267,7 +8273,8 @@ genFarPointerGet (operand * left, ); emitcode ("push", "%s", aopGet (AOP (left), 0, FALSE, TRUE, TRUE)); emitcode ("push", "%s", aopGet (AOP (left), 1, FALSE, TRUE, TRUE)); - emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE)); + if (options.model == MODEL_FLAT24) + emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE)); emitcode ("pop", "dph"); emitcode ("pop", "dpl"); } @@ -8333,7 +8340,8 @@ emitcodePointerGet (operand * left, { emitcode ("mov", "dpl,%s", aopGet (AOP (left), 0, FALSE, FALSE, TRUE)); emitcode ("mov", "dph,%s", aopGet (AOP (left), 1, FALSE, FALSE, TRUE)); - emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE)); + if (options.model == MODEL_FLAT24) + emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE)); } else { @@ -8342,7 +8350,8 @@ emitcodePointerGet (operand * left, ); emitcode ("push", "%s", aopGet (AOP (left), 0, FALSE, TRUE, TRUE)); emitcode ("push", "%s", aopGet (AOP (left), 1, FALSE, TRUE, TRUE)); - emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE)); + if (options.model == MODEL_FLAT24) + emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE)); emitcode ("pop", "dph"); emitcode ("pop", "dpl"); } @@ -8417,16 +8426,24 @@ genGenPointerGet (operand * left, genSetDPTR(0); _flushLazyDPS(); emitcode ("mov", "dph,%s", l); - l=aopGet(AOP(left),2,FALSE,FALSE,TRUE); - genSetDPTR(0); - _flushLazyDPS(); - emitcode ("mov", "dpx,%s", l); - emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,TRUE)); + if (options.model == MODEL_FLAT24) { + l=aopGet(AOP(left),2,FALSE,FALSE,TRUE); + genSetDPTR(0); + _flushLazyDPS(); + emitcode ("mov", "dpx,%s", l); + emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,TRUE)); + } else { + emitcode ("mov", "b,%s", aopGet (AOP(left),2,FALSE,FALSE,TRUE)); + } } else { emitcode ("mov", "dpl,%s", aopGet (AOP(left),0,FALSE,FALSE,TRUE)); emitcode ("mov", "dph,%s", aopGet (AOP(left),1,FALSE,FALSE,TRUE)); - emitcode ("mov", "dpx,%s", aopGet (AOP(left),2,FALSE,FALSE,TRUE)); - emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,TRUE)); + if (options.model == MODEL_FLAT24) { + emitcode ("mov", "dpx,%s", aopGet (AOP(left),2,FALSE,FALSE,TRUE)); + emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,TRUE)); + } else { + emitcode ("mov", "b,%s", aopGet (AOP(left),2,FALSE,FALSE,TRUE)); + } } _endLazyDPSEvaluation (); } @@ -8930,7 +8947,8 @@ genFarPointerSet (operand * right, { emitcode ("mov", "dpl,%s", aopGet (AOP (result), 0, FALSE, FALSE, TRUE)); emitcode ("mov", "dph,%s", aopGet (AOP (result), 1, FALSE, FALSE, TRUE)); - emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE, TRUE)); + if (options.model == MODEL_FLAT24) + emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE, TRUE)); } else { @@ -8939,7 +8957,8 @@ genFarPointerSet (operand * right, ); emitcode ("push", "%s", aopGet (AOP (result), 0, FALSE, TRUE, TRUE)); emitcode ("push", "%s", aopGet (AOP (result), 1, FALSE, TRUE, TRUE)); - emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE, TRUE)); + if (options.model == MODEL_FLAT24) + emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE, TRUE)); emitcode ("pop", "dph"); emitcode ("pop", "dpl"); } @@ -9005,8 +9024,12 @@ genGenPointerSet (operand * right, { /* we need to get it byte by byte */ emitcode ("mov", "dpl,%s", aopGet (AOP (result), 0, FALSE, FALSE, TRUE)); emitcode ("mov", "dph,%s", aopGet (AOP (result), 1, FALSE, FALSE, TRUE)); - emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE, TRUE)); - emitcode ("mov", "b,%s", aopGet (AOP (result), 3, FALSE, FALSE, TRUE)); + if (options.model == MODEL_FLAT24) { + emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE, TRUE)); + emitcode ("mov", "b,%s", aopGet (AOP (result), 3, FALSE, FALSE, TRUE)); + } else { + emitcode ("mov", "b,%s", aopGet (AOP (result), 2, FALSE, FALSE, TRUE)); + } } _endLazyDPSEvaluation (); } @@ -9916,6 +9939,14 @@ gen390Code (iCode * lic) lineHead = lineCurr = NULL; + if (options.model == MODEL_FLAT24) { + fReturnSizeDS390 = 5; + fReturn = fReturn24; + } else { + fReturnSizeDS390 = 4; + fReturn = fReturn16; + options.stack10bit=0; + } #if 0 //REMOVE ME!!! /* print the allocation information */ diff --git a/src/ds390/main.c b/src/ds390/main.c index 1cf35286..b1ff65bc 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -87,37 +87,47 @@ _ds390_finaliseOptions (void) /* Hack-o-matic: if we are using the flat24 model, * adjust pointer sizes. */ - if (options.model != MODEL_FLAT24) - { + if (options.model != MODEL_FLAT24) { fprintf (stderr, - "*** error: ds390 port only supports the flat24 model.\n"); - exit (1); - } - port->s.fptr_size = 3; - port->s.gptr_size = 4; - port->stack.isr_overhead++; /* Will save dpx on ISR entry. */ -#if 1 - port->stack.call_overhead++; /* This acounts for the extra byte + "*** warning: ds390 port small and large model experimental.\n"); + if (options.model == MODEL_LARGE) + { + port->mem.default_local_map = xdata; + port->mem.default_globl_map = xdata; + } + else + { + port->mem.default_local_map = data; + port->mem.default_globl_map = data; + } + } + else { + port->s.fptr_size = 3; + port->s.gptr_size = 4; + + port->stack.isr_overhead++; /* Will save dpx on ISR entry. */ + + port->stack.call_overhead++; /* This acounts for the extra byte * of return addres on the stack. * but is ugly. There must be a * better way. */ -#endif - port->mem.default_local_map = xdata; - port->mem.default_globl_map = xdata; + port->mem.default_local_map = xdata; + port->mem.default_globl_map = xdata; - if (!options.stack10bit) + if (!options.stack10bit) { fprintf (stderr, "*** error: ds390 port only supports the 10 bit stack mode.\n"); } - /* Fixup the memory map for the stack; it is now in - * far space and requires a FPOINTER to access it. - */ - istack->fmap = 1; - istack->ptrType = FPOINTER; + /* Fixup the memory map for the stack; it is now in + * far space and requires a FPOINTER to access it. + */ + istack->fmap = 1; + istack->ptrType = FPOINTER; + } /* MODEL_FLAT24 */ } static void @@ -138,16 +148,15 @@ _ds390_getRegName (struct regs *reg) static void _ds390_genAssemblerPreamble (FILE * of) { - if (options.model == MODEL_FLAT24) - { - fputs (".flat24 on\t\t; 24 bit flat addressing\n", of); + if (options.model == MODEL_FLAT24) + fputs (".flat24 on\t\t; 24 bit flat addressing\n", of); + fputs ("dpx = 0x93\t\t; dpx register unknown to assembler\n", of); fputs ("dps = 0x86\t\t; dps register unknown to assembler\n", of); fputs ("dpl1 = 0x84\t\t; dpl1 register unknown to assembler\n", of); fputs ("dph1 = 0x85\t\t; dph1 register unknown to assembler\n", of); fputs ("dpx1 = 0x95\t\t; dpx1 register unknown to assembler\n", of); fputs ("ap = 0x9C\t\t; ap register unknown to assembler\n", of); - } } /* Generate interrupt vector table. */ diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 567b13ef..6eef25f4 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -508,7 +508,11 @@ createStackSpil (symbol * sym) /* set the type to the spilling symbol */ sloc->type = copyLinkChain (sym->type); sloc->etype = getSpec (sloc->type); - SPEC_SCLS (sloc->etype) = options.model ? S_XDATA : S_DATA; + if (options.model == MODEL_SMALL) { + SPEC_SCLS (sloc->etype) = S_DATA; + } else { + SPEC_SCLS (sloc->etype) = S_XDATA; + } SPEC_EXTR (sloc->etype) = 0; /* we don't allow it to be allocated` -- 2.30.2