mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-02-02 23:30:49 +00:00
First stab at interrupt handling on the 6809 processor.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
1eb59279a8
commit
21e8360dc1
@ -122,6 +122,12 @@ namespace EightBit {
|
|||||||
void execute10(uint8_t opcode);
|
void execute10(uint8_t opcode);
|
||||||
void execute11(uint8_t opcode);
|
void execute11(uint8_t opcode);
|
||||||
|
|
||||||
|
// Interrupt handlers
|
||||||
|
|
||||||
|
void handleNMI();
|
||||||
|
void handleIRQ();
|
||||||
|
void handleFIRQ();
|
||||||
|
|
||||||
// Register selection for "indexed"
|
// Register selection for "indexed"
|
||||||
register16_t& RR(int which);
|
register16_t& RR(int which);
|
||||||
|
|
||||||
|
@ -13,19 +13,55 @@ int EightBit::mc6809::step() {
|
|||||||
if (LIKELY(powered())) {
|
if (LIKELY(powered())) {
|
||||||
m_prefix10 = m_prefix11 = false;
|
m_prefix10 = m_prefix11 = false;
|
||||||
ExecutingInstruction.fire(*this);
|
ExecutingInstruction.fire(*this);
|
||||||
return execute(fetchByte());
|
if (lowered(NMI()))
|
||||||
|
handleNMI();
|
||||||
|
else if (lowered(FIRQ()) && !(CC() & FF))
|
||||||
|
handleFIRQ();
|
||||||
|
else if (lowered(IRQ()) && !(CC() & IF))
|
||||||
|
handleIRQ();
|
||||||
|
else
|
||||||
|
execute(fetchByte());
|
||||||
ExecutedInstruction.fire(*this);
|
ExecutedInstruction.fire(*this);
|
||||||
}
|
}
|
||||||
return cycles();
|
return cycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Interrupt (etc.) handlers
|
||||||
|
|
||||||
void EightBit::mc6809::reset() {
|
void EightBit::mc6809::reset() {
|
||||||
Processor::reset();
|
Processor::reset();
|
||||||
DP() = 0; // Reestablish zero page
|
DP() = 0; // Reestablish zero page
|
||||||
CC() |= (IF & FF); // Disable interrupts
|
CC() |= (IF & FF); // Disable IRQ and FIRQ
|
||||||
jump(getWordPaged(0xff, RESETvector));
|
jump(getWordPaged(0xff, RESETvector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EightBit::mc6809::handleNMI() {
|
||||||
|
raise(NMI());
|
||||||
|
addCycles(21);
|
||||||
|
saveEntireRegisterState();
|
||||||
|
jump(getWordPaged(0xff, NMIvector));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EightBit::mc6809::handleIRQ() {
|
||||||
|
raise(IRQ());
|
||||||
|
addCycles(21);
|
||||||
|
saveEntireRegisterState();
|
||||||
|
CC() |= IF; // Disable IRQ
|
||||||
|
jump(getWordPaged(0xff, IRQvector));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EightBit::mc6809::handleFIRQ() {
|
||||||
|
addCycles(12);
|
||||||
|
raise(FIRQ());
|
||||||
|
CC() &= ~EF; // Clear the EF flag. i.e. this only saves PC and CC
|
||||||
|
pushWordS(PC());
|
||||||
|
pushS(CC());
|
||||||
|
CC() |= (IF & FF); // Disable IRQ and FIRQ
|
||||||
|
jump(getWordPaged(0xff, FIRQvector));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
int EightBit::mc6809::execute(uint8_t opcode) {
|
int EightBit::mc6809::execute(uint8_t opcode) {
|
||||||
const bool prefixed = m_prefix10 || m_prefix11;
|
const bool prefixed = m_prefix10 || m_prefix11;
|
||||||
if (LIKELY(!prefixed)) {
|
if (LIKELY(!prefixed)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user