Sort a bunch of missing argument const specifications.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-09-21 00:16:00 +01:00
parent 9e91d2adad
commit 7adefd380a
11 changed files with 73 additions and 69 deletions

View File

@ -89,20 +89,24 @@ void EightBit::mc6809::handleFIRQ() {
//
int EightBit::mc6809::execute(uint8_t opcode) {
int EightBit::mc6809::execute(const uint8_t opcode) {
lower(BA());
lower(BS());
if (UNLIKELY(m_prefix10))
execute10(opcode);
else if (UNLIKELY(m_prefix11))
execute11(opcode);
else
const bool prefixed = m_prefix10 || m_prefix11;
const bool unprefixed = !prefixed;
if (unprefixed) {
executeUnprefixed(opcode);
} else {
if (m_prefix10)
execute10(opcode);
else
execute11(opcode);
}
assert(cycles() > 0);
return cycles();
}
void EightBit::mc6809::executeUnprefixed(uint8_t opcode) {
void EightBit::mc6809::executeUnprefixed(const uint8_t opcode) {
assert(!(m_prefix10 || m_prefix11));
assert(cycles() == 0);
@ -472,7 +476,7 @@ void EightBit::mc6809::executeUnprefixed(uint8_t opcode) {
}
}
void EightBit::mc6809::execute10(uint8_t opcode) {
void EightBit::mc6809::execute10(const uint8_t opcode) {
assert(m_prefix10 && !m_prefix11);
assert(cycles() == 0);
@ -543,7 +547,7 @@ void EightBit::mc6809::execute10(uint8_t opcode) {
}
}
void EightBit::mc6809::execute11(uint8_t opcode) {
void EightBit::mc6809::execute11(const uint8_t opcode) {
assert(!m_prefix10 && m_prefix11);
assert(cycles() == 0);
@ -574,7 +578,7 @@ void EightBit::mc6809::execute11(uint8_t opcode) {
//
void EightBit::mc6809::push(register16_t& stack, uint8_t value) {
void EightBit::mc6809::push(register16_t& stack, const uint8_t value) {
BUS().write(stack--, value);
}
@ -584,7 +588,7 @@ uint8_t EightBit::mc6809::pop(register16_t& stack) {
//
EightBit::register16_t& EightBit::mc6809::RR(int which) {
EightBit::register16_t& EightBit::mc6809::RR(const int which) {
ASSUME(which >= 0);
ASSUME(which <= 3);
switch (which) {
@ -748,23 +752,23 @@ void EightBit::mc6809::saveEntireRegisterState() {
//
uint8_t EightBit::mc6809::adc(uint8_t operand, uint8_t data) {
uint8_t EightBit::mc6809::adc(const uint8_t operand, const uint8_t data) {
return add(operand, data, carry());
}
uint8_t EightBit::mc6809::add(uint8_t operand, uint8_t data, int carry) {
uint8_t EightBit::mc6809::add(const uint8_t operand, const uint8_t data, const int carry) {
const register16_t addition = operand + data + carry;
adjustAddition(operand, data, addition);
return addition.low;
}
EightBit::register16_t EightBit::mc6809::add(register16_t operand, register16_t data) {
EightBit::register16_t EightBit::mc6809::add(const register16_t operand, const register16_t data) {
const uint32_t addition = operand.word + data.word;
adjustAddition(operand, data, addition);
return addition & Mask16;
}
uint8_t EightBit::mc6809::andr(uint8_t operand, uint8_t data) {
uint8_t EightBit::mc6809::andr(uint8_t operand, const uint8_t data) {
clearFlag(CC(), VF);
adjustNZ(operand &= data);
return operand;
@ -794,11 +798,11 @@ void EightBit::mc6809::cmp(const uint8_t operand, const uint8_t data) {
sub(operand, data);
}
void EightBit::mc6809::cmp(register16_t operand, register16_t data) {
void EightBit::mc6809::cmp(const register16_t operand, const register16_t data) {
sub(operand, data);
}
uint8_t EightBit::mc6809::com(uint8_t operand) {
uint8_t EightBit::mc6809::com(const uint8_t operand) {
const uint8_t result = ~operand;
adjustNZ(result);
clearFlag(CC(), VF);
@ -806,7 +810,7 @@ uint8_t EightBit::mc6809::com(uint8_t operand) {
return result;
}
void EightBit::mc6809::cwai(uint8_t data) {
void EightBit::mc6809::cwai(const uint8_t data) {
CC() &= data;
saveEntireRegisterState();
halt();
@ -830,20 +834,20 @@ uint8_t EightBit::mc6809::da(uint8_t operand) {
return operand;
}
uint8_t EightBit::mc6809::dec(uint8_t operand) {
uint8_t EightBit::mc6809::dec(const uint8_t operand) {
const uint8_t result = operand - 1;
adjustNZ(result);
adjustOverflow(operand, 1, result);
return result;
}
uint8_t EightBit::mc6809::eor(uint8_t operand, uint8_t data) {
uint8_t EightBit::mc6809::eor(uint8_t operand, const uint8_t data) {
clearFlag(CC(), VF);
adjustNZ(operand ^= data);
return operand;
}
uint8_t& EightBit::mc6809::referenceTransfer8(int specifier) {
uint8_t& EightBit::mc6809::referenceTransfer8(const int specifier) {
switch (specifier) {
case 0b1000:
return A();
@ -858,7 +862,7 @@ uint8_t& EightBit::mc6809::referenceTransfer8(int specifier) {
}
}
EightBit::register16_t& EightBit::mc6809::referenceTransfer16(int specifier) {
EightBit::register16_t& EightBit::mc6809::referenceTransfer16(const int specifier) {
switch (specifier) {
case 0b0000:
return D();
@ -877,7 +881,7 @@ EightBit::register16_t& EightBit::mc6809::referenceTransfer16(int specifier) {
}
}
void EightBit::mc6809::exg(uint8_t data) {
void EightBit::mc6809::exg(const uint8_t data) {
const auto reg1 = highNibble(data);
const auto reg2 = lowNibble(data);
@ -898,17 +902,17 @@ uint8_t EightBit::mc6809::inc(uint8_t operand) {
return result;
}
void EightBit::mc6809::jsr(register16_t address) {
void EightBit::mc6809::jsr(const register16_t address) {
call(address);
}
uint8_t EightBit::mc6809::ld(uint8_t data) {
uint8_t EightBit::mc6809::ld(const uint8_t data) {
clearFlag(CC(), VF);
adjustNZ(data);
return data;
}
EightBit::register16_t EightBit::mc6809::ld(register16_t data) {
EightBit::register16_t EightBit::mc6809::ld(const register16_t data) {
clearFlag(CC(), VF);
adjustNZ(data);
return data;
@ -920,7 +924,7 @@ uint8_t EightBit::mc6809::lsr(uint8_t operand) {
return operand;
}
EightBit::register16_t EightBit::mc6809::mul(uint8_t first, uint8_t second) {
EightBit::register16_t EightBit::mc6809::mul(const uint8_t first, const uint8_t second) {
const register16_t result = first * second;
adjustZero(result);
setFlag(CC(), CF, result.low & Bit7);
@ -936,13 +940,13 @@ uint8_t EightBit::mc6809::neg(uint8_t operand) {
return operand;
}
uint8_t EightBit::mc6809::orr(uint8_t operand, uint8_t data) {
uint8_t EightBit::mc6809::orr(uint8_t operand, const uint8_t data) {
clearFlag(CC(), VF);
adjustNZ(operand |= data);
return operand;
}
void EightBit::mc6809::pshs(uint8_t data) {
void EightBit::mc6809::pshs(const uint8_t data) {
if (data & Bit7) {
addCycles(2);
pushWordS(PC());
@ -977,7 +981,7 @@ void EightBit::mc6809::pshs(uint8_t data) {
}
}
void EightBit::mc6809::pshu(uint8_t data) {
void EightBit::mc6809::pshu(const uint8_t data) {
if (data & Bit7) {
addCycles(2);
pushWordU(PC());
@ -1012,7 +1016,7 @@ void EightBit::mc6809::pshu(uint8_t data) {
}
}
void EightBit::mc6809::puls(uint8_t data) {
void EightBit::mc6809::puls(const uint8_t data) {
if (data & Bit0) {
addCycle();
CC() = popS();
@ -1047,7 +1051,7 @@ void EightBit::mc6809::puls(uint8_t data) {
}
}
void EightBit::mc6809::pulu(uint8_t data) {
void EightBit::mc6809::pulu(const uint8_t data) {
if (data & Bit0) {
addCycle();
CC() = popU();
@ -1135,12 +1139,12 @@ void EightBit::mc6809::swi3() {
jump(getWordPaged(0xff, SWI3vector));
}
uint8_t EightBit::mc6809::sex(uint8_t from) {
uint8_t EightBit::mc6809::sex(const uint8_t from) {
adjustNZ(from);
return from & Bit7 ? Mask8 : 0;
}
void EightBit::mc6809::tfr(uint8_t data) {
void EightBit::mc6809::tfr(const uint8_t data) {
const auto reg1 = highNibble(data);
const auto reg2 = lowNibble(data);
@ -1154,34 +1158,34 @@ void EightBit::mc6809::tfr(uint8_t data) {
referenceTransfer16(reg2) = referenceTransfer16(reg1);
}
uint8_t EightBit::mc6809::st(uint8_t data) {
uint8_t EightBit::mc6809::st(const uint8_t data) {
clearFlag(CC(), VF);
adjustNZ(data);
return data;
}
EightBit::register16_t EightBit::mc6809::st(register16_t data) {
EightBit::register16_t EightBit::mc6809::st(const register16_t data) {
clearFlag(CC(), VF);
adjustNZ(data);
return data;
}
uint8_t EightBit::mc6809::sbc(uint8_t operand, uint8_t data) {
uint8_t EightBit::mc6809::sbc(const uint8_t operand, const uint8_t data) {
return sub(operand, data, carry());
}
uint8_t EightBit::mc6809::sub(uint8_t operand, uint8_t data, int carry) {
uint8_t EightBit::mc6809::sub(const uint8_t operand, const uint8_t data, const int carry) {
const register16_t subtraction = operand - data - carry;
adjustSubtraction(operand, data, subtraction);
return subtraction.low;
}
EightBit::register16_t EightBit::mc6809::sub(register16_t operand, register16_t data) {
EightBit::register16_t EightBit::mc6809::sub(const register16_t operand, const register16_t data) {
const uint32_t subtraction = operand.word - data.word;
adjustSubtraction(operand, data, subtraction);
return subtraction & Mask16;
}
void EightBit::mc6809::tst(uint8_t data) {
void EightBit::mc6809::tst(const uint8_t data) {
cmp(data, 0);
}

View File

@ -474,7 +474,7 @@ void EightBit::Z80::xhtl() {
HL2().high = MEMPTR().high;
}
void EightBit::Z80::blockCompare(register16_t source, register16_t& counter) {
void EightBit::Z80::blockCompare(const register16_t source, register16_t& counter) {
const auto value = BUS().read(source);
uint8_t result = A() - value;
@ -539,7 +539,7 @@ bool EightBit::Z80::lddr() {
return !!(F() & PF); // See LDD
}
void EightBit::Z80::blockIn(register16_t& source, register16_t destination) {
void EightBit::Z80::blockIn(register16_t& source, const register16_t destination) {
MEMPTR() = BUS().ADDRESS() = source;
const auto value = readPort();
BUS().write(destination, value);

View File

@ -28,11 +28,11 @@ namespace EightBit {
uint8_t& DATA() { return m_data; }
uint8_t peek() { return reference(); }
uint8_t peek(uint16_t address) { return reference(address); }
uint8_t peek(register16_t address) { return reference(address.word); }
void poke(uint8_t value) { reference() = value; }
void poke(uint16_t address, uint8_t value) { reference(address) = value; }
void poke(register16_t address, uint8_t value) { reference(address.word) = value; }
uint8_t peek(const uint16_t address) { return reference(address); }
uint8_t peek(const register16_t address) { return reference(address.word); }
void poke(const uint8_t value) { reference() = value; }
void poke(const uint16_t address, const uint8_t value) { reference(address) = value; }
void poke(const register16_t address, const uint8_t value) { reference(address.word) = value; }
uint8_t read();
template<class T> uint8_t read(const T address) {
@ -50,7 +50,7 @@ namespace EightBit {
protected:
virtual MemoryMapping mapping(uint16_t address) = 0;
uint8_t& reference(uint16_t address);
uint8_t& reference(register16_t address) { return reference(address.word); }
uint8_t& reference(const register16_t address) { return reference(address.word); }
uint8_t& reference() { return reference(ADDRESS()); }
static std::map<uint16_t, std::vector<uint8_t>> parseHexFile(std::string path);

View File

@ -15,7 +15,7 @@ namespace EightBit {
void assume(int expression);
}
inline int EightBit::countBits(uint8_t value) {
inline int EightBit::countBits(const uint8_t value) {
#ifdef _MSC_VER
return __popcnt(value);
#else
@ -35,11 +35,11 @@ inline int EightBit::countBits(uint8_t value) {
#endif
}
inline bool EightBit::oddParity(uint8_t value) {
inline bool EightBit::oddParity(const uint8_t value) {
return countBits(value) % 2;
}
inline int EightBit::findFirstSet(int value) {
inline int EightBit::findFirstSet(const int value) {
#ifdef _MSC_VER
unsigned long index;
if (_BitScanForward(&index, value))
@ -52,7 +52,7 @@ inline int EightBit::findFirstSet(int value) {
#endif
}
inline void EightBit::assume(int expression) {
inline void EightBit::assume(const int expression) {
#ifdef _MSC_VER
__assume(expression);
#elif defined(__GNUG__)

View File

@ -117,11 +117,11 @@ namespace EightBit {
virtual void handleINT();
virtual void handleIRQ();
uint8_t getBytePaged(uint8_t page, uint8_t offset) {
uint8_t getBytePaged(const uint8_t page, const uint8_t offset) {
return BUS().read(register16_t(offset, page));
}
void setBytePaged(uint8_t page, uint8_t offset, uint8_t value) {
void setBytePaged(const uint8_t page, const uint8_t offset, const uint8_t value) {
BUS().write(register16_t(offset, page), value);
}
@ -143,12 +143,12 @@ namespace EightBit {
virtual void pushWord(const register16_t value) = 0;
virtual register16_t popWord() = 0;
register16_t getWord(register16_t address) {
register16_t getWord(const register16_t address) {
BUS().ADDRESS() = address;
return getWord();
}
void setWord(register16_t address, register16_t value) {
void setWord(const register16_t address, const register16_t value) {
BUS().ADDRESS() = address;
return setWord(value);
}

View File

@ -14,7 +14,7 @@ namespace EightBit {
return BYTES()[address];
}
void poke(uint16_t address, uint8_t value) {
void poke(const uint16_t address, const uint8_t value) {
Memory::poke(address, value);
}
};

View File

@ -33,8 +33,8 @@ namespace EightBit {
};
uint16_t word;
register16_t() noexcept : word(0) {}
register16_t(uint16_t w) noexcept : word(w) {}
register16_t(uint8_t l, uint8_t h) noexcept : low(l), high(h) {}
register16_t(const uint16_t w) noexcept : word(w) {}
register16_t(const uint8_t l, const uint8_t h) noexcept : low(l), high(h) {}
register16_t& operator++() noexcept {
++word;
@ -69,11 +69,11 @@ namespace EightBit {
}
};
inline bool operator==(register16_t lhs, const register16_t rhs) noexcept {
inline bool operator==(const register16_t lhs, const register16_t rhs) noexcept {
return lhs.word == rhs.word;
}
inline bool operator!=(register16_t lhs, const register16_t rhs) noexcept {
inline bool operator!=(const register16_t lhs, const register16_t rhs) noexcept {
return !(lhs == rhs);
}
@ -87,7 +87,7 @@ namespace EightBit {
return lhs;
}
inline std::ostream& operator<<(std::ostream& output, register16_t value) {
inline std::ostream& operator<<(std::ostream& output, const register16_t value) {
return output << std::hex << std::setw(4) << std::setfill('0') << value.word;
}
}

View File

@ -17,14 +17,14 @@ void EightBit::BigEndianProcessor::setWord(const register16_t value) {
BUS().write(value.low);
}
EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged(uint8_t page, uint8_t offset) {
EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) {
const auto high = getBytePaged(page, offset);
++BUS().ADDRESS().low;
const auto low = BUS().read();
return register16_t(low, high);
}
void EightBit::BigEndianProcessor::setWordPaged(uint8_t page, uint8_t offset, register16_t value) {
void EightBit::BigEndianProcessor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) {
setBytePaged(page, offset, value.high);
++BUS().ADDRESS().low;
BUS().read(value.low);

View File

@ -88,7 +88,7 @@ std::map<uint16_t, std::vector<uint8_t>> EightBit::Bus::parseHexFile(const std::
return returned;
}
uint8_t& EightBit::Bus::reference(uint16_t address) {
uint8_t& EightBit::Bus::reference(const uint16_t address) {
const auto mapped = mapping(address);
const uint16_t offset = address - mapped.begin;
if (mapped.access == MemoryMapping::ReadOnly)

View File

@ -17,14 +17,14 @@ void EightBit::LittleEndianProcessor::setWord(const register16_t value) {
BUS().write(value.high);
}
EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged(uint8_t page, uint8_t offset) {
EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) {
const auto low = getBytePaged(page, offset);
++BUS().ADDRESS().low;
const auto high = BUS().read();
return register16_t(low, high);
}
void EightBit::LittleEndianProcessor::setWordPaged(uint8_t page, uint8_t offset, register16_t value) {
void EightBit::LittleEndianProcessor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) {
setBytePaged(page, offset, value.low);
++BUS().ADDRESS().low;
BUS().read(value.high);

View File

@ -27,13 +27,13 @@ void EightBit::Processor::handleIRQ() {
int EightBit::Processor::run(const int limit) {
int current = 0;
while (LIKELY(powered()) && current < limit)
while (LIKELY(powered() && (current < limit)))
current += step();
return current;
}
// http://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend
int8_t EightBit::Processor::signExtend(int b, uint8_t x) {
int8_t EightBit::Processor::signExtend(const int b, uint8_t x) {
const uint8_t m = 1 << (b - 1); // mask can be pre-computed if b is fixed
x = x & ((1 << b) - 1); // (Skip this if bits in x above position b are already zero.)
const auto result = (x ^ m) - m;