*/
bool cometcmd(const CMDLINE *cmdl, PASS pass)
{
- WORD cmd, rr1, xr2, adr;
+ WORD cmd, r_r1, x_r2, adr;
/* オペランドなし */
if(cmdl->opd->opdc == 0) {
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);
}
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オペランドはアドレス */
/* メモリへの書き込み */
}
/* オペランド数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以外の命令の場合と、プログラムの入口名を取得できない場合は、 */
/**
* WORD値からr/r1を取得
*/
-WORD r_r1(WORD oprx)
+WORD get_r_r1(WORD oprx)
{
WORD r;
if((r = ((oprx & 0x00F0) >>4)) > GRSIZE - 1) {
/**
* WORD値からx/r2を取得
*/
-WORD x_r2(WORD oprx)
+WORD get_x_r2(WORD oprx)
{
WORD x;
if((x = (oprx & 0x000F)) > GRSIZE - 1) {
/**
* 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;
/**
* 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;
}
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;
}
{
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;
}
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;
}
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;
}
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;
}
{
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;
}
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;
}
{
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;
}
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;
}
{
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;
}
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;
}
{
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;
}
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;
}
{
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;
}
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;
}
{
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;
}
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;
}
{
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;
}
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;
}
{
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;
}
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;
}
{
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;
}
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;
}
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) {
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に、レジスタから最後に送り出されたビットの値を設定 */
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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]);
}
/**
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;
}
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;
}
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]);
}
/**
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;