Line 121... |
Line 121... |
CMP_IMM, CMP_ZPG, CMP_ZPX, CMP_ABS, CMP_ABX, CMP_ABY, CMP_IDX, CMP_IDY,
|
CMP_IMM, CMP_ZPG, CMP_ZPX, CMP_ABS, CMP_ABX, CMP_ABY, CMP_IDX, CMP_IDY,
|
CPX_IMM, CPX_ZPG, CPX_ABS, CPY_IMM, CPY_ZPG, CPY_ABS, PHP_IMP :
|
CPX_IMM, CPX_ZPG, CPX_ABS, CPY_IMM, CPY_ZPG, CPY_ABS, PHP_IMP :
|
begin
|
begin
|
alu_status <= STATUS;
|
alu_status <= STATUS;
|
end
|
end
|
|
PHA_IMP :
|
|
begin
|
|
alu_result <= result;
|
|
end
|
SEC_IMP :
|
SEC_IMP :
|
begin
|
begin
|
alu_status[C] <= 1;
|
alu_status[C] <= 1;
|
end
|
end
|
SED_IMP :
|
SED_IMP :
|
Line 329... |
Line 333... |
{STATUS[C],result} = op1 + op2 + alu_status[C];
|
{STATUS[C],result} = op1 + op2 + alu_status[C];
|
if ((op1[7] == op2[7]) && (op1[7] != result[7]))
|
if ((op1[7] == op2[7]) && (op1[7] != result[7]))
|
STATUS[V] = 1;
|
STATUS[V] = 1;
|
else
|
else
|
STATUS[V] = 0;
|
STATUS[V] = 0;
|
$display("op1 + op2 + C = result + C (V)");
|
//$display("op1 + op2 + C = result + C (V)");
|
$display("%d + %d + %b = %d + %b (%b)", op1, op2, alu_status[C],result,STATUS[C],STATUS[V]);
|
//$display("%d + %d + %b = %d + %b (%b)", op1, op2, alu_status[C],result,STATUS[C],STATUS[V]);
|
|
|
if (alu_status[D] == 1) begin
|
if (alu_status[D] == 1) begin
|
if (result[3:0] > 9) begin
|
if (result[3:0] > 9) begin
|
result = result[3:0] + 6; // A = A - 10 and A = A + 16
|
result = result[3:0] + 6; // A = A - 10 and A = A + 16
|
end
|
end
|
Line 357... |
Line 361... |
end
|
end
|
|
|
// EOR - Exclusive OR
|
// EOR - Exclusive OR
|
EOR_IMM, EOR_ZPG, EOR_ZPX, EOR_ABS, EOR_ABX, EOR_ABY, EOR_IDX, EOR_IDY : begin
|
EOR_IMM, EOR_ZPG, EOR_ZPX, EOR_ABS, EOR_ABX, EOR_ABY, EOR_IDX, EOR_IDY : begin
|
result = A ^ alu_a;
|
result = A ^ alu_a;
|
$display("op1 ^ op2 = result");
|
//$display("op1 ^ op2 = result");
|
$display("%d ^ %d = %d", op1, op2, result);
|
//$display("%d ^ %d = %d", op1, op2, result);
|
end
|
end
|
|
|
// LDA - Load Accumulator
|
// LDA - Load Accumulator
|
// LDX - Load X Register
|
// LDX - Load X Register
|
// LDY - Load Y Register
|
// LDY - Load Y Register
|