int main(){ int i, j; char *title = malloc(64); WORD r; bool is_x[] = { false, true }; char *str[] = { "", "0", "aaa", "GR", "GR8", "GR20", "GR0", "GR1", "GR2", "GR3", "GR4", "GR5", "GR6", "GR7" }; static CERR cerr_getgr[] = { { 120, "GR0 in operand x" }, }; cerr_init(); /* エラーの初期化 */ addcerrlist(ARRAYSIZE(cerr_getgr), cerr_getgr); for(i = 0; i <= 1; i++) { title = (is_x[i] == false) ? "Generel Register" : "Index Register"; printf("== %s ==\n", title); for(j = 0; j < ARRAYSIZE(str); j++) { cerr->num = 0; r = getgr(str[j], is_x[i]); printf("%s\t#%04X", str[j], r); if(cerr->num > 0) { printf("\tError - %d\t%s", cerr->num, cerr->msg); } printf("\n"); } } freecerr(); return 0; }
/** * @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"; const char *usage = "Usage: %s [-tTdvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n"; cerr_init(); addcerrlist_load(); addcerrlist_exec(); /* オプションの処理 */ while((opt = getopt_long(argc, argv, "tTdM:C:vh", longopts, NULL)) != -1) { switch(opt) { case 't': execmode.trace = true; break; case 'T': execmode.trace = true; execmode.logical = true; break; case 'd': execmode.dump = true; break; case 'M': memsize = atoi(optarg); break; case 'C': clocks = atoi(optarg); break; case 'v': fprintf(stdout, cmdversion, version); return 0; case 'h': fprintf(stdout, usage, argv[0]); return 0; case '?': fprintf(stderr, usage, argv[0]); exit(1); } } if(argv[optind] == NULL) { setcerr(211, ""); /* object file not specified */ fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg); exit(1); } /* COMET II仮想マシンのリセット */ reset(memsize, clocks); execptr->start = 0; if(loadassemble(argv[optind]) == true) { exec(); /* プログラム実行 */ } /* COMET II仮想マシンのシャットダウン */ shutdown(); stat = (cerr->num == 0) ? 0 : 1; /* エラーの解放 */ freecerr(); return stat; }
int main(){ int i, j; int code[] = { 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 201, 202, 203, 204, 205, 206, 207, 999 }; const char *str[] = {NULL, "foobar"}; addcerrlist(ARRAYSIZE(cerr_utest), cerr_utest); /* エラーの初期化 */ cerr = malloc_chk(sizeof(CERR), "cerr"); for(i = 0; i < ARRAYSIZE(str); i++) { for(j = 0; j < ARRAYSIZE(code); j++) { setcerr(code[j], str[i]); printf("%d: %s - %d\t%s\n", code[j], str[i], cerr->num, cerr->msg); } } freecerr(); return 0; }
/** * @brief casl2revコマンドのメイン * * @return 正常終了時は0、異常終了時は1 * * @param argc コマンドライン引数の数 * @param *argv[] コマンドライン引数の配列 */ int main(int argc, char *argv[]) { int opt = 0; int stat = 0; const char *version = PACKAGE_VERSION; const char *cmdversion = "disassemble of YACASL2 version %s\n"; const char *usage = "Usage: %s [-vh] FILE\n"; /* エラーの定義 */ cerr_init(); addcerrlist_load(); /* オプションの処理 */ while((opt = getopt_long(argc, argv, "vh", longopts, NULL)) != -1) { switch(opt) { case 'v': fprintf(stdout, cmdversion, version); goto casl2revfin; case 'h': fprintf(stdout, usage, argv[0]); goto casl2revfin; case '?': fprintf(stderr, usage, argv[0]); setcerr(212, ""); /* invalid option */ goto casl2revfin; } } if(argv[optind] == NULL) { setcerr(211, ""); /* object file not specified */ fprintf(stderr, "disassemble error - %d: %s\n", cerr->num, cerr->msg); goto casl2revfin; } disassemble_file(argv[optind]); /* プログラム実行 */ casl2revfin: if(cerr->num > 0) { stat = 1; } freecerr(); /* エラーの解放 */ return stat; }
int main(){ int i; WORD r; char *str[] = { "#32768", "#-1", "#G", "#FFFF", "#0", "#1", "#ab", "#AB", "#20" "0", "01", "1a", "-5G", "123", "32767", "32768", "32769", "-1", "-2345", "-32768", "-32769", "-32770" }; cerr_init(); /* エラーの初期化 */ addcerrlist_word(); for(i = 0; i < sizeof(str)/sizeof(str[0]); i++) { cerr->num = 0; r = nh2word(str[i]); printf("%s\t#%04X", str[i], r); if(cerr->num > 0) { printf("\tError - %d\t%s", cerr->num, cerr->msg); } printf("\n"); } freecerr(); return 0; }