check if transferred value is zero and set the z bit of the p status register

This commit is contained in:
Preston Skupinski 2011-05-01 13:46:28 -04:00
parent b167d4c164
commit 93ae3ec6a0

28
cpu.js
View File

@ -115,7 +115,11 @@ var TYA = {
// 8-bit index register to 16-bit accumulator. // 8-bit index register to 16-bit accumulator.
// 16-bit index register to 16-bit accumulator. // 16-bit index register to 16-bit accumulator.
cpu.r.a = cpu.r.y; cpu.r.a = cpu.r.y;
} }
if(cpu.r.a===0) {
cpu.p.z = 1;
}
// TODO: Set n bit of the p status register.
} }
}; };
@ -142,6 +146,10 @@ var TAY = {
cpu.r.y = cpu.r.a; cpu.r.y = cpu.r.a;
} }
} }
if(cpu.r.y===0) {
cpu.p.z = 1;
}
// TODO: Set n bit of the p status register.
} }
}; };
@ -163,7 +171,11 @@ var TXA = {
// 8-bit index register to 16-bit accumulator. // 8-bit index register to 16-bit accumulator.
// 16-bit index register to 16-bit accumulator. // 16-bit index register to 16-bit accumulator.
cpu.r.a = cpu.r.x; cpu.r.a = cpu.r.x;
} }
if(cpu.r.a===0) {
cpu.p.z = 1;
}
// TODO: Set n bit of the p status register.
} }
}; };
@ -190,6 +202,10 @@ var TAX = {
cpu.r.x = cpu.r.a; cpu.r.x = cpu.r.a;
} }
} }
if(cpu.r.x===0) {
cpu.p.z = 1;
}
// TODO: Set n bit of the p status register.
} }
}; };
@ -199,6 +215,10 @@ var TXY = {
}, },
execute:function(cpu) { execute:function(cpu) {
cpu.r.y = cpu.r.x; cpu.r.y = cpu.r.x;
if(cpu.r.y===0) {
cpu.p.z = 1;
}
// TODO: Set n bit of the p status register.
} }
}; };
@ -208,6 +228,10 @@ var TYX = {
}, },
execute:function(cpu) { execute:function(cpu) {
cpu.r.y = cpu.r.x; cpu.r.y = cpu.r.x;
if(cpu.r.y===0) {
cpu.p.z = 1;
}
// TODO: Set n bit of the p status register.
} }
}; };