]> git.gag.com Git - fw/sdcc/blobdiff - debugger/mcs51/simi.c
a new function for startup (_main)
[fw/sdcc] / debugger / mcs51 / simi.c
index 61133fa5481f6e136f26034c7376d9efc664784b..6eb859cadf3c1ae26fdaca38edff9eb693118d5c 100644 (file)
@@ -144,7 +144,17 @@ void openSimulator (char **args, int nargs)
     int retry = 0;
     int i ;
     Dprintf(D_simi, ("simi: openSimulator\n"));
-
+#ifdef SDCDB_DEBUG
+    if (D_simi & sdcdbDebug)
+    {
+        printf("simi: openSimulator: ");
+        for (i=0; i < nargs; i++ )
+        {
+            printf("arg%d: %s ",i,args[i]);
+        }
+        printf("\n");
+    }
+#endif
     invalidateCache(XMEM_CACHE);
     invalidateCache(IMEM_CACHE);
     invalidateCache(SREG_CACHE);
@@ -287,6 +297,15 @@ static int getMemString(char *buffer, char wrflag,
     return cachenr;
 }
 
+void simSetPC( unsigned int addr )
+{
+    char buffer[40];
+    sprintf(buffer,"pc %d\n", addr);
+    sendSim(buffer);
+    waitForSim(100,NULL);
+    simResponse();   
+}
+
 int simSetValue (unsigned int addr,char mem, int size, unsigned long val)
 {
     char cachenr, i;
@@ -312,6 +331,7 @@ int simSetValue (unsigned int addr,char mem, int size, unsigned long val)
     sendSim(buffer);
     waitForSim(100,NULL);
     simResponse();   
+    return 0;
 }
 
 
@@ -411,7 +431,7 @@ void simLoadFile (char *s)
 {
     char buff[128];
 
-    sprintf(buff,"l \"%s\"\n",s);
+    sprintf(buff,"file \"%s\"\n",s);
     printf(buff);
     sendSim(buff);
     waitForSim(500,NULL);
@@ -441,6 +461,8 @@ unsigned int simGoTillBp ( unsigned int gaddr)
       //sleep(1);
       //waitForSim();
 
+      sendSim("reset\n");
+      waitForSim(wait_ms, NULL);
       sendSim("run 0x0\n");
     } else     if (gaddr == -1) { /* resume */
       sendSim ("run\n");
@@ -477,10 +499,16 @@ unsigned int simGoTillBp ( unsigned int gaddr)
         sr++ ;
     }
 
+    nointerrupt = 1;
+    /* get answer of stop command */
+    if ( userinterrupt )
+        waitForSim(wait_ms, NULL);
+
     /* better solution: ask pc */
     sendSim ("pc\n");
     waitForSim(100, NULL);
     sr = simResponse();
+    nointerrupt = 0;
 
     gaddr = strtol(sr+3,0,0);
     return gaddr;
@@ -509,6 +537,7 @@ void closeSimulator ()
         simactive = 0;
         return;
     }
+    simactive = 0;
     sendSim("quit\n");
     fclose (simin);
     fclose (simout);