From 4aaa5bc19f9fe9f0bb22d2854e91d0b9f78d8708 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Fri, 1 Apr 2011 23:02:32 +0900 Subject: [PATCH] =?utf8?q?exec.c=E3=82=92=E4=B8=80=E9=83=A8=E5=A4=89?= =?utf8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- include/struct.h | 6 +++--- src/cmd.c | 12 ++++++------ src/exec.c | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/struct.h b/include/struct.h index ec4f52b..0825ac1 100644 --- a/include/struct.h +++ b/include/struct.h @@ -151,10 +151,10 @@ void free_cmdtype_code(); bool create_code_type(); /** - * 命令コードから命令タイプを返す - * 無効な場合はNONEを返す + * 命令コードから命令を返す + * 命令コードでない場合はNULLを返す */ -CMDTYPE getcmdtype(WORD code); +CMD *getcmd(WORD code); /** * 命令コードから命令の関数ポインタを返す diff --git a/src/cmd.c b/src/cmd.c index aa435b9..ecd5fdb 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -183,21 +183,21 @@ bool create_code_type() } /** - * 命令コードから命令タイプを返す - * 無効な場合はNOTCMDを返す + * 命令コードから命令を返す + * 命令コードでない場合はNULLを返す */ -CMDTYPE getcmdtype(WORD code) +CMD *getcmd(WORD code) { CMDTAB *p; - CMDTYPE t = NOTCMD; + CMD *c = NULL; for(p = code_type[hash_code(code)]; p != NULL; p = p->next) { if(code == p->cmd->code) { - t = p->cmd->type; + c = p->cmd; break; } } - return t; + return c; } /** diff --git a/src/exec.c b/src/exec.c index ab0a133..5dc4eb1 100644 --- a/src/exec.c +++ b/src/exec.c @@ -529,7 +529,7 @@ void svc(const WORD r, const WORD adr) bool exec() { WORD op, r_r1, x_r2, val; - CMDTYPE cmdtype; + CMD *cmd; void (*cmdptr)(); clock_t clock_begin, clock_end; @@ -574,16 +574,16 @@ bool exec() op = sys->memory[sys->cpu->pr] & 0xFF00; /* 命令の解読 */ /* 命令がCOMET II命令ではない場合はエラー終了 */ - if((cmdtype = getcmdtype(op)) == NOTCMD) { + if((cmd = getcmd(op)) == NULL) { setcerr(210, pr2str(sys->cpu->pr)); /* not command code of COMET II */ goto execerr; } - cmdptr = getcmdptr(op); + cmdptr = cmd->ptr; r_r1 = (sys->memory[sys->cpu->pr] >> 4) & 0xF; x_r2 = sys->memory[sys->cpu->pr] & 0xF; sys->cpu->pr++; /* オペランドの取り出し */ - if(cmdtype == R1_R2) { + if(cmd->type == R1_R2) { /* オペランドの数値が汎用レジスタの範囲外の場合はエラー */ if(x_r2 > GRSIZE - 1) { setcerr(209, pr2str(sys->cpu->pr-1)); /* not GR in operand x */ @@ -591,7 +591,7 @@ bool exec() } val = sys->cpu->gr[x_r2]; } - else if(cmdtype == R_ADR_X || cmdtype == R_ADR_X_ || cmdtype == ADR_X) { + else if(cmd->type == R_ADR_X || cmd->type == R_ADR_X_ || cmd->type == ADR_X) { /* オペランドの数値が汎用レジスタの範囲外の場合はエラー */ if(x_r2 > GRSIZE - 1) { setcerr(209, pr2str(sys->cpu->pr-1)); /* not GR in operand x */ @@ -604,7 +604,7 @@ bool exec() val += sys->cpu->gr[x_r2]; } /* ロード/算術論理演算命令/比較演算命令では、アドレスに格納されている内容を取得 */ - if(cmdtype == R_ADR_X_) { + if(cmd->type == R_ADR_X_) { if(val >= sys->memsize) { setcerr(206, pr2str(sys->cpu->pr-1)); /* Address - out of COMET II memory */ goto execerr; -- 2.18.0