Add RTI/RTS instructions to the 6809 processor

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-08-22 10:21:22 +01:00
parent 07248972bf
commit 10684a02f4
2 changed files with 26 additions and 0 deletions

View File

@ -252,6 +252,8 @@ namespace EightBit {
void pulu(uint8_t data); void pulu(uint8_t data);
uint8_t rol(uint8_t operand); uint8_t rol(uint8_t operand);
uint8_t ror(uint8_t operand); uint8_t ror(uint8_t operand);
void rti();
void rts();
register16_t m_d; register16_t m_d;
register16_t m_x; register16_t m_x;

View File

@ -294,6 +294,12 @@ int EightBit::mc6809::executeUnprefixed(uint8_t opcode) {
case 0x66: addCycles(6); BUS().write(ror(AM_indexed_byte())); break; // ROR (indexed) case 0x66: addCycles(6); BUS().write(ror(AM_indexed_byte())); break; // ROR (indexed)
case 0x76: addCycles(7); BUS().write(ror(AM_extended_byte())); break; // ROR (extended) case 0x76: addCycles(7); BUS().write(ror(AM_extended_byte())); break; // ROR (extended)
// RTI
case 0x38: addCycles(6); rti(); break; // RTI (RTI inherent)
// RTS
case 0x39: addCycles(5); rts(); break; // RTS (RTS inherent)
default: default:
UNREACHABLE; UNREACHABLE;
} }
@ -890,3 +896,21 @@ uint8_t EightBit::mc6809::ror(uint8_t operand) {
adjustNZ(operand); adjustNZ(operand);
return operand; return operand;
} }
void EightBit::mc6809::rti() {
CC() = popS();
if (CC() & EF) {
addCycles(9); // One cycle per byte
A() = popS();
B() = popS();
DP() = popS();
X() = popWordS();
Y() = popWordS();
U() = popWordS();
}
ret();
}
void EightBit::mc6809::rts() {
ret();
}