projects
/
YACASL2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ソースの推敲
[YACASL2.git]
/
src
/
comet2.c
diff --git
a/src/comet2.c
b/src/comet2.c
index
36060d3
..
55bab75
100644
(file)
--- a/
src/comet2.c
+++ b/
src/comet2.c
@@
-1,12
+1,5
@@
-#include <stdio.h>
-#include <stdlib.h>
-#define _GNU_SOURCE
-#include <getopt.h>
-
-#include "exec.h"
-#include "cmem.h"
-#include "cerr.h"
#include "package.h"
#include "package.h"
+#include "exec.h"
/**
* comet2コマンドのオプション
/**
* comet2コマンドのオプション
@@
-16,29
+9,31
@@
static struct option longopts[] = {
{"tracearithmetic", no_argument, NULL, 't'},
{"tracelogical", no_argument, NULL, 'T'},
{"dump", no_argument, NULL, 'd'},
{"tracearithmetic", no_argument, NULL, 't'},
{"tracelogical", no_argument, NULL, 'T'},
{"dump", no_argument, NULL, 'd'},
+ {"monitor", no_argument, NULL, 'm'},
{"memorysize", required_argument, NULL, 'M'},
{"clocks", required_argument, NULL, 'C'},
{"memorysize", required_argument, NULL, 'M'},
{"clocks", required_argument, NULL, 'C'},
- {
"version", no_argument, NULL, 'v' },
+ {"version", no_argument, NULL, 'v' },
{"help", no_argument, NULL, 'h'},
{0, 0, 0, 0},
};
/**
{"help", no_argument, NULL, 'h'},
{0, 0, 0, 0},
};
/**
- * comet2コマンドのメイン
+ * @brief comet2コマンドのメイン
+ *
+ * @return 正常終了時は0、異常終了時は1
+ *
+ * @param argc コマンドライン引数の数
+ * @param *argv[] コマンドライン引数の配列
*/
int main(int argc, char *argv[])
{
int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS;
int opt, stat = 0;
const char *version = PACKAGE_VERSION, *cmdversion = "comet2 of YACASL2 version %s\n";
*/
int main(int argc, char *argv[])
{
int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS;
int opt, stat = 0;
const char *version = PACKAGE_VERSION, *cmdversion = "comet2 of YACASL2 version %s\n";
- const char *usage = "Usage: %s [-tTdvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
-
- cerr_init();
- addcerrlist_load();
- addcerrlist_exec();
+ const char *usage = "Usage: %s [-tTdmvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
/* オプションの処理 */
/* オプションの処理 */
- while((opt = getopt_long(argc, argv, "tTdM:C:vh", longopts, NULL)) != -1) {
+ while((opt = getopt_long(argc, argv, "tTd
m
M:C:vh", longopts, NULL)) != -1) {
switch(opt) {
case 't':
execmode.trace = true;
switch(opt) {
case 't':
execmode.trace = true;
@@
-50,6
+45,9
@@
int main(int argc, char *argv[])
case 'd':
execmode.dump = true;
break;
case 'd':
execmode.dump = true;
break;
+ case 'm':
+ execmode.monitor = true;
+ break;
case 'M':
memsize = atoi(optarg);
break;
case 'M':
memsize = atoi(optarg);
break;
@@
-67,21
+65,24
@@
int main(int argc, char *argv[])
exit(1);
}
}
exit(1);
}
}
+ /* エラーの定義 */
+ cerr_init();
+ addcerrlist_load();
+ addcerrlist_exec();
+
if(argv[optind] == NULL) {
setcerr(211, ""); /* object file not specified */
fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
if(argv[optind] == NULL) {
setcerr(211, ""); /* object file not specified */
fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
-
exit(1)
;
+
goto fin
;
}
}
- /* COMET II仮想マシンのリセット */
- reset(memsize, clocks);
+ reset(memsize, clocks); /* COMET II仮想マシンのリセット */
execptr->start = 0;
execptr->start = 0;
- if(
loadassemble(argv[optind]) == true
) {
- exec(); /* プログラム実行 */
+ if(
(execptr->end = loadassemble(argv[optind], execptr->start)) > 0 && cerr->num == 0
) {
+ exec();
/* プログラム実行 */
}
}
- /* COMET II仮想マシンのシャットダウン */
- shutdown();
- stat = (cerr->num == 0) ? 0 : -1;
- /* エラーの解放 */
- freecerr();
+ shutdown(); /* COMET II仮想マシンのシャットダウン */
+fin:
+ stat = (cerr->num == 0) ? 0 : 1;
+ freecerr(); /* エラーの解放 */
return stat;
}
return stat;
}