X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=debugger%2Fmcs51%2Fsimi.c;h=4a771a339fcc4782fa304011bb4b6aa4afb2733b;hb=HEAD;hp=3124250535067c0655f985dc4b5d8661c3bc5229;hpb=149f5ee3233356176308957ed2d93a2c093a74f8;p=fw%2Fsdcc diff --git a/debugger/mcs51/simi.c b/debugger/mcs51/simi.c index 31242505..4a771a33 100644 --- a/debugger/mcs51/simi.c +++ b/debugger/mcs51/simi.c @@ -82,7 +82,14 @@ static char *getMemCache(unsigned int addr,int cachenum, int size) { sendSim("ds 0x80 0xff\n"); } - else + else if ( cachenum == CMEM_CACHE ) + { +#define CMEM_CACHE_MASK ((MAX_CACHE_SIZE >> 2) - 1) + laddr = addr & ~CMEM_CACHE_MASK; + sprintf(cache->buffer,"dump rom 0x%x 0x%x\n",laddr,laddr+CMEM_CACHE_MASK ); + sendSim(cache->buffer); + } + else { laddr = addr & 0xffffffc0; sprintf(cache->buffer,"dx 0x%x 0x%x\n",laddr,laddr+0xff ); @@ -283,6 +290,7 @@ void openSimulator (char **args, int nargs) invalidateCache(XMEM_CACHE); invalidateCache(IMEM_CACHE); invalidateCache(SREG_CACHE); + invalidateCache(CMEM_CACHE); if (INVALID_SOCKET == (sock = WSASocket(PF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0))) { fprintf(stderr, "cannot create socket: %d\n", WSAGetLastError()); @@ -363,6 +371,7 @@ static int execSimulator(char **args, int nargs) exit(1); } } + return simPid; } void openSimulator (char **args, int nargs) @@ -385,6 +394,7 @@ void openSimulator (char **args, int nargs) invalidateCache(XMEM_CACHE); invalidateCache(IMEM_CACHE); invalidateCache(SREG_CACHE); + invalidateCache(CMEM_CACHE); if ((sock = socket(AF_INET,SOCK_STREAM,0)) < 0) { @@ -473,12 +483,14 @@ static int getMemString(char *buffer, char wrflag, { case 'A': /* External stack */ case 'F': /* External ram */ + case 'P': /* Pdata space */ prefix = "xram"; cachenr = XMEM_CACHE; break; case 'C': /* Code */ case 'D': /* Code / static segment */ prefix = "rom"; + cachenr = CMEM_CACHE; break; case 'B': /* Internal stack */ case 'E': /* Internal ram (lower 128) bytes */ @@ -527,6 +539,16 @@ void simSetPC( unsigned int addr ) simResponse(); } +unsigned int simGetPC(void) +{ + char *sr; + sendSim("pc\n"); + waitForSim(100,NULL); + simResponse(); + sr = simResponse(); + return strtol(sr+3,0,0); +} + int simSetValue (unsigned int addr,char mem, int size, unsigned long val) { char cachenr, i; @@ -544,7 +566,7 @@ int simSetValue (unsigned int addr,char mem, int size, unsigned long val) s = buffer + strlen(buffer) -1; for ( i = 0 ; i < size ; i++ ) { - sprintf(s," 0x%x", val & 0xff); + sprintf(s," 0x%lx", val & 0xff); s += strlen(s); val >>= 8; } @@ -653,7 +675,7 @@ void simLoadFile (char *s) char buff[128]; sprintf(buff,"file \"%s\"\n",s); - printf(buff); + printf("%s",buff); sendSim(buff); waitForSim(500,NULL); } @@ -743,6 +765,7 @@ void simReset (void) invalidateCache(XMEM_CACHE); invalidateCache(IMEM_CACHE); invalidateCache(SREG_CACHE); + invalidateCache(CMEM_CACHE); sendSim("res\n"); waitForSim(100,NULL); }