Update to v102r23 release.
byuu says:
Changelog:
- rewrote the 6502 CPU core from scratch. Now called MOS6502,
supported BCD mode
- Famicom core disables BCD mode via MOS6502::BCD = 0;
- renamed r65816 folder to wdc65816 (still need to rename the actual
class, though ...)
Note: need to remove build rules for the now renamed r6502, r65816
objects from processor/GNUmakefile.
So this'll seem like a small WIP, but it was a solid five hours to
rewrite the entire 6502 core. The reason I wanted to do this was because
the old 6502 core was pretty sloppy. My coding style improved a lot, and
I really liked how the HuC6280 CPU core came out, so I wanted the 6502
core to be like that one.
The core can now support BCD mode, so hopefully that will prove useful
to hex\_usr and allow one core to run both the NES and his Atari 2600
cores at some point.
Note that right now, the core doesn't support any illegal instructions.
The old core supported a small number of them, but were mostly the no
operation ones. The goal is support all of the illegal instructions at
some point.
It's very possible the rewrite introduced some regressions, so thorough
testing of the NES core would be appreciated if anyone were up for it.
2017-06-11 01:51:53 +00:00
|
|
|
auto MOS6502::instructionAbsoluteModify(fp alu) -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
absolute |= operand() << 8;
|
|
|
|
auto data = read(absolute);
|
|
|
|
write(absolute, data);
|
|
|
|
L write(absolute, ALU(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionAbsoluteModify(fp alu, uint8 index) -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
absolute |= operand() << 8;
|
|
|
|
idlePageAlways(absolute, absolute + index);
|
|
|
|
auto data = read(absolute + index);
|
|
|
|
write(absolute + index, data);
|
|
|
|
L write(absolute + index, ALU(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionAbsoluteRead(fp alu, uint8& data) -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
absolute |= operand() << 8;
|
|
|
|
L data = ALU(read(absolute));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionAbsoluteRead(fp alu, uint8& data, uint8 index) -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
absolute |= operand() << 8;
|
|
|
|
idlePageCrossed(absolute, absolute + index);
|
|
|
|
L data = ALU(read(absolute + index));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionAbsoluteWrite(uint8& data) -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
absolute |= operand() << 8;
|
|
|
|
L write(absolute, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionAbsoluteWrite(uint8& data, uint8 index) -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
absolute |= operand() << 8;
|
|
|
|
idlePageAlways(absolute, absolute + index);
|
|
|
|
L write(absolute + index, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionBranch(bool take) -> void {
|
|
|
|
if(!take) {
|
|
|
|
L operand();
|
|
|
|
} else {
|
|
|
|
int8 displacement = operand();
|
|
|
|
idlePageCrossed(PC, PC + displacement);
|
|
|
|
L idle();
|
|
|
|
PC = PC + displacement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-29 10:36:35 +00:00
|
|
|
auto MOS6502::instructionBreak() -> void {
|
|
|
|
operand();
|
|
|
|
push(PCH);
|
|
|
|
push(PCL);
|
|
|
|
uint16 vector = 0xfffe;
|
|
|
|
nmi(vector);
|
|
|
|
push(P | 0x30);
|
|
|
|
I = 1;
|
|
|
|
PCL = read(vector++);
|
|
|
|
L PCH = read(vector++);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionCallAbsolute() -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
absolute |= operand() << 8;
|
|
|
|
idle();
|
|
|
|
PC--;
|
|
|
|
push(PCH);
|
|
|
|
L push(PCL);
|
|
|
|
PC = absolute;
|
|
|
|
}
|
|
|
|
|
Update to v102r23 release.
byuu says:
Changelog:
- rewrote the 6502 CPU core from scratch. Now called MOS6502,
supported BCD mode
- Famicom core disables BCD mode via MOS6502::BCD = 0;
- renamed r65816 folder to wdc65816 (still need to rename the actual
class, though ...)
Note: need to remove build rules for the now renamed r6502, r65816
objects from processor/GNUmakefile.
So this'll seem like a small WIP, but it was a solid five hours to
rewrite the entire 6502 core. The reason I wanted to do this was because
the old 6502 core was pretty sloppy. My coding style improved a lot, and
I really liked how the HuC6280 CPU core came out, so I wanted the 6502
core to be like that one.
The core can now support BCD mode, so hopefully that will prove useful
to hex\_usr and allow one core to run both the NES and his Atari 2600
cores at some point.
Note that right now, the core doesn't support any illegal instructions.
The old core supported a small number of them, but were mostly the no
operation ones. The goal is support all of the illegal instructions at
some point.
It's very possible the rewrite introduced some regressions, so thorough
testing of the NES core would be appreciated if anyone were up for it.
2017-06-11 01:51:53 +00:00
|
|
|
auto MOS6502::instructionClear(bool& flag) -> void {
|
|
|
|
L idle();
|
|
|
|
flag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionImmediate(fp alu, uint8& data) -> void {
|
|
|
|
L data = ALU(operand());
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionImplied(fp alu, uint8& data) -> void {
|
|
|
|
L idle();
|
|
|
|
data = ALU(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionIndirectXRead(fp alu, uint8& data) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
load(zeroPage);
|
|
|
|
uint16 absolute = load(zeroPage + X + 0);
|
|
|
|
absolute |= load(zeroPage + X + 1) << 8;
|
|
|
|
L data = ALU(read(absolute));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionIndirectXWrite(uint8& data) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
load(zeroPage);
|
|
|
|
uint16 absolute = load(zeroPage + X + 0);
|
|
|
|
absolute |= load(zeroPage + X + 1) << 8;
|
|
|
|
L write(absolute, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionIndirectYRead(fp alu, uint8& data) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
uint16 absolute = load(zeroPage + 0);
|
|
|
|
absolute |= load(zeroPage + 1) << 8;
|
|
|
|
idlePageCrossed(absolute, absolute + Y);
|
|
|
|
L data = ALU(read(absolute + Y));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionIndirectYWrite(uint8& data) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
uint16 absolute = load(zeroPage + 0);
|
|
|
|
absolute |= load(zeroPage + 1) << 8;
|
|
|
|
idlePageAlways(absolute, absolute + Y);
|
|
|
|
L write(absolute + Y, data);
|
|
|
|
}
|
|
|
|
|
2017-09-29 10:36:35 +00:00
|
|
|
auto MOS6502::instructionJumpAbsolute() -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
L absolute |= operand() << 8;
|
|
|
|
PC = absolute;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionJumpIndirect() -> void {
|
|
|
|
uint16 absolute = operand();
|
|
|
|
absolute |= operand() << 8;
|
|
|
|
uint16 pc = read(absolute);
|
|
|
|
absolute.byte(0)++; //MOS6502: $00ff wraps here to $0000; not $0100
|
|
|
|
L pc |= read(absolute) << 8;
|
|
|
|
PC = pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionNoOperation() -> void {
|
|
|
|
L idle();
|
|
|
|
}
|
|
|
|
|
Update to v102r23 release.
byuu says:
Changelog:
- rewrote the 6502 CPU core from scratch. Now called MOS6502,
supported BCD mode
- Famicom core disables BCD mode via MOS6502::BCD = 0;
- renamed r65816 folder to wdc65816 (still need to rename the actual
class, though ...)
Note: need to remove build rules for the now renamed r6502, r65816
objects from processor/GNUmakefile.
So this'll seem like a small WIP, but it was a solid five hours to
rewrite the entire 6502 core. The reason I wanted to do this was because
the old 6502 core was pretty sloppy. My coding style improved a lot, and
I really liked how the HuC6280 CPU core came out, so I wanted the 6502
core to be like that one.
The core can now support BCD mode, so hopefully that will prove useful
to hex\_usr and allow one core to run both the NES and his Atari 2600
cores at some point.
Note that right now, the core doesn't support any illegal instructions.
The old core supported a small number of them, but were mostly the no
operation ones. The goal is support all of the illegal instructions at
some point.
It's very possible the rewrite introduced some regressions, so thorough
testing of the NES core would be appreciated if anyone were up for it.
2017-06-11 01:51:53 +00:00
|
|
|
auto MOS6502::instructionPull(uint8& data) -> void {
|
|
|
|
idle();
|
|
|
|
idle();
|
|
|
|
L data = pull();
|
|
|
|
Z = data == 0;
|
|
|
|
N = data.bit(7);
|
|
|
|
}
|
|
|
|
|
2017-09-29 10:36:35 +00:00
|
|
|
auto MOS6502::instructionPullP() -> void {
|
|
|
|
idle();
|
|
|
|
idle();
|
|
|
|
L P = pull();
|
|
|
|
}
|
|
|
|
|
Update to v102r23 release.
byuu says:
Changelog:
- rewrote the 6502 CPU core from scratch. Now called MOS6502,
supported BCD mode
- Famicom core disables BCD mode via MOS6502::BCD = 0;
- renamed r65816 folder to wdc65816 (still need to rename the actual
class, though ...)
Note: need to remove build rules for the now renamed r6502, r65816
objects from processor/GNUmakefile.
So this'll seem like a small WIP, but it was a solid five hours to
rewrite the entire 6502 core. The reason I wanted to do this was because
the old 6502 core was pretty sloppy. My coding style improved a lot, and
I really liked how the HuC6280 CPU core came out, so I wanted the 6502
core to be like that one.
The core can now support BCD mode, so hopefully that will prove useful
to hex\_usr and allow one core to run both the NES and his Atari 2600
cores at some point.
Note that right now, the core doesn't support any illegal instructions.
The old core supported a small number of them, but were mostly the no
operation ones. The goal is support all of the illegal instructions at
some point.
It's very possible the rewrite introduced some regressions, so thorough
testing of the NES core would be appreciated if anyone were up for it.
2017-06-11 01:51:53 +00:00
|
|
|
auto MOS6502::instructionPush(uint8& data) -> void {
|
|
|
|
idle();
|
|
|
|
L push(data);
|
|
|
|
}
|
|
|
|
|
2017-09-29 10:36:35 +00:00
|
|
|
auto MOS6502::instructionPushP() -> void {
|
|
|
|
idle();
|
|
|
|
L push(P | 0x30);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionReturnInterrupt() -> void {
|
|
|
|
idle();
|
|
|
|
idle();
|
|
|
|
P = pull();
|
|
|
|
PCL = pull();
|
|
|
|
L PCH = pull();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionReturnSubroutine() -> void {
|
|
|
|
idle();
|
|
|
|
idle();
|
|
|
|
PCL = pull();
|
|
|
|
PCH = pull();
|
|
|
|
L idle();
|
|
|
|
PC++;
|
|
|
|
}
|
|
|
|
|
Update to v102r23 release.
byuu says:
Changelog:
- rewrote the 6502 CPU core from scratch. Now called MOS6502,
supported BCD mode
- Famicom core disables BCD mode via MOS6502::BCD = 0;
- renamed r65816 folder to wdc65816 (still need to rename the actual
class, though ...)
Note: need to remove build rules for the now renamed r6502, r65816
objects from processor/GNUmakefile.
So this'll seem like a small WIP, but it was a solid five hours to
rewrite the entire 6502 core. The reason I wanted to do this was because
the old 6502 core was pretty sloppy. My coding style improved a lot, and
I really liked how the HuC6280 CPU core came out, so I wanted the 6502
core to be like that one.
The core can now support BCD mode, so hopefully that will prove useful
to hex\_usr and allow one core to run both the NES and his Atari 2600
cores at some point.
Note that right now, the core doesn't support any illegal instructions.
The old core supported a small number of them, but were mostly the no
operation ones. The goal is support all of the illegal instructions at
some point.
It's very possible the rewrite introduced some regressions, so thorough
testing of the NES core would be appreciated if anyone were up for it.
2017-06-11 01:51:53 +00:00
|
|
|
auto MOS6502::instructionSet(bool& flag) -> void {
|
|
|
|
L idle();
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionTransfer(uint8& source, uint8& target, bool flag) -> void {
|
|
|
|
L idle();
|
|
|
|
target = source;
|
|
|
|
if(!flag) return;
|
|
|
|
Z = target == 0;
|
|
|
|
N = target.bit(7);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionZeroPageModify(fp alu) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
auto data = load(zeroPage);
|
|
|
|
store(zeroPage, data);
|
|
|
|
L store(zeroPage, ALU(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionZeroPageModify(fp alu, uint8 index) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
load(zeroPage);
|
|
|
|
auto data = load(zeroPage + index);
|
|
|
|
store(zeroPage + index, data);
|
|
|
|
L store(zeroPage + index, ALU(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionZeroPageRead(fp alu, uint8& data) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
L data = ALU(load(zeroPage));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionZeroPageRead(fp alu, uint8& data, uint8 index) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
load(zeroPage);
|
|
|
|
L data = ALU(load(zeroPage + index));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionZeroPageWrite(uint8& data) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
L store(zeroPage, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MOS6502::instructionZeroPageWrite(uint8& data, uint8 index) -> void {
|
|
|
|
auto zeroPage = operand();
|
|
|
|
read(zeroPage);
|
|
|
|
L store(zeroPage + index, data);
|
|
|
|
}
|