From: j8takagi Date: Sun, 10 Apr 2011 14:54:28 +0000 (+0900) Subject: 変数名を整理 X-Git-Tag: v0.1p37 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c1bb1f12ad0f10aafbdaa59fbc43247784e5096;p=YACASL2.git 変数名を整理 --- diff --git a/src/assemble.c b/src/assemble.c index 1f3da35..8c1c436 100644 --- a/src/assemble.c +++ b/src/assemble.c @@ -346,7 +346,7 @@ void writeRPOP(PASS pass) */ bool cometcmd(const CMDLINE *cmdl, PASS pass) { - WORD cmd, rr1, xr2, adr; + WORD cmd, r_r1, x_r2, adr; /* オペランドなし */ if(cmdl->opd->opdc == 0) { @@ -357,23 +357,23 @@ bool cometcmd(const CMDLINE *cmdl, PASS pass) writememory(cmd, (asptr->ptr)++, pass); } /* 第1オペランドは汎用レジスタ */ - else if((rr1 = getgr(cmdl->opd->opdv[0], false)) != 0xFFFF) { + else if((r_r1 = getgr(cmdl->opd->opdv[0], false)) != 0xFFFF) { /* オペランド数1 */ if(cmdl->opd->opdc == 1) { if((cmd = getcmdcode(cmdl->cmd, R_)) == 0xFFFF) { setcerr(108, cmdl->cmd); /* not command of operand "r" */ return false; } - cmd |= (rr1 << 4); + cmd |= (r_r1 << 4); writememory(cmd, (asptr->ptr)++, pass); } /* オペランド数2。第2オペランドは汎用レジスタ */ - else if(cmdl->opd->opdc == 2 && (xr2 = getgr(cmdl->opd->opdv[1], false)) != 0xFFFF) { + else if(cmdl->opd->opdc == 2 && (x_r2 = getgr(cmdl->opd->opdv[1], false)) != 0xFFFF) { if((cmd = getcmdcode(cmdl->cmd, R1_R2)) == 0xFFFF) { setcerr(109, cmdl->cmd); /* not command of operand "r1,r2" */ return false; } - cmd |= ((rr1 << 4) | xr2); /* 第1オペランド、第2オペランドともに汎用レジスタ */ + cmd |= ((r_r1 << 4) | x_r2); /* 第1オペランド、第2オペランドともに汎用レジスタ */ /* メモリへの書き込み */ writememory(cmd, (asptr->ptr)++, pass); } @@ -383,14 +383,14 @@ bool cometcmd(const CMDLINE *cmdl, PASS pass) setcerr(110, cmdl->cmd); /* not command of operand "r,adr[,x]" */ return false; } - cmd |= (rr1 << 4); /* 第1オペランドは汎用レジスタ */ + cmd |= (r_r1 << 4); /* 第1オペランドは汎用レジスタ */ /* オペランド数3の場合 */ if(cmdl->opd->opdc == 3) { /* 第3オペランドは指標レジスタとして用いる汎用レジスタ */ - if((xr2 = getgr(cmdl->opd->opdv[2], true)) == 0xFFFF) { + if((x_r2 = getgr(cmdl->opd->opdv[2], true)) == 0xFFFF) { setcerr(125, cmdl->cmd); /* not GR in operand x */ return false; } - cmd |= xr2; + cmd |= x_r2; } adr = getadr(asptr->prog, cmdl->opd->opdv[1], pass); /* 第2オペランドはアドレス */ /* メモリへの書き込み */ @@ -409,11 +409,11 @@ bool cometcmd(const CMDLINE *cmdl, PASS pass) } /* オペランド数2の場合 */ if(cmdl->opd->opdc == 2) { /* 第2オペランドは指標レジスタとして用いる汎用レジスタ */ - xr2 = getgr(cmdl->opd->opdv[1], true); + x_r2 = getgr(cmdl->opd->opdv[1], true); if(cerr->num > 0) { return false; } - cmd |= xr2; + cmd |= x_r2; } /* CALLの場合はプログラムの入口名を表すラベルを取得 */ /* CALL以外の命令の場合と、プログラムの入口名を取得できない場合は、 */ diff --git a/src/exec.c b/src/exec.c index 3fb2771..d8df852 100644 --- a/src/exec.c +++ b/src/exec.c @@ -151,7 +151,7 @@ void setfr(WORD adr) /** * WORD値からr/r1を取得 */ -WORD r_r1(WORD oprx) +WORD get_r_r1(WORD oprx) { WORD r; if((r = ((oprx & 0x00F0) >>4)) > GRSIZE - 1) { @@ -164,7 +164,7 @@ WORD r_r1(WORD oprx) /** * WORD値からx/r2を取得 */ -WORD x_r2(WORD oprx) +WORD get_x_r2(WORD oprx) { WORD x; if((x = (oprx & 0x000F)) > GRSIZE - 1) { @@ -177,10 +177,10 @@ WORD x_r2(WORD oprx) /** * 2つのWORD値からadr[,x]を取得 */ -WORD adrx(WORD adr, WORD oprx) +WORD get_adr_x(WORD adr, WORD oprx) { WORD a = adr, x; - if((x = x_r2(oprx)) > 0) { + if((x = get_x_r2(oprx)) > 0) { a += sys->cpu->gr[x]; } return a; @@ -190,10 +190,10 @@ WORD adrx(WORD adr, WORD oprx) /** * 2つのWORD値からadr[,x]のアドレスに格納されている内容を取得 */ -WORD val_adrx(WORD adr, WORD oprx) +WORD get_val_adr_x(WORD adr, WORD oprx) { WORD a; - if((a = adrx(adr, oprx)) >= sys->memsize) { + if((a = get_adr_x(adr, oprx)) >= sys->memsize) { setcerr(207, pr2str(sys->cpu->pr + 1)); /* address in word #2 - out of memory */ return 0x0; } @@ -216,7 +216,7 @@ void ld_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - setfr(sys->cpu->gr[r_r1(w[0])] = val_adrx(w[1], w[0])); + setfr(sys->cpu->gr[get_r_r1(w[0])] = get_val_adr_x(w[1], w[0])); sys->cpu->pr += 2; } @@ -227,7 +227,7 @@ void ld_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - setfr(sys->cpu->gr[r_r1(w[0])] = sys->cpu->gr[x_r2(w[0])]); + setfr(sys->cpu->gr[get_r_r1(w[0])] = sys->cpu->gr[get_x_r2(w[0])]); sys->cpu->pr += 1; } @@ -239,7 +239,7 @@ void st() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - sys->memory[adrx(w[1], w[0])] = sys->cpu->gr[r_r1(w[0])]; + sys->memory[get_adr_x(w[1], w[0])] = sys->cpu->gr[get_r_r1(w[0])]; sys->cpu->pr += 2; } @@ -251,7 +251,7 @@ void lad() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - sys->cpu->gr[r_r1(w[0])] = adrx(w[1], w[0]); + sys->cpu->gr[get_r_r1(w[0])] = get_adr_x(w[1], w[0]); sys->cpu->pr += 2; } @@ -286,7 +286,7 @@ void adda_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - adda(r_r1(w[0]), val_adrx(w[1], w[0])); + adda(get_r_r1(w[0]), get_val_adr_x(w[1], w[0])); sys->cpu->pr += 2; } @@ -297,7 +297,7 @@ void adda_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - adda(r_r1(w[0]), sys->cpu->gr[x_r2(w[0])]); + adda(get_r_r1(w[0]), sys->cpu->gr[get_x_r2(w[0])]); sys->cpu->pr += 1; } @@ -309,7 +309,7 @@ void suba_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - adda(r_r1(w[0]), ~(val_adrx(w[1], w[0])) + 1); + adda(get_r_r1(w[0]), ~(get_val_adr_x(w[1], w[0])) + 1); sys->cpu->pr += 2; } @@ -320,7 +320,7 @@ void suba_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - adda(r_r1(w[0]), ~(sys->cpu->gr[x_r2(w[0])]) + 1); + adda(get_r_r1(w[0]), ~(sys->cpu->gr[get_x_r2(w[0])]) + 1); sys->cpu->pr += 1; } @@ -351,7 +351,7 @@ void addl_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - addl(r_r1(w[0]), val_adrx(w[1], w[0])); + addl(get_r_r1(w[0]), get_val_adr_x(w[1], w[0])); sys->cpu->pr += 2; } @@ -362,7 +362,7 @@ void addl_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - addl(r_r1(w[0]), sys->cpu->gr[x_r2(w[0])]); + addl(get_r_r1(w[0]), sys->cpu->gr[get_x_r2(w[0])]); sys->cpu->pr += 1; } @@ -374,7 +374,7 @@ void subl_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - addl(r_r1(w[0]), ~(val_adrx(w[1], w[0])) + 1); + addl(get_r_r1(w[0]), ~(get_val_adr_x(w[1], w[0])) + 1); sys->cpu->pr += 2; } @@ -385,7 +385,7 @@ void subl_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - addl(r_r1(w[0]), ~(sys->cpu->gr[x_r2(w[0])]) + 1); + addl(get_r_r1(w[0]), ~(sys->cpu->gr[get_x_r2(w[0])]) + 1); sys->cpu->pr += 1; } @@ -397,7 +397,7 @@ void and_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - setfr(sys->cpu->gr[r_r1(w[0])] &= val_adrx(w[1], w[0])); + setfr(sys->cpu->gr[get_r_r1(w[0])] &= get_val_adr_x(w[1], w[0])); sys->cpu->pr += 2; } @@ -408,7 +408,7 @@ void and_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - setfr(sys->cpu->gr[r_r1(w[0])] &= sys->cpu->gr[x_r2(w[0])]); + setfr(sys->cpu->gr[get_r_r1(w[0])] &= sys->cpu->gr[get_x_r2(w[0])]); sys->cpu->pr += 1; } @@ -420,7 +420,7 @@ void or_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - setfr(sys->cpu->gr[r_r1(w[0])] |= val_adrx(w[1], w[0])); + setfr(sys->cpu->gr[get_r_r1(w[0])] |= get_val_adr_x(w[1], w[0])); sys->cpu->pr += 2; } @@ -431,7 +431,7 @@ void or_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - setfr(sys->cpu->gr[r_r1(w[0])] |= sys->cpu->gr[x_r2(w[0])]); + setfr(sys->cpu->gr[get_r_r1(w[0])] |= sys->cpu->gr[get_x_r2(w[0])]); sys->cpu->pr += 1; } @@ -443,7 +443,7 @@ void xor_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - setfr(sys->cpu->gr[r_r1(w[0])] ^= val_adrx(w[1], w[0])); + setfr(sys->cpu->gr[get_r_r1(w[0])] ^= get_val_adr_x(w[1], w[0])); sys->cpu->pr += 2; } @@ -454,7 +454,7 @@ void xor_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - setfr(sys->cpu->gr[r_r1(w[0])] ^= sys->cpu->gr[x_r2(w[0])]); + setfr(sys->cpu->gr[get_r_r1(w[0])] ^= sys->cpu->gr[get_x_r2(w[0])]); sys->cpu->pr += 1; } @@ -480,7 +480,7 @@ void cpa_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - cpa(r_r1(w[0]), val_adrx(w[1], w[0])); + cpa(get_r_r1(w[0]), get_val_adr_x(w[1], w[0])); sys->cpu->pr += 2; } @@ -491,7 +491,7 @@ void cpa_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - cpa(r_r1(w[0]), sys->cpu->gr[x_r2(w[0])]); + cpa(get_r_r1(w[0]), sys->cpu->gr[get_x_r2(w[0])]); sys->cpu->pr += 1; } @@ -520,7 +520,7 @@ void cpl_r_adr_x() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - cpl(r_r1(w[0]), val_adrx(w[1], w[0])); + cpl(get_r_r1(w[0]), get_val_adr_x(w[1], w[0])); sys->cpu->pr += 2; } @@ -531,7 +531,7 @@ void cpl_r1_r2() { WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - cpl(r_r1(w[0]), sys->cpu->gr[x_r2(w[0])]); + cpl(get_r_r1(w[0]), sys->cpu->gr[get_x_r2(w[0])]); sys->cpu->pr += 1; } @@ -547,9 +547,9 @@ void sla() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; sys->cpu->fr = 0x0; - sign = sys->cpu->gr[(r = r_r1(w[0]))] & 0x8000; + sign = sys->cpu->gr[(r = get_r_r1(w[0]))] & 0x8000; sys->cpu->gr[r] &= 0x7FFF; - for(i = 0; i < adrx(w[1], w[0]); i++) { + for(i = 0; i < get_adr_x(w[1], w[0]); i++) { last = sys->cpu->gr[r] & 0x4000; sys->cpu->gr[r] <<= 1; } @@ -582,9 +582,9 @@ void sra() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; sys->cpu->fr = 0x0; - sign = sys->cpu->gr[(r = r_r1(w[0]))] & 0x8000; + sign = sys->cpu->gr[(r = get_r_r1(w[0]))] & 0x8000; sys->cpu->gr[r] &= 0x7FFF; - for(i = 0; i < adrx(w[1], w[0]); i++) { + for(i = 0; i < get_adr_x(w[1], w[0]); i++) { last = sys->cpu->gr[r] & 0x1; sys->cpu->gr[r] >>= 1; if(sign > 0) { @@ -618,8 +618,8 @@ void sll() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; sys->cpu->fr = 0x0; - for(i = 0; i < adrx(w[1], w[0]); i++) { - last = sys->cpu->gr[(r = r_r1(w[0]))] & 0x8000; + for(i = 0; i < get_adr_x(w[1], w[0]); i++) { + last = sys->cpu->gr[(r = get_r_r1(w[0]))] & 0x8000; sys->cpu->gr[r] <<= 1; } /* OFに、レジスタから最後に送り出されたビットの値を設定 */ @@ -648,8 +648,8 @@ void srl() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; sys->cpu->fr = 0x0; - r = r_r1(w[0]); - for(i = 0; i < adrx(w[1], w[0]); i++) { + r = get_r_r1(w[0]); + for(i = 0; i < get_adr_x(w[1], w[0]); i++) { last = sys->cpu->gr[r] & 0x0001; sys->cpu->gr[r] >>= 1; } @@ -677,7 +677,7 @@ void jpl() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; if((sys->cpu->fr & (SF | ZF)) == 0) { - sys->cpu->pr = adrx(w[1], w[0]); + sys->cpu->pr = get_adr_x(w[1], w[0]); } else { sys->cpu->pr += 2; } @@ -692,7 +692,7 @@ void jmi() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; if((sys->cpu->fr & SF) > 0) { - sys->cpu->pr = adrx(w[1], w[0]); + sys->cpu->pr = get_adr_x(w[1], w[0]); } else { sys->cpu->pr += 2; } @@ -707,7 +707,7 @@ void jnz() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; if((sys->cpu->fr & ZF) == 0) { - sys->cpu->pr = adrx(w[1], w[0]); + sys->cpu->pr = get_adr_x(w[1], w[0]); } else { sys->cpu->pr += 2; } @@ -722,7 +722,7 @@ void jze() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; if((sys->cpu->fr & ZF) > 0) { - sys->cpu->pr = adrx(w[1], w[0]); + sys->cpu->pr = get_adr_x(w[1], w[0]); } else { sys->cpu->pr += 2; } @@ -737,7 +737,7 @@ void jov() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; if((sys->cpu->fr & OF) > 0) { - sys->cpu->pr = adrx(w[1], w[0]); + sys->cpu->pr = get_adr_x(w[1], w[0]); } else { sys->cpu->pr += 2; } @@ -751,7 +751,7 @@ void jump() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - sys->cpu->pr = adrx(w[1], w[0]); + sys->cpu->pr = get_adr_x(w[1], w[0]); } /** @@ -763,7 +763,7 @@ void push() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; assert(sys->cpu->sp > execptr->end && sys->cpu->sp <= sys->memsize); - sys->memory[--(sys->cpu->sp)] = adrx(w[1], w[0]); + sys->memory[--(sys->cpu->sp)] = get_adr_x(w[1], w[0]); sys->cpu->pr += 2; } @@ -775,7 +775,7 @@ void pop() assert(sys->cpu->sp > execptr->end && sys->cpu->sp <= sys->memsize); WORD w[1]; w[0] = sys->memory[sys->cpu->pr]; - sys->cpu->gr[r_r1(w[0])] = sys->memory[(sys->cpu->sp)++]; + sys->cpu->gr[get_r_r1(w[0])] = sys->memory[(sys->cpu->sp)++]; sys->cpu->pr += 1; } @@ -789,7 +789,7 @@ void call() w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; sys->memory[--(sys->cpu->sp)] = sys->cpu->pr + 1; - sys->cpu->pr = adrx(w[1], w[0]); + sys->cpu->pr = get_adr_x(w[1], w[0]); } /** @@ -813,7 +813,7 @@ void svc() WORD w[2]; w[0] = sys->memory[sys->cpu->pr]; w[1] = sys->memory[sys->cpu->pr + 1]; - switch(adrx(w[1], w[0])) + switch(get_adr_x(w[1], w[0])) { case 0x0: /* STOP */ execptr->stop = true;