modelDS390:
test -d ds390 || mkdir ds390
rm -f ds390/*.lib
- $(MAKE) CFLAGS="$(CFLAGS) -mds390 --model-flat24 \
- --stack-10bit" objects
+ $(MAKE) CFLAGS="$(CFLAGS) -mds390" objects
cd ds390; $(MAKE)
cp *.lib ds390
mv *.rel *.asm *.cdb ds390
SOURCES = $(patsubst %.rel,%.c,$(OBJECTS))
CPPFLAGS = -I../../include
-CFLAGS = -mds390 \
- --model-flat24 \
- --stack-10bit \
- $(CPPFLAGS) $(VERBOSE)
+CFLAGS = -mds390 $(CPPFLAGS) $(VERBOSE)
all: $(OBJECTS) libds390.lib
USE_ALT_LEX = 0
-PORTS = mcs51 z80 avr ds390 pic izt
+PORTS = $(shell cat ../ports.build)
+ALLPORTS = $(shell cat ../ports.all)
PORT_LIBS = $(PORTS:%=%/port.a)
LIBS = -lm @LIBS@
void replaceLabel (eBBlock *, symbol *, symbol *);
void dumpEbbsToFileExt (char *, eBBlock **, int);
-#if defined(_MSC_VER)
+//#if defined(_MSC_VER)
/*-----------------------------------------------------------------*/
/* dumpLiveRanges - dump liverange information into a file */
void dumpLiveRanges (char *ext, hTab * liveRanges);
-#endif // _MSC_VER
+//#endif // _MSC_VER
#endif
{
sym_link *t1 = operandType (IC_LEFT (ic)), *t2;
- if (IS_DS390_PORT)
+ if (TARGET_IS_DS390)
{
/* hack-o-matic! */
return;
void
_printPointerType (FILE * oFile, const char *name)
{
- if (IS_DS390_PORT)
+ if (TARGET_IS_DS390)
{
fprintf (oFile, "\t.byte %s,(%s >> 8),(%s >> 16)", name, name, name);
}
operand *geniCodeDerefPtr (operand *);
#define PRINTFUNC(x) void x (FILE *of, iCode *ic, char *s)
-/* forward definition of print functions */
+/* forward definition of ic print functions */
PRINTFUNC (picGetValueAtAddr);
PRINTFUNC (picSetValueAtAddr);
PRINTFUNC (picAddrOf);
/* under the following conditions create a
register equivalent for a local symbol */
if (sym->level && sym->etype && SPEC_OCLS (sym->etype) &&
- (IN_FARSPACE (SPEC_OCLS (sym->etype)) && (!IS_DS390_PORT)) &&
+ (IN_FARSPACE (SPEC_OCLS (sym->etype)) && (!TARGET_IS_DS390)) &&
options.stackAuto == 0)
ok = 0;
if (IS_SPEC (type) &&
IS_TRUE_SYMOP (op) &&
- (!IN_FARSPACE (SPEC_OCLS (etype)) || IS_DS390_PORT))
+ (!IN_FARSPACE (SPEC_OCLS (etype)) || TARGET_IS_DS390))
{
op = operandFromOperand (op);
op->isaddr = 0;
}
else {
resType = usualBinaryConversions (&left, &right);
- /* if (IS_DS390_PORT) { */
- /* jwk char*char=int
- Now be can use the 16bit result of "mul a,b" instead of explicit
- casts and support function calls as with --ansiint
- */
- /* if ((IS_CHAR(letype) || IS_SHORT(letype)) && */
- /* (IS_CHAR(retype) || IS_SHORT(retype))) { */
if (resultIsInt) {
SPEC_NOUN(getSpec(resType))=V_INT;
SPEC_SHORT(getSpec(resType))=0;
}
}
-/* } */
/* if the right is a literal & power of 2 */
/* then make it a left shift */
if (IN_FARSPACE (SPEC_OCLS (sym->etype)) &&
options.stackAuto == 0 &&
- !IS_DS390_PORT)
+ !TARGET_IS_DS390)
{
}
else
&ds390_port,
#endif
#if !OPT_DISABLE_PIC
- &pic14_port,
+ &pic_port,
#endif
#if !OPT_DISABLE_I186
&i186_port,
/**
remove me - TSD a hack to force sdcc to generate gpasm format .asm files.
*/
-extern void pic14glue ();
+extern void picglue ();
/** Sets the port to the one given by the command line option.
@param The name minus the option (eg 'mcs51')
@return 0 on success.
*/
-static int
+static void
_setPort (const char *name)
{
int i;
if (!strcmp (_ports[i]->target, name))
{
port = _ports[i];
- return 0;
+ return;
}
}
/* Error - didnt find */
"SDCC : ");
for (i = 0; i < NUM_PORTS; i++)
fprintf (stderr, "%s%s", i == 0 ? "" : "/", _ports[i]->target);
+
fprintf (stderr, " %s"
#ifdef SDCC_SUB_VERSION_STR
"/" SDCC_SUB_VERSION_STR
#endif
- " ` "
#ifdef __CYGWIN32__
" (CYGWIN32)\n"
#else
case 'm':
/* Used to select the port */
- if (_setPort (argv[i] + 2))
- {
- werror (W_UNSUPP_OPTION, "-m", "Unrecognised processor");
- }
+ _setPort (argv[i] + 2);
break;
case 'a':
/* standard library path */
if (!options.nostdlib)
{
- if (IS_DS390_PORT)
+ if (TARGET_IS_DS390)
{
c = "ds390";
}
/*printVersionInfo (); */
+ if (NUM_PORTS==0) {
+ fprintf (stderr, "Build error: no ports are enabled.\n");
+ exit (1);
+ }
+
_findPort (argc, argv);
/* Initalise the port. */
if (port->init)
if (!fatalError)
{
- if (IS_PIC14_PORT)
+ if (!TARGET_IS_PIC) {
/* TSD PIC port hack - if the PIC port option is enabled
and SDCC is used to generate PIC code, then we will
generate .asm files in gpasm's format instead of SDCC's
assembler's format
*/
- pic14glue ();
+ picglue ();
+ }
else
glue ();
if (fatalError)
-------------------------------------------------------------------------*/
#include <stdio.h>
+#include <malloc.h>
#include "newalloc.h"
#include <assert.h>
#include "SDCCset.h"
* control this allcoation, but the code was originally that way, and
* changing it for non-390 ports breaks the compiler badly.
*/
- bool useXdata = IS_DS390_PORT ? options.model : options.useXstack;
+ bool useXdata = TARGET_IS_DS390 ? 1 : options.useXstack;
SPEC_SCLS (sym->etype) = (useXdata ?
S_XDATA : S_FIXED);
}
DCL_TYPE (val->type) = PPOINTER;
break;
case S_FIXED:
- if (IS_DS390_PORT)
+ if (TARGET_IS_DS390)
{
/* The AUTO and REGISTER classes should probably
* also become generic pointers, but I haven't yet
/* Globals */
PORT avr_port = {
+ TARGET_ID_AVR,
"avr",
"ATMEL AVR", /* Target name */
{
rm -f *core *[%~] *.[oa] *.output
rm -f .[a-z]*~ \#*
rm -f $(PRJDIR)/bin/sdcc sdcc
- for port in $(PORTS) ; do\
+ for port in $(ALLPORTS) ; do\
$(MAKE) -C $$port -f clean.mk clean ;\
done
#define D(x) x
-unsigned fReturnSize_390 = 5; /* shared with ralloc.c */
+unsigned fReturnSizeDS390 = 5; /* shared with ralloc.c */
static char *fReturn[] =
{"dpl", "dph", "dpx", "b", "a"};
static char *accUse[] =
aop = op->aop = sym->aop = newAsmop (AOP_STR);
aop->size = getSize (sym->type);
- for (i = 0; i < (int) fReturnSize_390; i++)
+ for (i = 0; i < (int) fReturnSizeDS390; i++)
aop->aopu.aop_str[i] = fReturn[i];
return;
}
IS_TRUE_SYMOP (IC_RESULT (ic))))
{
int size = getSize (operandType (IC_RESULT (ic)));
- int offset = fReturnSize_390 - size;
+ int offset = fReturnSizeDS390 - size;
while (size--)
{
- emitcode ("push", "%s", (strcmp (fReturn[fReturnSize_390 - offset - 1], "a") ?
- fReturn[fReturnSize_390 - offset - 1] : "acc"));
+ emitcode ("push", "%s", (strcmp (fReturn[fReturnSizeDS390 - offset - 1], "a") ?
+ fReturn[fReturnSizeDS390 - offset - 1] : "acc"));
offset++;
}
aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
void gen390Code (iCode *);
-extern unsigned fReturnSize_390;
+extern unsigned fReturnSizeDS390;
#endif
/* Globals */
PORT ds390_port =
{
+ TARGET_ID_DS390,
"ds390",
"DS80C390", /* Target name */
{
/* only upto 2 bytes since we cannot predict
the usage of b, & acc */
- if (getSize (operandType (op)) > (fReturnSize_390 - 2) &&
+ if (getSize (operandType (op)) > (fReturnSizeDS390 - 2) &&
ic->op != RETURN &&
ic->op != SEND &&
!POINTER_SET (ic) &&
/* Globals */
PORT i186_port =
{
+ TARGET_ID_I186,
"i186",
"Intel 8086/80186", /* Target name */
{
/* Globals */
PORT tlcs900h_port =
{
+ TARGET_ID_TLCS900H,
"tlcs900h",
"Toshiba TLCS-900H", /* Target name */
{
char *fReturn8051[] =
{"dpl", "dph", "b", "a"};
-char *fReturn390[] =
-{"dpl", "dph", "dpx", "b", "a"};
-unsigned fReturnSize = 4; /* shared with ralloc.c */
+unsigned fReturnSizeMCS51 = 4; /* shared with ralloc.c */
char **fReturn = fReturn8051;
static char *accUse[] =
{"a", "b"};
/* assign depending on the storage class */
/* if it is on the stack or indirectly addressable */
/* space we need to assign either r0 or r1 to it */
- if ((sym->onStack && !options.stack10bit) || sym->iaccess)
+ if (sym->onStack || sym->iaccess)
{
sym->aop = aop = newAsmop (0);
aop->aopu.aop_ptr = getFreePtr (ic, &aop, result);
return aop;
}
- if (sym->onStack && options.stack10bit)
- {
- /* It's on the 10 bit stack, which is located in
- * far data space.
- */
-
- if (_G.accInUse)
- emitcode ("push", "acc");
-
- emitcode ("mov", "a,_bp");
- emitcode ("add", "a,#0x%02x",
- ((sym->stack < 0) ?
- ((char) (sym->stack - _G.nRegsSaved)) :
- ((char) sym->stack)) & 0xff);
-
- genSetDPTR (1);
- emitcode ("mov", "dpx1,#0x40");
- emitcode ("mov", "dph1,#0x00");
- emitcode ("mov", "dpl1, a");
- genSetDPTR (0);
-
- if (_G.accInUse)
- emitcode ("pop", "acc");
-
- sym->aop = aop = newAsmop (AOP_DPTR2);
- aop->size = getSize (sym->type);
- return aop;
- }
-
/* if in bit space */
if (IN_BITSPACE (space))
{
int i;
aop = op->aop = sym->aop = newAsmop (AOP_STR);
aop->size = getSize (sym->type);
- for (i = 0; i < fReturnSize; i++)
+ for (i = 0; i < fReturnSizeMCS51; i++)
aop->aopu.aop_str[i] = fReturn[i];
return;
}
getFreePtr (ic, &aop, FALSE);
- if (options.stack10bit)
- {
- /* I'm not sure what to do here yet... */
- /* #STUB */
- fprintf (stderr,
- "*** Warning: probably generating bad code for "
- "10 bit stack mode.\n");
- }
-
if (stk)
{
emitcode ("mov", "a,_bp");
emitcode ("mov", "a,#(%05d$ >> 8)", (rlbl->key + 100));
emitcode ("push", "acc");
- if (options.model == MODEL_FLAT24)
- {
- emitcode ("mov", "a,#(%05d$ >> 16)", (rlbl->key + 100));
- emitcode ("push", "acc");
- }
-
/* now push the calling address */
aopOp (IC_LEFT (ic), ic, FALSE);
emitcode ("push", "dpl");
if (!inExcludeList ("dph"))
emitcode ("push", "dph");
- if (options.model == MODEL_FLAT24 && !inExcludeList ("dpx"))
- {
- emitcode ("push", "dpx");
- /* Make sure we're using standard DPTR */
- emitcode ("push", "dps");
- emitcode ("mov", "dps, #0x00");
- if (options.stack10bit)
- {
- /* This ISR could conceivably use DPTR2. Better save it. */
- emitcode ("push", "dpl1");
- emitcode ("push", "dph1");
- emitcode ("push", "dpx1");
- }
- }
/* if this isr has no bank i.e. is going to
run with bank 0 , then we need to save more
registers :-) */
}
}
- if (options.model == MODEL_FLAT24 && !inExcludeList ("dpx"))
- {
- if (options.stack10bit)
- {
- emitcode ("pop", "dpx1");
- emitcode ("pop", "dph1");
- emitcode ("pop", "dpl1");
- }
- emitcode ("pop", "dps");
- emitcode ("pop", "dpx");
- }
if (!inExcludeList ("dph"))
emitcode ("pop", "dph");
if (!inExcludeList ("dpl"))
{ /* we need to get it byte by byte */
emitcode ("mov", "dpl,%s", aopGet (AOP (left), 0, FALSE, FALSE));
emitcode ("mov", "dph,%s", aopGet (AOP (left), 1, FALSE, FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE));
- }
}
}
/* so dptr know contains the address */
{ /* we need to get it byte by byte */
emitcode ("mov", "dpl,%s", aopGet (AOP (left), 0, FALSE, FALSE));
emitcode ("mov", "dph,%s", aopGet (AOP (left), 1, FALSE, FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE));
- }
}
}
/* so dptr know contains the address */
{ /* we need to get it byte by byte */
emitcode ("mov", "dpl,%s", aopGet (AOP (left), 0, FALSE, FALSE));
emitcode ("mov", "dph,%s", aopGet (AOP (left), 1, FALSE, FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE));
- emitcode ("mov", "b,%s", aopGet (AOP (left), 3, FALSE, FALSE));
- }
- else
- {
- emitcode ("mov", "b,%s", aopGet (AOP (left), 2, FALSE, FALSE));
- }
+ emitcode ("mov", "b,%s", aopGet (AOP (left), 2, FALSE, FALSE));
}
}
/* so dptr know contains the address */
{ /* we need to get it byte by byte */
emitcode ("mov", "dpl,%s", aopGet (AOP (result), 0, FALSE, FALSE));
emitcode ("mov", "dph,%s", aopGet (AOP (result), 1, FALSE, FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE));
- }
}
}
/* so dptr know contains the address */
{ /* we need to get it byte by byte */
emitcode ("mov", "dpl,%s", aopGet (AOP (result), 0, FALSE, FALSE));
emitcode ("mov", "dph,%s", aopGet (AOP (result), 1, FALSE, FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE));
- emitcode ("mov", "b,%s", aopGet (AOP (result), 3, FALSE, FALSE));
- }
- else
- {
- emitcode ("mov", "b,%s", aopGet (AOP (result), 2, FALSE, FALSE));
- }
+ emitcode ("mov", "b,%s", aopGet (AOP (result), 2, FALSE, FALSE));
}
}
/* so dptr know contains the address */
/* fill the result with zero */
size = AOP_SIZE (IC_RESULT (ic)) - 1;
-
- if (options.stack10bit && size < (FPTRSIZE - 1))
- {
- fprintf (stderr,
- "*** warning: pointer to stack var truncated.\n");
- }
-
offset = 1;
while (size--)
{
- /* Yuck! */
- if (options.stack10bit && offset == 2)
- {
- aopPut (AOP (IC_RESULT (ic)), "#0x40", offset++);
- }
- else
- {
- aopPut (AOP (IC_RESULT (ic)), zero, offset++);
- }
+ aopPut (AOP (IC_RESULT (ic)), zero, offset++);
}
goto release;
{
int size = getSize (operandType (IC_RESULT (ic)));
- int offset = fReturnSize - size;
+ int offset = fReturnSizeMCS51 - size;
while (size--)
{
- emitcode ("push", "%s", (strcmp (fReturn[fReturnSize - offset - 1], "a") ?
- fReturn[fReturnSize - offset - 1] : "acc"));
+ emitcode ("push", "%s", (strcmp (fReturn[fReturnSizeMCS51 - offset - 1], "a") ?
+ fReturn[fReturnSizeMCS51 - offset - 1] : "acc"));
offset++;
}
aopOp (IC_RESULT (ic), ic, FALSE);
typedef struct asmop
{
- short type; /* can have values
- AOP_LIT - operand is a literal value
- AOP_REG - is in registers
- AOP_DIR - direct just a name
- AOP_DPTR - dptr contains address of operand
- AOP_DPTR2 - dptr2 contains address of operand (DS80C390 only).
- AOP_R0/R1 - r0/r1 contains address of operand
- AOP_STK - should be pushed on stack this
- can happen only for the result
- AOP_IMMD - immediate value for eg. remateriazable
- AOP_CRY - carry contains the value of this
- AOP_STR - array of strings
- AOP_ACC - result is in the acc:b pair
- */
+ short type;
+ /* can have values
+ AOP_LIT - operand is a literal value
+ AOP_REG - is in registers
+ AOP_DIR - direct just a name
+ AOP_DPTR - dptr contains address of operand
+ AOP_R0/R1 - r0/r1 contains address of operand
+ AOP_STK - should be pushed on stack this
+ can happen only for the result
+ AOP_IMMD - immediate value for eg. remateriazable
+ AOP_CRY - carry contains the value of this
+ AOP_STR - array of strings
+ AOP_ACC - result is in the acc:b pair
+ */
short coff; /* current offset */
short size; /* total size */
unsigned code:1; /* is in Code space */
void gen51Code (iCode *);
-extern char *fReturn8051[];
-extern char *fReturn390[];
-extern unsigned fReturnSize;
-extern char **fReturn;
+//extern char *fReturn8051[];
+extern unsigned fReturnSizeMCS51;
+//extern char **fReturn;
#endif
static void
_mcs51_finaliseOptions (void)
{
- /* Hack-o-matic: if we are using the flat24 model,
- * adjust pointer sizes.
- */
- 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. */
-#if 1
- 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
- fReturn = fReturn390;
- fReturnSize = 5;
- }
-
if (options.model == MODEL_LARGE)
{
port->mem.default_local_map = xdata;
port->mem.default_local_map = data;
port->mem.default_globl_map = data;
}
-
- if (options.stack10bit)
- {
- if (options.model != MODEL_FLAT24)
- {
- fprintf (stderr,
- "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
- fprintf (stderr, "\t10 bit stack mode disabled.\n");
- options.stack10bit = 0;
- }
- else
- {
- /* 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;
- }
- }
}
static void
static void
_mcs51_genAssemblerPreamble (FILE * 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);
- }
}
/* Generate interrupt vector table. */
static int
_mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
{
- int i;
-
- if (options.model != MODEL_FLAT24)
- {
- /* Let the default code handle it. */
- return FALSE;
- }
-
- fprintf (of, "\tajmp\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);
- }
- else
- {
- fprintf (of, "\treti\n\t.ds\t7\n");
- }
- }
-
- return TRUE;
+ return FALSE;
}
/** $1 is always the basename.
/* Globals */
PORT mcs51_port =
{
+ TARGET_ID_MCS51,
"mcs51",
"MCU 8051", /* Target name */
{
TRUE, /* Emit glue around main */
- MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
+ MODEL_SMALL | MODEL_LARGE,
MODEL_SMALL
},
{
orl a,r%2
}
-replace {
- mov %1,a
- mov dpl,%2
- mov dph,%3
- mov dpx,%4
- mov a,%1
-} by {
- ; Peephole 136a removed redundant moves
- mov %1,a
- mov dpl,%2
- mov dph,%3
- mov dpx,%4
-} if 24bitMode
-
replace {
mov %1,a
mov dpl,%2
clr a
}
-replace {
- mov dpl,#0x00
- mov dph,#0x00
- mov dpx,#0x00
-} by {
- ; Peephole 181a used 24 bit load of dptr
- mov dptr,#0x0000
-} if 24bitMode
-
// saving 3 byte, 2 cycles, return(NULL) profits here
replace {
mov dpl,#0x00
mov dptr,#0x0000
}
-// saves 2 bytes, ?? cycles.
-replace {
- mov dpl,#%1
- mov dph,#(%1 >> 8)
- mov dpx,#(%1 >> 16)
-} by {
- ; Peephole 182a used 24 bit load of dptr
- mov dptr,#%1
-} if 24bitMode
-
// saving 3 byte, 2 cycles, return(float_constant) profits here
replace {
mov dpl,#%1
inc %1
}
-replace {
- mov dptr,#((((%1 >> 16)) <<16) + (((%1 >> 8)) <<8) + %1)
-} by {
- ; Peephole 210a simplified expression
- mov dptr,#%1
-} if 24bitMode
-
replace {
mov dptr,#((((%1 >> 8)) <<8) + %1)
} by {
/* only upto 2 bytes since we cannot predict
the usage of b, & acc */
- if (getSize (operandType (op)) > (fReturnSize - 2) &&
+ if (getSize (operandType (op)) > (fReturnSizeMCS51 - 2) &&
ic->op != RETURN &&
ic->op != SEND &&
!POINTER_SET (ic) &&
char *fReturnpic14[] = {"FSR","dph","b","a" };
//char *fReturn390[] = {"dpl","dph","dpx", "b","a" };
-static unsigned fReturnSize = 4; /* shared with ralloc.c */
+unsigned fReturnSizePic = 4; /* shared with ralloc.c */
static char **fReturn = fReturnpic14;
static char *accUse[] = {"a","b"};
int i;
aop = op->aop = sym->aop = newAsmop(AOP_STR);
aop->size = getSize(sym->type);
- for ( i = 0 ; i < fReturnSize ; i++ )
+ for ( i = 0 ; i < fReturnSizePic ; i++ )
aop->aopu.aop_str[i] = fReturn[i];
DEBUGemitcode(";","%d",__LINE__);
return;
IS_TRUE_SYMOP(IC_RESULT(ic))) ) {
int size = getSize(operandType(IC_RESULT(ic)));
- int offset = fReturnSize - size;
+ int offset = fReturnSizePic - size;
while (size--) {
- emitcode ("push","%s", (strcmp(fReturn[fReturnSize - offset - 1],"a") ?
- fReturn[fReturnSize - offset - 1] : "acc"));
+ emitcode ("push","%s", (strcmp(fReturn[fReturnSizePic - offset - 1],"a") ?
+ fReturn[fReturnSizePic - offset - 1] : "acc"));
offset++;
}
aopOp(IC_RESULT(ic),ic,FALSE);
void genpic14Code (iCode *);
-extern char *fReturnpic14[];
-extern char *fReturn390[];
-extern unsigned fReturnSize;
-extern char **fReturn;
+//extern char *fReturnpic14[];
+//extern char *fReturn390[];
+extern unsigned fReturnSizePic;
+//extern char **fReturn;
#endif
/* glue - the final glue that hold the whole thing together */
/*-----------------------------------------------------------------*/
void
-pic14glue ()
+picglue ()
{
FILE *vFile;
static void
_pic14_finaliseOptions (void)
{
+#if 0
/* Hack-o-matic: if we are using the flat24 model,
* adjust pointer sizes.
*/
istack->ptrType = FPOINTER;
}
}
+#endif
}
static void
};
/* Globals */
-PORT pic14_port =
+PORT pic_port =
{
+ TARGET_ID_PIC,
"pic14",
"MCU pic", /* Target name */
{
/* only upto 2 bytes since we cannot predict
the usage of b, & acc */
- if (getSize (operandType (op)) > (fReturnSize - 2) &&
+ if (getSize (operandType (op)) > (fReturnSizePic - 2) &&
ic->op != RETURN &&
ic->op != SEND)
return NULL;
#ifndef PORT_INCLUDE
#define PORT_INCLUDE
+#define TARGET_ID_MCS51 1
+#define TARGET_ID_GBZ80 2
+#define TARGET_ID_Z80 3
+#define TARGET_ID_AVR 4
+#define TARGET_ID_DS390 5
+#define TARGET_ID_PIC 6
+#define TARGET_ID_I186 7
+#define TARGET_ID_TLCS900H 8
+#define TARGET_ID_XA51 9
+
+/* Macro to test the target we are compiling for.
+ Can only be used after SDCCmain has defined the port
+*/
+#define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
+#define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
+#define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
+#define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
+#define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
+#define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
+#define TARGET_IS_I186 (port->id==TARGET_ID_I186)
+#define TARGET_IS_TCLS900H (port->id==TARGET_ID_TCLS900H)
+
/* Processor specific names */
typedef struct
{
+/** Unique id for this target */
+ const int id;
/** Target name used for -m */
const char *target;
struct
{
- /** TRUE if all types of glue functions should be inseted into
+ /** TRUE if all types of glue functions should be inserted into
the file that also defines main.
We dont want this in cases like the z80 where the startup
code is provided by a seperate module.
const char *fun_prefix;
/** Called once the processor target has been selected.
- First chance to initalise and set any port specific varibles.
+ First chance to initalise and set any port specific variables.
'port' is set before calling this. May be NULL.
*/
void (*init) (void);
extern PORT ds390_port;
#endif
#if !OPT_DISABLE_PIC
-extern PORT pic14_port;
+extern PORT pic_port;
#endif
#if !OPT_DISABLE_I186
extern PORT i186_port;
extern PORT tlcs900h_port;
#endif
-/* Test to see if we are current compiling in what? port. */
-#define IS_MCS51_PORT (port == &mcs51_port)
-#define IS_GBZ80_PORT (port == &gbz80_port)
-#define IS_Z80_PORT (port == &z80_port)
-#define IS_AVR_PORT (port == &avr_port)
-#define IS_DS390_PORT (port == &ds390_port)
-#define IS_PIC14_PORT (port == &pic14_port)
-#define IS_I186_PORT (port == &i186_port)
-#define IS_TCLS900H_PORT (port == &tlcs900h_port)
-
#endif PORT_INCLUDE
# The asm files are generated by sdcc
.c.asm:
- $(CC) -mpic14 -c $*.c
+ $(CC) -mpic -c $*.c
# The .cod files are generated by gpasm
# these get loaded by gpsim.
/* Globals */
PORT z80_port =
{
+ TARGET_ID_Z80,
"z80",
"Zilog Z80", /* Target name */
{
/* Globals */
PORT gbz80_port =
{
+ TARGET_ID_GBZ80,
"gbz80",
"Gameboy Z80-like", /* Target name */
{