mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-23 00:29:47 +00:00
Rearrange the 6809 code such that I can fire memory events.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
ab1d84703b
commit
15e1258f40
@ -71,9 +71,10 @@ namespace EightBit {
|
||||
const uint8_t SWI3vector = 0xf2;
|
||||
const uint8_t RESERVEDvector = 0xf0;
|
||||
|
||||
uint8_t& AM_direct() {
|
||||
//
|
||||
|
||||
void Address_direct() {
|
||||
BUS().ADDRESS() = register16_t(fetchByte(), DP());
|
||||
return BUS().reference();
|
||||
}
|
||||
|
||||
register16_t& RR(int which) {
|
||||
@ -93,7 +94,7 @@ namespace EightBit {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t& AM_indexed() {
|
||||
void Address_indexed() {
|
||||
const auto type = fetchByte();
|
||||
auto& rr = RR(type & (Bit6 | Bit5));
|
||||
switch (type & Bit7) {
|
||||
@ -167,16 +168,33 @@ namespace EightBit {
|
||||
default:
|
||||
UNREACHABLE;
|
||||
}
|
||||
return BUS().reference();
|
||||
}
|
||||
|
||||
uint8_t& AM_extended() {
|
||||
void Address_extended() {
|
||||
BUS().ADDRESS() = fetchWord();
|
||||
return BUS().reference();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
uint8_t AM_direct() {
|
||||
Address_direct();
|
||||
return BUS().read();
|
||||
}
|
||||
|
||||
uint8_t AM_indexed() {
|
||||
Address_indexed();
|
||||
return BUS().read();
|
||||
}
|
||||
|
||||
uint8_t AM_extended() {
|
||||
AM_extended();
|
||||
return BUS().read();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
void abx();
|
||||
void neg(uint8_t& operand);
|
||||
uint8_t neg(uint8_t operand);
|
||||
|
||||
register16_t m_d;
|
||||
register16_t m_x;
|
||||
|
@ -34,11 +34,11 @@ int EightBit::mc6809::execute(uint8_t cell) {
|
||||
case 0x3a: addCycles(3); abx(); break; // ABX (inherent)
|
||||
|
||||
// NEG
|
||||
case 0x00: addCycles(6); neg(AM_direct()); break; // NEG (direct)
|
||||
case 0x40: addCycles(2); neg(A()); break; // NEG (NEGA, inherent)
|
||||
case 0x50: addCycles(2); neg(B()); break; // NEG (NEGB, inherent)
|
||||
case 0x60: addCycles(6); neg(AM_indexed()); break; // NEG (indexed)
|
||||
case 0x70: addCycles(7); neg(AM_extended()); break; // NEG (extended)
|
||||
case 0x00: addCycles(6); BUS().write(neg(AM_direct())); break; // NEG (direct)
|
||||
case 0x40: addCycles(2); A() = neg(A()); break; // NEG (NEGA, inherent)
|
||||
case 0x50: addCycles(2); B() = neg(B()); break; // NEG (NEGB, inherent)
|
||||
case 0x60: addCycles(6); BUS().write(neg(AM_indexed())); break; // NEG (indexed)
|
||||
case 0x70: addCycles(7); BUS().write(neg(AM_extended())); break; // NEG (extended)
|
||||
|
||||
default:
|
||||
ASSUME(false);
|
||||
@ -54,11 +54,12 @@ void EightBit::mc6809::abx() {
|
||||
X() += B();
|
||||
}
|
||||
|
||||
void EightBit::mc6809::neg(uint8_t& operand) {
|
||||
uint8_t EightBit::mc6809::neg(uint8_t operand) {
|
||||
setFlag(CC(), VF, operand == Bit7);
|
||||
const register16_t result = 0 - operand;
|
||||
operand = result.low;
|
||||
setFlag(CC(), NF, operand & Bit7);
|
||||
setFlag(CC(), ZF, operand == 0);
|
||||
setFlag(CC(), CF, result.word & Bit8);
|
||||
return operand;
|
||||
}
|
Loading…
Reference in New Issue
Block a user