From: j8takagi Date: Mon, 7 Dec 2009 11:32:21 +0000 (+0900) Subject: クロック周波数の定義を追加 X-Git-Tag: v0.1~88 X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=commitdiff_plain;h=b4e48008c95b35c692827326191698c22b06124f クロック周波数の定義を追加 --- diff --git a/casl2 b/casl2 deleted file mode 100755 index ca2c1f6..0000000 Binary files a/casl2 and /dev/null differ diff --git a/comet2 b/comet2 deleted file mode 100755 index b1d553d..0000000 Binary files a/comet2 and /dev/null differ diff --git a/include/casl2.h b/include/casl2.h index 4f933b4..70e25c5 100644 --- a/include/casl2.h +++ b/include/casl2.h @@ -5,13 +5,16 @@ #include #include #include +#include + #define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0])) /* COMET IIの規格 */ enum { - CMDSIZE = 4, /* 命令の最大文字数 */ - REGSIZE = 8, /* レジスタの数。COMET II規格では、8 */ - MEMSIZE = 512 /* 主記憶の容量。COMET II規格では、65536語 */ + CMDSIZE = 4, /* 命令の最大文字数 */ + REGSIZE = 8, /* 汎用レジスタの数 */ + MEMSIZE = 512, /* メモリ容量。COMET II規格では、65536語 */ + CLOCKS = 5000000 /* クロック周波数。COMET II規格では、未定義 */ }; /* ハッシュ値を取得する */ diff --git a/src/exec.c b/src/exec.c index d811c92..19be801 100644 --- a/src/exec.c +++ b/src/exec.c @@ -266,6 +266,8 @@ void exec() WORD op, r_r1, x_r2, val; CMDTYPE cmdtype; char *errpr = malloc(8); + clock_t clock_begin, clock_end; + if(tracemode) { fprintf(stdout, "\nExecuting machine codes\n"); } @@ -278,6 +280,7 @@ void exec() } /* 機械語の実行 */ for (; ; ) { + clock_begin = clock(); /* プログラムレジスタのアドレスが主記憶の範囲外の場合はエラー */ if(PR >= MEMSIZE) { sprintf(errpr, "PR:#%04X", PR); @@ -448,6 +451,9 @@ void exec() default: break; } + do { + clock_end = clock(); + } while(clock_end - clock_begin < CLOCKS_PER_SEC / CLOCKS); } execerr: fprintf(stderr, "Execute error - %d: %s\n", cerrno, cerrmsg);