示例#1
0
文件: sattable.c 项目: nitrologic/emu
static void saturn_instruction_1(saturn_state *cpustate)
{
	int reg, adr, oper;

	switch (adr=READ_OP(cpustate)) {
	case 0:
		switch (reg=READ_OP(cpustate)) {
		case 0: case 1: case 2: case 3: case 4:
			saturn_copy(cpustate, R0+reg, BEGIN_W, COUNT_W, A);
			break; // r0=a w
		case 8: case 9: case 0xa: case 0xb: case 0xc:
			saturn_copy(cpustate, R0+(reg&7), BEGIN_W, COUNT_W, C);
			break; // r0=c w
		default:
			saturn_invalid3( cpustate, 1, adr, reg );
			break;
		}
		break;
	case 1:
		switch (reg=READ_OP(cpustate)) {
		case 0: case 1: case 2: case 3: case 4:
			saturn_copy(cpustate, A, BEGIN_W, COUNT_W, R0+reg);
			break; // a=r0 w
		case 8: case 9: case 0xa: case 0xb: case 0xc:
			saturn_copy(cpustate, C, BEGIN_W, COUNT_W, R0+(reg&7));
			break; // c=r0 w
		default:
			saturn_invalid3( cpustate, 1, adr, reg );
			break;
		}
		break;
	case 2:
		switch (reg=READ_OP(cpustate)) {
		case 0: case 1: case 2: case 3: case 4:
			saturn_exchange(cpustate, A, BEGIN_W, COUNT_W, R0+reg);
			break; // ar0ex w
		case 8: case 9: case 0xa: case 0xb: case 0xc:
			saturn_exchange(cpustate, C, BEGIN_W, COUNT_W, R0+(reg&7));
			break; // cr0ex w
		default:
			saturn_invalid3( cpustate, 2, adr, reg );
			break;
		}
		break;
	case 3:
		switch (READ_OP(cpustate)) {
		case 0: saturn_reg_to_adr(cpustate, A,0);break;
		case 1: saturn_reg_to_adr(cpustate, A,1);break;
		case 2: saturn_exchange_adr_reg(cpustate, 0,A);break;
		case 3: saturn_exchange_adr_reg(cpustate, 1,A);break;
		case 4: saturn_reg_to_adr(cpustate, C,0);break;
		case 5: saturn_reg_to_adr(cpustate, C,1);break;
		case 6: saturn_exchange_adr_reg(cpustate, 0,C);break;
		case 7: saturn_exchange_adr_reg(cpustate, 1,C);break;
		case 8: saturn_reg_to_adr_word(cpustate, A,0);break;
		case 9: saturn_reg_to_adr_word(cpustate, A,1);break;
		case 0xa: saturn_exchange_adr_reg_word(cpustate, 0,A);break;
		case 0xb: saturn_exchange_adr_reg_word(cpustate, 1,A);break;
		case 0xc: saturn_reg_to_adr_word(cpustate, C,0);break;
		case 0xd: saturn_reg_to_adr_word(cpustate, C,1);break;
		case 0xe: saturn_exchange_adr_reg_word(cpustate, 0,C);break;
		case 0xf: saturn_exchange_adr_reg_word(cpustate, 1,C);break;
		}
		break;
	case 4:
		switch (READ_OP(cpustate)) {
		case 0: saturn_store_nibbles(cpustate, A, BEGIN_A, COUNT_A, 0); break;
		case 1: saturn_store_nibbles(cpustate, A, BEGIN_A, COUNT_A, 1); break;
		case 2: saturn_load_nibbles(cpustate, A, BEGIN_A, COUNT_A, 0); break;
		case 3: saturn_load_nibbles(cpustate, A, BEGIN_A, COUNT_A, 1); break;
		case 4: saturn_store_nibbles(cpustate, C, BEGIN_A, COUNT_A, 0); break;
		case 5: saturn_store_nibbles(cpustate, C, BEGIN_A, COUNT_A, 1); break;
		case 6: saturn_load_nibbles(cpustate, C, BEGIN_A, COUNT_A, 0); break;
		case 7: saturn_load_nibbles(cpustate, C, BEGIN_A, COUNT_A, 1); break;
		case 8: saturn_store_nibbles(cpustate, A, BEGIN_B, COUNT_B, 0); break;
		case 9: saturn_store_nibbles(cpustate, A, BEGIN_B, COUNT_B, 1); break;
		case 0xa: saturn_load_nibbles(cpustate, A, BEGIN_B, COUNT_B, 0); break;
		case 0xb: saturn_load_nibbles(cpustate, A, BEGIN_B, COUNT_B, 1); break;
		case 0xc: saturn_store_nibbles(cpustate, C, BEGIN_B, COUNT_B, 0); break;
		case 0xd: saturn_store_nibbles(cpustate, C, BEGIN_B, COUNT_B, 1); break;
		case 0xe: saturn_load_nibbles(cpustate, C, BEGIN_B, COUNT_B, 0); break;
		case 0xf: saturn_load_nibbles(cpustate, C, BEGIN_B, COUNT_B, 1); break;
		}
		break;
	case 5:
		switch (oper=READ_OP(cpustate)) {
		case 0: case 1: case 4: case 5:
			switch (adr=READ_OP(cpustate)) {
			case 0:
				saturn_store_nibbles(cpustate, oper&4?C:A,cpustate->p,1,oper&1);
				break;
			case 1:
				saturn_store_nibbles(cpustate, oper&4?C:A,0,cpustate->p+1,oper&1);
				break;
			case 2: case 3: case 4: case 5: case 6: case 7:
				saturn_store_nibbles(cpustate, oper&4?C:A,adr_a_begin[adr],adr_a_count[adr],oper&1);
				break;
			default:
				saturn_invalid4( cpustate, 1, 5, oper, adr );
				break;
			}
			break;
		case 2: case 3: case 6: case 7:
			switch (adr=READ_OP(cpustate)) {
			case 0:
				saturn_load_nibbles(cpustate, oper&4?C:A,cpustate->p,1,oper&1);
				break;
			case 1:
				saturn_load_nibbles(cpustate, oper&4?C:A,0,cpustate->p+1,oper&1);
				break;
			case 2: case 3: case 4: case 5: case 6: case 7:
				saturn_load_nibbles(cpustate, oper&4?C:A,adr_a_begin[adr],adr_a_count[adr],oper&1);
				break;
			default:
				saturn_invalid4( cpustate, 1, 5, oper, adr );
				break;
			}
			break;
		case 8: saturn_store_nibbles(cpustate, A, 0, READ_OP(cpustate)+1, 0); break;
		case 9: saturn_store_nibbles(cpustate, A, 0, READ_OP(cpustate)+1, 1); break;
		case 0xa: saturn_load_nibbles(cpustate, A, 0, READ_OP(cpustate)+1, 0); break;
		case 0xb: saturn_load_nibbles(cpustate, A, 0, READ_OP(cpustate)+1, 1); break;
		case 0xc: saturn_store_nibbles(cpustate, C, 0, READ_OP(cpustate)+1, 0); break;
		case 0xd: saturn_store_nibbles(cpustate, C, 0, READ_OP(cpustate)+1, 1); break;
		case 0xe: saturn_load_nibbles(cpustate, C, 0, READ_OP(cpustate)+1, 0); break;
		case 0xf: saturn_load_nibbles(cpustate, C, 0, READ_OP(cpustate)+1, 1); break;
		}
		break;
	case 6: saturn_add_adr(cpustate, 0);break;
	case 7: saturn_add_adr(cpustate, 1);break;
	case 8: saturn_sub_adr(cpustate, 0);break;
	case 9: saturn_load_adr(cpustate, 0,2);break;
	case 0xa: saturn_load_adr(cpustate, 0,4);break;
	case 0xb: saturn_load_adr(cpustate, 0,5);break;
	case 0xc: saturn_sub_adr(cpustate, 1);break;
	case 0xd: saturn_load_adr(cpustate, 1,2);break;
	case 0xe: saturn_load_adr(cpustate, 1,4);break;
	case 0xf: saturn_load_adr(cpustate, 1,5);break;
	}
}
示例#2
0
static void saturn_instruction_1(void)
{
	int reg, adr, oper;

	switch (adr=READ_OP()) {
	case 0:
		switch (reg=READ_OP()) {
		case 0: case 1: case 2: case 3: case 4:
			saturn_copy(R0+reg, BEGIN_W, COUNT_W, A);
			break; /* r0=a w */
		case 8: case 9: case 0xa: case 0xb: case 0xc:
			saturn_copy(R0+(reg&7), BEGIN_W, COUNT_W, C);
			break; /* r0=c w */
		}
		break;
	case 1:
		switch (reg=READ_OP()) {
		case 0: case 1: case 2: case 3: case 4:
			saturn_copy(A, BEGIN_W, COUNT_W, R0+reg);
			break; /* a=r0 w */
		case 8: case 9: case 0xa: case 0xb: case 0xc:
			saturn_copy(C, BEGIN_W, COUNT_W, R0+(reg&7));
			break; /* c=r0 w */
		}
		break;
	case 2:
		switch (reg=READ_OP()) {
		case 0: case 1: case 2: case 3: case 4:
			saturn_exchange(A, BEGIN_W, COUNT_W, R0+reg);
			break; /* ar0ex w */
		case 8: case 9: case 0xa: case 0xb: case 0xc:
			saturn_exchange(C, BEGIN_W, COUNT_W, R0+(reg&7));
			break; /* cr0ex w */
		}
		break;
	case 3:
		switch (READ_OP()) {
		case 0: saturn_reg_to_adr(A,0);break;
		case 1: saturn_reg_to_adr(A,1);break;
		case 2: saturn_exchange_adr_reg(0,A);break;
		case 3: saturn_exchange_adr_reg(1,A);break;
		case 4: saturn_reg_to_adr(C,0);break;
		case 5: saturn_reg_to_adr(C,1);break;
		case 6: saturn_exchange_adr_reg(0,C);break;
		case 7: saturn_exchange_adr_reg(1,C);break;
		case 8: saturn_reg_to_adr_word(A,0);break;
		case 9: saturn_reg_to_adr_word(A,1);break;
		case 0xa: saturn_exchange_adr_reg_word(0,A);break;
		case 0xb: saturn_exchange_adr_reg_word(1,A);break;
		case 0xc: saturn_reg_to_adr_word(C,0);break;
		case 0xd: saturn_reg_to_adr_word(C,1);break;
		case 0xe: saturn_exchange_adr_reg_word(0,C);break;
		case 0xf: saturn_exchange_adr_reg_word(1,C);break;
		}
		break;
	case 4:
		switch (READ_OP()) {
		case 0: saturn_store_nibbles(A, BEGIN_A, COUNT_A, 0); break;
		case 1: saturn_store_nibbles(A, BEGIN_A, COUNT_A, 1); break;
		case 2: saturn_load_nibbles(A, BEGIN_A, COUNT_A, 0); break;
		case 3: saturn_load_nibbles(A, BEGIN_A, COUNT_A, 1); break;
		case 4: saturn_store_nibbles(C, BEGIN_A, COUNT_A, 0); break;
		case 5: saturn_store_nibbles(C, BEGIN_A, COUNT_A, 1); break;
		case 6: saturn_load_nibbles(C, BEGIN_A, COUNT_A, 0); break;
		case 7: saturn_load_nibbles(C, BEGIN_A, COUNT_A, 1); break;
		case 8: saturn_store_nibbles(A, BEGIN_B, COUNT_B, 0); break;
		case 9: saturn_store_nibbles(A, BEGIN_B, COUNT_B, 1); break;
		case 0xa: saturn_load_nibbles(A, BEGIN_B, COUNT_B, 0); break;
		case 0xb: saturn_load_nibbles(A, BEGIN_B, COUNT_B, 1); break;
		case 0xc: saturn_store_nibbles(C, BEGIN_B, COUNT_B, 0); break;
		case 0xd: saturn_store_nibbles(C, BEGIN_B, COUNT_B, 1); break;
		case 0xe: saturn_load_nibbles(C, BEGIN_B, COUNT_B, 0); break;
		case 0xf: saturn_load_nibbles(C, BEGIN_B, COUNT_B, 1); break;
		}
		break;
	case 5:
		switch (oper=READ_OP()) {
		case 0: case 1: case 4: case 5:
			switch (adr=READ_OP()) {
			case 0: 
				saturn_store_nibbles(oper&4?C:A,saturn.p,1,oper&1);
				break;
			case 1: 
				saturn_store_nibbles(oper&4?C:A,0,saturn.p+1,oper&1);
				break;
			case 2: case 3: case 4: case 5: case 6: case 7:
				saturn_store_nibbles(oper&4?C:A,adr_a_begin[adr],adr_a_count[adr],oper&1);
				break;
			}
			break;
		case 2: case 3: case 6: case 7:
			switch (adr=READ_OP()) {
			case 0: 
				saturn_load_nibbles(oper&4?C:A,saturn.p,1,oper&1);
				break;
			case 1: 
				saturn_load_nibbles(oper&4?C:A,0,saturn.p+1,oper&1);
				break;
			case 2: case 3: case 4: case 5: case 6: case 7:
				saturn_load_nibbles(oper&4?C:A,adr_a_begin[adr],adr_a_count[adr],oper&1);
				break;
			}
			break;
		case 8: saturn_store_nibbles(A, 0, READ_OP()+1, 0); break;
		case 9: saturn_store_nibbles(A, 0, READ_OP()+1, 1); break;
		case 0xa: saturn_load_nibbles(A, 0, READ_OP()+1, 0); break;
		case 0xb: saturn_load_nibbles(A, 0, READ_OP()+1, 1); break;
		case 0xc: saturn_store_nibbles(C, 0, READ_OP()+1, 0); break;
		case 0xd: saturn_store_nibbles(C, 0, READ_OP()+1, 1); break;
		case 0xe: saturn_load_nibbles(C, 0, READ_OP()+1, 0); break;
		case 0xf: saturn_load_nibbles(C, 0, READ_OP()+1, 1); break;
		}
		break;
	case 9: saturn_load_adr(0,2);break;
	case 0xa: saturn_load_adr(0,4);break;
	case 0xb: saturn_load_adr(0,5);break;
	case 0xd: saturn_load_adr(1,2);break;
	case 0xe: saturn_load_adr(1,4);break;
	case 0xf: saturn_load_adr(1,5);break;
	case 6: saturn_add_adr(0);break;
	case 7: saturn_add_adr(1);break;
	case 8: saturn_sub_adr(0);break;
	case 0xc: saturn_sub_adr(1);break;
	}
}