Line 185... |
Line 185... |
ASL_ZPG: { exec_asl_mem(); }; // M,Z,C,N = M*2
|
ASL_ZPG: { exec_asl_mem(); }; // M,Z,C,N = M*2
|
ASL_ZPX: { exec_asl_mem(); };
|
ASL_ZPX: { exec_asl_mem(); };
|
ASL_ABS: { exec_asl_mem(); };
|
ASL_ABS: { exec_asl_mem(); };
|
ASL_ABX: { exec_asl_mem(); };
|
ASL_ABX: { exec_asl_mem(); };
|
|
|
BCC_REL: {}; // nothing is done. these are all branches.
|
//BCC_REL: {}; // nothing is done. these are all branches.
|
BCS_REL: {};
|
//BCS_REL: {};
|
BEQ_REL: {};
|
//BEQ_REL: {};
|
BMI_REL: {};
|
//BMI_REL: {};
|
BNE_REL: {};
|
//BNE_REL: {};
|
BPL_REL: {};
|
//BPL_REL: {};
|
BVC_REL: {};
|
//BVC_REL: {};
|
BVS_REL: {};
|
//BVS_REL: {};
|
|
|
BIT_ZPG: { exec_bit(); }; // Z = A & M, N = M7, V = M6
|
BIT_ZPG: { exec_bit(); }; // Z = A & M, N = M7, V = M6
|
BIT_ABS: { exec_bit(); };
|
BIT_ABS: { exec_bit(); };
|
|
|
BRK_IMP: { reg_status[4:4] = 1; };
|
BRK_IMP: { reg_status[4:4] = 1; };
|
Line 246... |
Line 246... |
INC_ABX: { exec_inc(inst.alu_a, TRUE); };
|
INC_ABX: { exec_inc(inst.alu_a, TRUE); };
|
|
|
INX_IMP: { exec_inc(reg_x, FALSE); };
|
INX_IMP: { exec_inc(reg_x, FALSE); };
|
INY_IMP: { exec_inc(reg_y, FALSE); };
|
INY_IMP: { exec_inc(reg_y, FALSE); };
|
|
|
JMP_ABS: {};
|
//JMP_ABS: {};
|
JMP_IND: {};
|
//JMP_IND: {};
|
JSR_ABS: {};
|
//JSR_ABS: {};
|
|
|
LDA_IMM: { exec_load(reg_a, TRUE); }; // A,Z,N = M
|
LDA_IMM: { exec_load(reg_a, TRUE); }; // A,Z,N = M
|
LDA_ZPG: { exec_load(reg_a, TRUE); };
|
LDA_ZPG: { exec_load(reg_a, TRUE); };
|
LDA_ZPX: { exec_load(reg_a, TRUE); };
|
LDA_ZPX: { exec_load(reg_a, TRUE); };
|
LDA_ABS: { exec_load(reg_a, TRUE); };
|
LDA_ABS: { exec_load(reg_a, TRUE); };
|
Line 277... |
Line 277... |
LSR_ZPG: { exec_lsr(inst.alu_a); };
|
LSR_ZPG: { exec_lsr(inst.alu_a); };
|
LSR_ZPX: { exec_lsr(inst.alu_a); };
|
LSR_ZPX: { exec_lsr(inst.alu_a); };
|
LSR_ABS: { exec_lsr(inst.alu_a); };
|
LSR_ABS: { exec_lsr(inst.alu_a); };
|
LSR_ABX: { exec_lsr(inst.alu_a); };
|
LSR_ABX: { exec_lsr(inst.alu_a); };
|
|
|
NOP_IMP: {};
|
//NOP_IMP: {};
|
|
|
ORA_IMM: { exec_or(); }; // A,Z,N = A|M
|
ORA_IMM: { exec_or(); }; // A,Z,N = A|M
|
ORA_ZPG: { exec_or(); };
|
ORA_ZPG: { exec_or(); };
|
ORA_ZPX: { exec_or(); };
|
ORA_ZPX: { exec_or(); };
|
ORA_ABS: { exec_or(); };
|
ORA_ABS: { exec_or(); };
|
Line 289... |
Line 289... |
ORA_ABY: { exec_or(); };
|
ORA_ABY: { exec_or(); };
|
ORA_IDX: { exec_or(); };
|
ORA_IDX: { exec_or(); };
|
ORA_IDY: { exec_or(); };
|
ORA_IDY: { exec_or(); };
|
|
|
PHA_IMP: { reg_result = reg_a; };
|
PHA_IMP: { reg_result = reg_a; };
|
PHP_IMP: {}; // P is always connected and the result is not updated
|
//PHP_IMP: {}; // P is always connected and the result is not updated
|
PLA_IMP: {
|
PLA_IMP: {
|
reg_a = inst.alu_a;
|
reg_a = inst.alu_a;
|
reg_result = inst.alu_a;
|
reg_result = inst.alu_a;
|
update_z(reg_a);
|
update_z(reg_a);
|
update_n(reg_a);
|
update_n(reg_a);
|
Line 313... |
Line 313... |
ROR_ZPX: { exec_rot(FALSE, inst.alu_a); };
|
ROR_ZPX: { exec_rot(FALSE, inst.alu_a); };
|
ROR_ABS: { exec_rot(FALSE, inst.alu_a); };
|
ROR_ABS: { exec_rot(FALSE, inst.alu_a); };
|
ROR_ABX: { exec_rot(FALSE, inst.alu_a); };
|
ROR_ABX: { exec_rot(FALSE, inst.alu_a); };
|
|
|
RTI_IMP: { reg_status = inst.alu_a; reg_status[5:5] = 1; };
|
RTI_IMP: { reg_status = inst.alu_a; reg_status[5:5] = 1; };
|
RTS_IMP: { };
|
//RTS_IMP: { };
|
|
|
SBC_IMM: { exec_sub(); }; // A,Z,C,N = A-M-(1-C)
|
SBC_IMM: { exec_sub(); }; // A,Z,C,N = A-M-(1-C)
|
SBC_ZPG: { exec_sub(); };
|
SBC_ZPG: { exec_sub(); };
|
SBC_ZPX: { exec_sub(); };
|
SBC_ZPX: { exec_sub(); };
|
SBC_ABS: { exec_sub(); };
|
SBC_ABS: { exec_sub(); };
|
Line 370... |
Line 370... |
|
|
temp = reg_a - inst.alu_a - 1 + reg_status[0:0];
|
temp = reg_a - inst.alu_a - 1 + reg_status[0:0];
|
reg_result = reg_a - inst.alu_a - 1 + reg_status[0:0];
|
reg_result = reg_a - inst.alu_a - 1 + reg_status[0:0];
|
|
|
reg_status[7:7] = temp[7:7]; // N
|
reg_status[7:7] = temp[7:7]; // N
|
//print (reg_a ^ inst.alu_a) & (reg_a ^ temp) & 0x80;
|
|
reg_status[6:6] = (reg_a[7:7] ^ inst.alu_a[7:7]) & (reg_a[7:7] ^ temp[7:7]); // V
|
reg_status[6:6] = (reg_a[7:7] ^ inst.alu_a[7:7]) & (reg_a[7:7] ^ temp[7:7]); // V
|
|
|
print reg_result;
|
|
if (reg_result == 0) {
|
if (reg_result == 0) {
|
reg_status[1:1] = 1; // Z
|
reg_status[1:1] = 1; // Z
|
} else {
|
} else {
|
reg_status[1:1] = 0; // Z
|
reg_status[1:1] = 0; // Z
|
};
|
};
|
Line 385... |
Line 383... |
if (reg_status[3:3] == 1) { // decimal
|
if (reg_status[3:3] == 1) { // decimal
|
var op1 : int;
|
var op1 : int;
|
var op2 : int;
|
var op2 : int;
|
|
|
op1 = (reg_a & 0x0f ) - (inst.alu_a & 0x0f) - ( (reg_status[0:0] == 1) ? 0 : 1);
|
op1 = (reg_a & 0x0f ) - (inst.alu_a & 0x0f) - ( (reg_status[0:0] == 1) ? 0 : 1);
|
print op1;
|
|
op2 = (reg_a & 0xf0) - (inst.alu_a & 0xf0);
|
op2 = (reg_a & 0xf0) - (inst.alu_a & 0xf0);
|
print op2;
|
|
|
|
if (op1[4:4] == 1) {
|
if (op1[4:4] == 1) {
|
op1 -= 6;
|
op1 -= 6;
|
op2 = op2 - 1;
|
op2 = op2 - 1;
|
};
|
};
|
print op1;
|
|
print op2;
|
|
|
|
if(op2[8:8] == 1) {
|
if(op2[8:8] == 1) {
|
op2 -= 0x60;
|
op2 -= 0x60;
|
};
|
};
|
print op2;
|
|
|
|
reg_a = (op1 & 0x0f) | (op2 & 0xf0);
|
reg_a = (op1 & 0x0f) | (op2 & 0xf0);
|
reg_result = reg_a;
|
reg_result = reg_a;
|
}
|
}
|
else {
|
else {
|