mirror of
https://github.com/pevans/erc-c.git
synced 2024-09-29 11:55:01 +00:00
Set carry if the right-most bit is 1
Don't consider the left-most bit
This commit is contained in:
parent
5d8403aaa7
commit
3206332a7d
@ -97,8 +97,17 @@ DEFINE_INST(lsr)
|
|||||||
{
|
{
|
||||||
SET_RESULT(oper >> 1);
|
SET_RESULT(oper >> 1);
|
||||||
|
|
||||||
// MOS_NEGATIVE is intentionally not included here.
|
// Set ZERO if it should apply
|
||||||
mos6502_modify_status(cpu, MOS_ZC, oper, result);
|
mos6502_modify_status(cpu, MOS_ZERO, oper, result);
|
||||||
|
|
||||||
|
// However, we handle carry a bit differently here. The carry bit
|
||||||
|
// should be 1 if oper & 0x1; that is, when we shift right, we want
|
||||||
|
// the right-most bit to be captured in carry, in just the same way
|
||||||
|
// we want the left-most bit to be captured in carry for ASL.
|
||||||
|
cpu->P &= ~MOS_CARRY;
|
||||||
|
if (oper & 0x1) {
|
||||||
|
cpu->P |= MOS_CARRY;
|
||||||
|
}
|
||||||
|
|
||||||
if (cpu->eff_addr) {
|
if (cpu->eff_addr) {
|
||||||
mos6502_set(cpu, cpu->eff_addr, result & 0xff);
|
mos6502_set(cpu, cpu->eff_addr, result & 0xff);
|
||||||
|
Loading…
Reference in New Issue
Block a user