X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fassemble.c;h=9227114d01165cfab05d5d6d2560f8853d65e93a;hb=30921b571a523338d8b5290d874ec7920ff0b21f;hp=c53ad5baad5c28ed46d5fcc6e57e66e92560411b;hpb=176a22fd90e39acf9b4bdae260d71b8d31be6db0;p=YACASL2.git diff --git a/src/assemble.c b/src/assemble.c index c53ad5b..9227114 100644 --- a/src/assemble.c +++ b/src/assemble.c @@ -82,7 +82,7 @@ static CMD ascmd[] = { { "END", assemble_end }, { "DS", assemble_ds }, { "DC", assemble_dc }, - { NULL, NULL } + { "", NULL } }; /** @@ -93,7 +93,7 @@ static CMD macrocmd[] = { { "IN", assemble_in }, { "RPUSH", assemble_rpush }, { "RPOP", assemble_rpop }, - { NULL, NULL } + { "", NULL } }; /** @@ -144,7 +144,6 @@ WORD getadr(const char *prog, const char *str, PASS pass) */ WORD getgr(const char *str, bool is_x) { - assert(str != NULL); WORD r; /* "GR[0-7]" 以外の文字列では、0xFFFFを返して終了 */ @@ -156,7 +155,7 @@ WORD getgr(const char *str, bool is_x) r = (WORD)(*(str+2) - '0'); /* GR0は指標レジスタとして用いることができない */ if(is_x == true && r == 0x0) { - setcerr(120, NULL); /* GR0 in operand x */ + setcerr(120, ""); /* GR0 in operand x */ return 0x0; } return r; @@ -255,11 +254,11 @@ void writedc(const char *str, PASS pass) void assemble_start(const CMDLINE *cmdl, PASS pass) { if(cmdl->opd->opdc > 1) { - setcerr(106, NULL); /* operand count mismatch */ + setcerr(106, ""); /* operand count mismatch */ return; } - if(cmdl->label == NULL) { - setcerr(107, NULL); /* no label in START */ + if(*(cmdl->label) == '\0') { + setcerr(107, ""); /* no label in START */ return; } /* プログラム名の設定 */ @@ -279,7 +278,7 @@ void assemble_start(const CMDLINE *cmdl, PASS pass) void assemble_end(const CMDLINE *cmdl, PASS pass) { if(cmdl->opd->opdc > 0) { - setcerr(106, NULL); /* operand count mismatch */ + setcerr(106, ""); /* operand count mismatch */ return; } /* 1回目のアセンブルの場合は、リテラル領域開始アドレスを設定 */ @@ -301,7 +300,7 @@ void assemble_ds(const CMDLINE *cmdl, PASS pass) { int i; if(cmdl->opd->opdc != 1) { - setcerr(106, NULL); /* operand count mismatch */ + setcerr(106, ""); /* operand count mismatch */ return; } for(i = 0; i < atoi(cmdl->opd->opdv[0]); i++) { @@ -320,7 +319,7 @@ void assemble_dc(const CMDLINE *cmdl, PASS pass) { int i; if(cmdl->opd->opdc == 0 || cmdl->opd->opdc >= OPDSIZE) { - setcerr(106, NULL); /* operand count mismatch */ + setcerr(106, ""); /* operand count mismatch */ return; } for(i = 0; i < cmdl->opd->opdc; i++) { @@ -348,7 +347,7 @@ void assemble_in(const CMDLINE *cmdl, PASS pass) { char *line = malloc_chk(LINESIZE + 1, "assemble_in.line"); if(cmdl->opd->opdc == 0 || cmdl->opd->opdc > 2) { - setcerr(106, NULL); /* operand count mismatch */ + setcerr(106, ""); /* operand count mismatch */ return; } assembleline(" PUSH 0,GR1", pass); @@ -383,7 +382,7 @@ void assemble_out(const CMDLINE *cmdl, PASS pass) { char *line = malloc_chk(LINESIZE + 1, "assemble_out.line"); if(cmdl->opd->opdc == 0 || cmdl->opd->opdc > 2) { - setcerr(106, NULL); /* operand count mismatch */ + setcerr(106, ""); /* operand count mismatch */ return; } assembleline(" PUSH 0,GR1", pass); @@ -419,7 +418,7 @@ void assemble_rpush(const CMDLINE *cmdl, PASS pass) int i; char *line = malloc_chk(LINESIZE + 1, "assemble_rpush.line"); if(cmdl->opd->opdc > 0) { - setcerr(106, NULL); /* operand count mismatch */ + setcerr(106, ""); /* operand count mismatch */ return; } for(i = 1; i <= GRSIZE-1; i++) { @@ -448,7 +447,7 @@ void assemble_rpop(const CMDLINE *cmdl, PASS pass) int i; char *line = malloc_chk(LINESIZE + 1, "assemble_rpop.line"); if(cmdl->opd->opdc > 0) { - setcerr(106, NULL); /* operand count mismatch */ + setcerr(106, ""); /* operand count mismatch */ return; } for(i = GRSIZE-1; i >= 1; i--) { @@ -469,7 +468,7 @@ bool casl2cmd(CMD *cmdtbl, const CMDLINE *cmdl, PASS pass) { int i; void (*cmdptr)(); - for(i = 0; cmdtbl[i].name != NULL; i++) { + for(i = 0; *(cmdtbl[i].name) != '\0'; i++) { if(strcmp(cmdl->cmd, cmdtbl[i].name) == 0) { cmdptr = cmdtbl[i].ptr; (*cmdptr)(cmdl, pass); @@ -576,7 +575,7 @@ bool assemble_comet2cmd(const CMDLINE *cmdl, PASS pass) bool assembletok(const CMDLINE *cmdl, PASS pass) { /* 命令がない場合 */ - if(cmdl->cmd == NULL) { + if(*(cmdl->cmd) == '\0') { return true; } /* アセンブラ命令またはマクロ命令の書込 */ @@ -605,14 +604,14 @@ bool assembleline(const char *line, PASS pass) stat = (cerr->num == 0) ? true : false; if(cmdl != NULL) { if(stat == true) { - if(pass == FIRST && cmdl->label != NULL) { + if(pass == FIRST && *(cmdl->label) != '\0') { stat = addlabel(asptr->prog, cmdl->label, asptr->ptr); } - if(stat == true) { - stat = assembletok(cmdl, pass); - } - FREE(cmdl->label); } + if(stat == true) { + stat = assembletok(cmdl, pass); + } + FREE(cmdl->label); if(cmdl->opd != NULL) { for(i = 0; i < cmdl->opd->opdc; i++) { FREE(cmdl->opd->opdv[i]);