micro-opt

This commit is contained in:
folkert van heusden 2022-04-13 20:53:54 +02:00
parent 54b9ac8eae
commit a90547c3d1
2 changed files with 11 additions and 13 deletions

22
cpu.cpp
View file

@ -146,19 +146,19 @@ void cpu::put_result(const uint16_t a, const uint8_t dst_mode, const uint8_t dst
b->write(a, word_mode, value, false); b->write(a, word_mode, value, false);
} }
void cpu::addRegister(const int nr, const bool prev_mode, const uint16_t value) uint16_t cpu::addRegister(const int nr, const bool prev_mode, const uint16_t value)
{ {
if (nr < 6) if (nr < 6)
regs0_5[getBitPSW(11)][nr] += value; return regs0_5[getBitPSW(11)][nr] += value;
else if (nr == 6) {
if (nr == 6) {
if (prev_mode) if (prev_mode)
sp[(getPSW() >> 12) & 3] += value; return sp[(getPSW() >> 12) & 3] += value;
else
sp[getPSW() >> 14] += value; return sp[getPSW() >> 14] += value;
}
else {
pc += value;
} }
return pc += value;
} }
bool cpu::getBitPSW(const int bit) const bool cpu::getBitPSW(const int bit) const
@ -1324,9 +1324,7 @@ void cpu::pushStack(const uint16_t v)
exit(1); exit(1);
} }
addRegister(6, false, -2); uint16_t a = addRegister(6, false, -2);
uint16_t a = getRegister(6, false);
b -> writeWord(a, v); b -> writeWord(a, v);
} }

2
cpu.h
View file

@ -38,7 +38,7 @@ private:
uint16_t getRegister(const int nr, const bool MF_MT) const; uint16_t getRegister(const int nr, const bool MF_MT) const;
void setRegister(const int nr, const bool MF_MT, const uint16_t value); void setRegister(const int nr, const bool MF_MT, const uint16_t value);
void addRegister(const int nr, const bool MF_MT, const uint16_t value); uint16_t addRegister(const int nr, const bool MF_MT, const uint16_t value);
uint16_t getGAMAddress(const uint8_t mode, const int reg, const bool word_mode, const bool MF_MT); uint16_t getGAMAddress(const uint8_t mode, const int reg, const bool word_mode, const bool MF_MT);
uint16_t getGAM(const uint8_t mode, const uint8_t reg, const bool word_mode, const bool MF_MT); uint16_t getGAM(const uint8_t mode, const uint8_t reg, const bool word_mode, const bool MF_MT);