X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fds390%2Fmain.c;h=5698771c6981013b25ac533c37f0eaa9d60819aa;hb=b0676377cb1ae0ffef8495682d34f8aa7a0ccf00;hp=4c340750f40d93ee364c7b4f4d63ab7b561c3f86;hpb=940ddadd79bebcdd9ccf131e03d09de45d088e23;p=fw%2Fsdcc diff --git a/src/ds390/main.c b/src/ds390/main.c index 4c340750..5698771c 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -10,7 +10,8 @@ #include "gen.h" #include "BuildCmd.h" #include "MySystem.h" - +#include "../SDCCutil.h" +extern const char *preArgv[128]; /* pre-processor arguments */ static char _defaultRules[] = { #include "peeph.rul" @@ -49,6 +50,13 @@ static builtins __ds390_builtins[] = { { "__builtin_memcpy_x2x","v",3,{"cx*","cx*","i"}}, /* void __builtin_memcpy_x2x (xdata char *,xdata char *,int) */ { "__builtin_memcpy_c2x","v",3,{"cx*","cp*","i"}}, /* void __builtin_memcpy_c2x (xdata char *,code char *,int) */ { "__builtin_memset_x","v",3,{"cx*","c","i"}}, /* void __builtin_memset (xdata char *,char,int) */ + /* __builtin_inp - used to read from a memory mapped port, increment first pointer */ + { "__builtin_inp","v",3,{"cx*","cx*","i"}}, /* void __builtin_inp (xdata char *,xdata char *,int) */ + /* __builtin_inp - used to write to a memory mapped port, increment first pointer */ + { "__builtin_outp","v",3,{"cx*","cx*","i"}}, /* void __builtin_outp (xdata char *,xdata char *,int) */ + { "__builtin_swapw","us",1,{"us"}}, /* unsigned short __builtin_swapw (unsigned short) */ + { "__builtin_memcmp_x2x","c",3,{"cx*","cx*","i"}}, /* void __builtin_memcmp_x2x (xdata char *,xdata char *,int) */ + { "__builtin_memcmp_c2x","c",3,{"cx*","cp*","i"}}, /* void __builtin_memcmp_c2x (xdata char *,code char *,int) */ { NULL , NULL,0, {NULL}} /* mark end of table */ }; void ds390_assignRegisters (eBBlock ** ebbs, int count); @@ -70,13 +78,32 @@ _ds390_reset_regparm () static int _ds390_regparm (sym_link * l) { - /* for this processor it is simple - can pass only the first parameter in a register */ - if (regParmFlg) - return 0; - regParmFlg = 1; - return 1; + if (options.parms_in_bank1 == 0) { + /* simple can pass only the first parameter in a register */ + if (regParmFlg) + return 0; + + regParmFlg = 1; + return 1; + } else { + int size = getSize(l); + int remain ; + + /* first one goes the usual way to DPTR */ + if (regParmFlg == 0) { + regParmFlg += 4 ; + return 1; + } + /* second one onwards goes to RB1_0 thru RB1_7 */ + remain = regParmFlg - 4; + if (size > (8 - remain)) { + regParmFlg = 12 ; + return 0; + } + regParmFlg += size ; + return regParmFlg - size + 1; + } } static bool @@ -128,7 +155,7 @@ _ds390_finaliseOptions (void) fprintf (stderr, "*** error: ds390 port only supports the 10 bit stack mode.\n"); } else { - if (!options.stack_loc) options.stack_loc = 0x400007; + if (!options.stack_loc) options.stack_loc = 0x400008; } /* generate native code 16*16 mul/div */ @@ -142,6 +169,10 @@ _ds390_finaliseOptions (void) */ istack->fmap = 1; istack->ptrType = FPOINTER; + + if (options.parms_in_bank1) { + addToList (preArgv, "-DSDCC_PARMS_IN_BANK1"); + } } /* MODEL_FLAT24 */ } @@ -180,6 +211,11 @@ _ds390_genAssemblerPreamble (FILE * of) fputs ("mc = 0xD5\t\t; mc register unknown to assembler\n", of); fputs ("F1 = 0xD1\t\t; F1 user flag unknown to assembler\n", of); fputs ("esp = 0x9B\t\t; ESP user flag unknown to assembler\n", of); + if (options.parms_in_bank1) { + int i ; + for (i=0; i < 8 ; i++ ) + fprintf (of,"b1_%d = 0x%x \n",i,8+i); + } } /* Generate interrupt vector table. */ @@ -194,7 +230,7 @@ _ds390_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts) return FALSE; } - fprintf (of, "\tajmp\t__sdcc_gsinit_startup\n"); + fprintf (of, "\tajmp\t__reset_vect\n"); /* now for the other interrupts */ for (i = 0; i < maxInterrupts; i++) @@ -209,6 +245,8 @@ _ds390_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts) } } + fprintf (of, "__reset_vect:\n\tljmp\t__sdcc_gsinit_startup\n"); + return TRUE; } @@ -288,6 +326,7 @@ PORT ds390_port = TARGET_ID_DS390, "ds390", "DS80C390", /* Target name */ + NULL, { TRUE, /* Emit glue around main */ MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24, @@ -344,6 +383,7 @@ PORT ds390_port = "_", _ds390_init, _ds390_parseOptions, + NULL, _ds390_finaliseOptions, _ds390_setDefaultOptions, ds390_assignRegisters, @@ -418,7 +458,7 @@ static void _tininative_finaliseOptions (void) fprintf(stderr,"TININative supports only stack10bit \n"); } - if (!options.stack_loc) options.stack_loc = 0x400007; + if (!options.stack_loc) options.stack_loc = 0x400008; /* generate native code 16*16 mul/div */ if (options.useAccelerator) @@ -478,11 +518,11 @@ static void _tininative_do_assemble (const char * const *asmOptions) }; char buffer[100]; - buildCmdLine(buffer,macroCmd,srcFileName,NULL,NULL,NULL); + buildCmdLine(buffer,macroCmd,dstFileName,NULL,NULL,NULL); if (my_system(buffer)) { exit(1); } - buildCmdLine(buffer,a390Cmd,srcFileName,NULL,NULL,asmOptions); + buildCmdLine(buffer,a390Cmd,dstFileName,NULL,NULL,asmOptions); if (my_system(buffer)) { exit(1); } @@ -571,6 +611,7 @@ PORT tininative_port = TARGET_ID_DS390, "TININative", "DS80C390", /* Target name */ + NULL, /* processor */ { FALSE, /* Emit glue around main */ MODEL_FLAT24, @@ -627,6 +668,7 @@ PORT tininative_port = "", _tininative_init, _ds390_parseOptions, + NULL, _tininative_finaliseOptions, _tininative_setDefaultOptions, ds390_assignRegisters,