new option -o
[fw/sdcc] / src / ds390 / main.c
index 660a21b404ee70ff1dd4f8a4f2cbf273391b5b3c..a52127d9c71bad1eeb59a2db7663a54686759a20 100644 (file)
@@ -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
@@ -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. */
@@ -288,6 +324,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 +381,7 @@ PORT ds390_port =
   "_",
   _ds390_init,
   _ds390_parseOptions,
+  NULL,
   _ds390_finaliseOptions,
   _ds390_setDefaultOptions,
   ds390_assignRegisters,
@@ -478,11 +516,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);
     }    
@@ -541,7 +579,24 @@ static builtins __tininative_builtins[] = {
     { "MM_Free","i",1,{"i"}},                          /* int  MM_Free  (int)                  */
     { "MM_Deref","cx*",1,{"i"}},                       /* char *MM_Free  (int)                 */
     { "MM_UnrestrictedPersist","c",1,{"i"}},           /* char  MM_UnrestrictedPersist  (int)   */
-    { "MM_AppTag","c",2,{"i","c"}},                    /* char *MM_AppTag  (int,char)          */
+    /* System functions */
+    { "System_ExecJavaProcess","c",2,{"cx*","i"}},     /* char System_ExecJavaProcess (char *,int) */
+    { "System_GetRTCRegisters","v",1,{"cx*"}},        /* void System_GetRTCRegisters (char *) */
+    { "System_SetRTCRegisters","v",1,{"cx*"}},        /* void System_SetRTCRegisters (char *) */
+    { "System_ThreadSleep","v",2,{"l","c"}},           /* void System_ThreadSleep (long,char)  */
+    { "System_ThreadSleep_ExitCriticalSection","v",2,{"l","c"}},/* void System_ThreadSleep_ExitCriticalSection (long,char)  */
+    { "System_ProcessSleep","v",2,{"l","c"}},           /* void System_ProcessSleep (long,char)  */
+    { "System_ProcessSleep_ExitCriticalSection","v",2,{"l","c"}},/* void System_ProcessSleep_ExitCriticalSection (long,char)  */
+    { "System_ThreadResume","c",2,{"c","c"}},          /* char System_ThreadResume(char,char)  */
+    { "System_SaveJavaThreadState","v",0,{NULL}},      /* void System_SaveJavaThreadState()    */
+    { "System_RestoreJavaThreadState","v",0,{NULL}},   /* void System_RestoreJavaThreadState() */
+    { "System_ProcessYield","v",0,{NULL}},             /* void System_ProcessYield() */
+    { "System_ProcessSuspend","v",0,{NULL}},           /* void System_ProcessSuspend() */
+    { "System_ProcessResume","v",1,{"c"}},             /* void System_ProcessResume(char) */
+    { "System_RegisterPoll","c",1,{"vF*"}},            /* char System_RegisterPoll ((void *func pointer)()) */
+    { "System_RemovePoll","c",1,{"vF*"}},              /* char System_RemovePoll ((void *func pointer)()) */
+    { "System_GetCurrentProcessId","c",0,{NULL}},      /* char System_GetCurrentProcessId() */
+    { "System_GetCurrentThreadId","c",0,{NULL}},       /* char System_GetCurrentThreadId() */
     { NULL , NULL,0, {NULL}}                      /* mark end of table */
 };    
 
@@ -554,6 +609,7 @@ PORT tininative_port =
   TARGET_ID_DS390,
   "TININative",
   "DS80C390",                  /* Target name */
+       NULL,                   /* processor */
   {
     FALSE,                     /* Emit glue around main */
     MODEL_FLAT24,
@@ -610,6 +666,7 @@ PORT tininative_port =
   "",
   _tininative_init,
   _ds390_parseOptions,
+  NULL,
   _tininative_finaliseOptions,
   _tininative_setDefaultOptions,
   ds390_assignRegisters,