X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fexec.c;h=3e4b1b9fc7922bc559ece93ad1d12e66aed68258;hp=ad5755127ec994f0d9efce2139d32c41fd4768e3;hb=e24285f0509319319aef28a188b7c01ba7e22bf1;hpb=2ef92a7c1a848fbe897ac6e14f73fd6dbeef8c84 diff --git a/src/exec.c b/src/exec.c index ad57551..3e4b1b9 100644 --- a/src/exec.c +++ b/src/exec.c @@ -1,6 +1,9 @@ #include "casl2.h" #include "exec.h" +/* 実行モード: trace, logical, dump */ +EXECMODE execmode = {false, false, false}; + /* 標準入力から文字データを読込(SVC 1) */ void svcin() { @@ -8,11 +11,10 @@ void svcin() char *buffer = malloc(INSIZE + 1); if(fgets(buffer, INSIZE, stdin) == NULL) { - memory[GR[1]] = 0x0; - memory[GR[2]] = 0x0; + memory[GR[1]] = memory[GR[2]] = 0x0; return; } - for(i = 0; i < GR[1] && i < INSIZE; i++) { + for(i = 0; i < INSIZE; i++) { if(*(buffer + i) == '\0' || *(buffer + i) == '\n') { --i; break; @@ -37,12 +39,9 @@ void svcout() setcerr(203, NULL); /* SVC output - out of Comet II memory */ return; } - if((w = memory[GR[1]+i]) == '\0') { - break; - } /* 「文字の組」の符号表に記載された文字と、改行(CR)/タブを表示 */ /* それ以外の文字は、「.」で表す */ - if((w >= 0x20 && w <= 0x7E) || w == 0xA || w == '\t') { + if(((w = memory[GR[1]+i]) >= 0x20 && w <= 0x7E) || w == 0xA || w == '\t') { putchar((char)w); } else { putchar('.'); @@ -139,7 +138,7 @@ void cpl(WORD val0, WORD val1) /* 算術演算なので、第15ビットは送り出されない */ WORD sla(WORD val0, WORD val1) { - WORD sign, res, last; + WORD sign, res, last = 0x0; int i; FR = 0x0; @@ -170,7 +169,7 @@ WORD sla(WORD val0, WORD val1) /* 空いたビット位置には符号と同じものが入る */ WORD sra(WORD val0, WORD val1) { - WORD sign, res, last; + WORD sign, res, last = 0x0; int i; FR = 0x0; @@ -202,7 +201,7 @@ WORD sra(WORD val0, WORD val1) /* 論理左シフト。フラグを設定して値を返す */ WORD sll(WORD val0, WORD val1) { - WORD res = val0, last; + WORD res = val0, last = 0x0; int i; FR = 0x0; @@ -228,7 +227,7 @@ WORD sll(WORD val0, WORD val1) /* 論理右シフト。フラグを設定して値を返す */ WORD srl(WORD val0, WORD val1) { - WORD res = val0, last; + WORD res = val0, last = 0x0; int i; FR = 0x0; @@ -270,7 +269,7 @@ void exec() { WORD op, r_r1, x_r2, val; CMDTYPE cmdtype; - char *errpr = malloc(8); + char *errpr = malloc(CERRSTRSIZE + 1); clock_t clock_begin, clock_end; if((&execmode)->trace) { @@ -467,7 +466,9 @@ void exec() do { clock_end = clock(); } while(clock_end - clock_begin < CLOCKS_PER_SEC / clocks); -/* printf("PR:%04X; time: %f\n", PR, (double)((clock_end - clock_begin) * CLOCKS_PER_SEC)); */ + #if 0 + printf("PR:%04X; time: %f\n", PR, (double)((clock_end - clock_begin) * CLOCKS_PER_SEC)); + #endif } execerr: fprintf(stderr, "Execute error - %d: %s\n", cerrno, cerrmsg);