-/*-----------------------------------------------------------------*/
-/* simRegs - returns value of registers */
-/*-----------------------------------------------------------------*/
-char *simRegs()
-{
- char *resp ;
- unsigned int rv;
- char *rb = regBuff;
- int i;
-
- sendSim("info registers\n");
- //kpb(8-5-01) sendSim("dr\n");
-
- waitForSim();
- /* make it some more readable */
- resp = simResponse();
-
- return resp;
-
-#if 0
- Take this out(2-09-02) cant see as its that useful to reformat, karl.
-
- /* the response is of the form
- XXXXXX R0 R1 R2 R3 R4 R5 R6 R7 ........
- XXXXXX XX . ACC=0xxx dd cc B=0xxx dd cc DPTR= 0xxxxx @DPTR= 0xxx dd cc
- XXXXXX XX . PSW= 0xxx CY=[1|0] AC=[0|1] OV=[0|1] P=[1|0]
-
-Format as of 8-4-01:
- 0x00 00 00 00 00 00 00 00 00 ........
- 000000 00 . ACC= 0x00 0 . B= 0x00 DPTR= 0x0000 @DPTR= 0x00 0 .
- 000000 00 . PSW= 0x00 CY=0 AC=0 OV=0 P=0
-F 0x006d 75 87 80 MOV PCON,#80
-*/
-
- memset(regBuff,0,sizeof(regBuff));
- /* skip the first numerics */
- while (*resp && !isxdigit(*resp)) resp++;
-
- if (strncmp(resp, "0x", 2)) {
- fprintf(stderr, "Error: Format1A\n");
- return regBuff;
- }
- resp += 2;
- while (*resp && isxdigit(*resp)) resp++;
-
- /* now get the eight registers */
- for (i = 0 ; i < 7 ; i++) {
- while (*resp && isspace(*resp)) resp++;
- if (!*resp)
- break;
- rv = strtol(resp,&resp,16);
- sprintf(rb,"R%d : 0x%02X %d %c\n",i,rv,rv,(isprint(rv) ? rv : '.'));
- rb += strlen(rb);
- }
-
- if (!*resp) return regBuff;
-
- /* skip till end of line */
- while (*resp && *resp != '\n') resp++;
- while (*resp && !isxdigit(*resp)) resp++;
- while (*resp && isxdigit(*resp)) resp++;
-
- /* accumulator value */
- rv = getValueStr(resp,"ACC");
- sprintf(rb,"ACC : 0x%02X %d %c\n",rv,rv,(isprint(rv) ? rv : '.'));
- rb += strlen(rb);
-
- /* value of B */
- rv = getValueStr(resp,"B=");
- sprintf(rb,"B : 0x%02X %d %c\n",rv,rv,(isprint(rv) ? rv : '.'));
- rb += strlen(rb);
-
- rv = getValueStr(resp,"DPTR=");
- sprintf(rb,"DPTR: 0x%04X %d\n",rv,rv);
- rb += strlen(rb);
-
- rv = getValueStr(resp,"@DPTR=");
- sprintf(rb,"@DPTR: 0x%02X %d %c\n", rv,rv,(isprint(rv) ? rv : '.'));
- rb += strlen(rb);
-
- sprintf(rb,"PSW : 0x%02X | CY : %d | AC : %d | OV : %d | P : %d\n",
- getValueStr(resp,"PSW="),
- getValueStr(resp,"CY="),
- getValueStr(resp,"AC="),
- getValueStr(resp,"OV="),
- getValueStr(resp,"P="));
-
- return regBuff;
-#endif
-
-}