mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-09-01 15:29:11 +00:00
Add an implementation of ADC for the 6809
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
15e1258f40
commit
a7835b943a
@ -176,6 +176,10 @@ namespace EightBit {
|
||||
|
||||
//
|
||||
|
||||
uint8_t AM_immediate() {
|
||||
return fetchByte();
|
||||
}
|
||||
|
||||
uint8_t AM_direct() {
|
||||
Address_direct();
|
||||
return BUS().read();
|
||||
@ -187,13 +191,15 @@ namespace EightBit {
|
||||
}
|
||||
|
||||
uint8_t AM_extended() {
|
||||
AM_extended();
|
||||
Address_extended();
|
||||
return BUS().read();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
void abx();
|
||||
uint8_t adc(uint8_t operand, uint8_t data);
|
||||
uint8_t add(uint8_t operand, uint8_t data, int carry = 0);
|
||||
uint8_t neg(uint8_t operand);
|
||||
|
||||
register16_t m_d;
|
||||
|
@ -33,6 +33,16 @@ int EightBit::mc6809::execute(uint8_t cell) {
|
||||
// ABX
|
||||
case 0x3a: addCycles(3); abx(); break; // ABX (inherent)
|
||||
|
||||
// ADC
|
||||
case 0x89: addCycles(2); A() = adc(A(), AM_immediate()); break; // ADC (ADCA, immediate)
|
||||
case 0x99: addCycles(4); A() = adc(A(), AM_direct()); break; // ADC (ADCA, direct)
|
||||
case 0xA9: addCycles(4); A() = adc(A(), AM_indexed()); break; // ADC (ADCA, indexed)
|
||||
case 0xB9: addCycles(4); A() = adc(A(), AM_extended()); break; // ADC (ADCA, extended)
|
||||
case 0xC9: addCycles(2); B() = adc(B(), AM_immediate()); break; // ADC (ADCB, immediate)
|
||||
case 0xD9: addCycles(4); B() = adc(B(), AM_direct()); break; // ADC (ADCB, direct)
|
||||
case 0xE9: addCycles(4); B() = adc(B(), AM_indexed()); break; // ADC (ADCB, indexed)
|
||||
case 0xF9: addCycles(4); B() = adc(B(), AM_extended()); break; // ADC (ADCB, extended)
|
||||
|
||||
// NEG
|
||||
case 0x00: addCycles(6); BUS().write(neg(AM_direct())); break; // NEG (direct)
|
||||
case 0x40: addCycles(2); A() = neg(A()); break; // NEG (NEGA, inherent)
|
||||
@ -62,4 +72,16 @@ uint8_t EightBit::mc6809::neg(uint8_t operand) {
|
||||
setFlag(CC(), ZF, operand == 0);
|
||||
setFlag(CC(), CF, result.word & Bit8);
|
||||
return operand;
|
||||
}
|
||||
|
||||
uint8_t EightBit::mc6809::adc(uint8_t operand, uint8_t data) {
|
||||
return add(operand, data, CC() & CF);
|
||||
}
|
||||
|
||||
uint8_t EightBit::mc6809::add(uint8_t operand, uint8_t data, int carry) {
|
||||
const register16_t result = operand + data + carry;
|
||||
setFlag(CC(), NF, result.low & Bit7);
|
||||
setFlag(CC(), ZF, result.low == 0);
|
||||
setFlag(CC(), CF, result.word & Bit8);
|
||||
return result.low;
|
||||
}
|
Loading…
Reference in New Issue
Block a user