WORD beginptr[argc];
char *objfile = NULL;
const char *usage =
- "Usage: %s [-slLaAtTdh] [-oO<OUTFILE>] [-M <memorysize>] [-C <clocks>] FILE ...\n";
+ "Usage: %s [-slLaAtTdh] [-oO<OBJECTFILE>] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE ...\n";
while((opt = getopt_long(argc, argv, "tTdslLao::O::AM:C:h", longopts, NULL)) != -1) {
switch(opt) {
/* comet2のエラー定義 */
CERRARRAY cerr_comet2[] = {
{ 201, "Load object file - full of COMET II memory" },
+ { 208, "object file is not specified" },
};
bool addcerrlist_comet2()
{
/* 指定されたファイルからアセンブル結果を読込 */
bool loadassemble(char *file) {
FILE *fp;
+ bool status = true;
if((fp = fopen(file, "r")) == NULL) {
perror(file);
if((endptr = startptr + fread(memory, sizeof(WORD), memsize-startptr, fp)) == memsize) {
setcerr(201, NULL); /* Load object file - full of COMET II memory */
fprintf(stderr, "Execute error - %d: %s\n", cerrno, cerrmsg);
- return false;
+ status = false;
}
fclose(fp);
- return true;
+ return status;
}
/* comet2コマンド */
int main(int argc, char *argv[])
{
int opt;
- const char *usage = "Usage: %s [-tTdh] [-M <memorysize>] [-C <clocks>] FILE\n";
+ const char *usage = "Usage: %s [-tTdh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
addcerrlist_comet2();
while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) {
exit(-1);
}
}
+ if(argv[optind] == NULL) {
+ setcerr(208, NULL); /* object file is not specified */
+ fprintf(stderr, "comet2 error - %d: %s\n", cerrno, cerrmsg);
+ goto comet2err;
+ }
reset();
startptr = 0;
if(loadassemble(argv[optind]) == true) {
exec(); /* プログラム実行 */
}
if(cerrno > 0) {
- freecerr();
- exit(-1);
+ goto comet2err;
}
return 0;
+comet2err:
+ freecerr();
+ exit(-1);
}
--- /dev/null
+include ../CMD.mk # YACASL2DIR, CASL2, COMET2
+ASDIR = $(YACASL2DIR)/as
+CASL2LIBDIR = $(YACASL2DIR)/as/casl2lib
+ASFILE = $(YACASL2DIR)/as/err/err_207.casl
+ASCMD = $(CASL2) -O $(YACASL2DIR)/as/err/err_207.casl
+COMET2FLAG = -M8
+EXECCMD = $(COMET2) $(COMET2FLAG)
+include ../TEST.mk