+/* `Deep Thought', a softcore CPU implemented on a FPGA
+
+ Copyright (C) 2010 Markus Hofstaetter <markus.manrow@gmx.at>
+ Copyright (C) 2010 Martin Perner <e0725782@student.tuwien.ac.at>
+ Copyright (C) 2010 Stefan Rebernig <stefan.rebernig@gmail.com>
+ Copyright (C) 2010 Manfred Schwarz <e0725898@student.tuwien.ac.at>
+ Copyright (C) 2010 Bernhard Urban <lewurm@gmail.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
#include "../Iinstr.hpp"
class Cbranch : public Iinstr {
break;
case 2:
this->name = "ret";
+ this->clockcount = 3;
break;
case 3:
this->name = "reti";
+ this->clockcount = 3;
break;
default:
cerr << "What have you done? 2 bits that have more than 4 values?!" << endl;
dynamic_bitset<> immb = argbits;
immb.resize(16);
- this->m_imm = this->generate16ImmSign(immb.to_ulong());
+ this->m_imm = this->generate16ImmSign(immb.to_ulong())*4;
}
void Cbranch::execInstr()
{
- cout << "should exec " << this->toString() << endl;
+ //cout << "should exec " << this->toString() << endl;
CDat pc = this->m_cpu->getCurPC();
switch(this->m_typ) {
case 1:
{
CDat sp = this->m_cpu->getStack();
- this->m_cpu->setRAM(sp, pc);
sp -= 4;
+ this->m_cpu->setRAM(sp, this->m_cpu->getNextPC());
this->m_cpu->setStack(sp);
}
+ /* fall through */
case 0:
- this->m_cpu->setNextPC(pc+this->m_imm);
+ this->m_cpu->setNextPC(pc+(this->m_imm));
break;
case 2:
case 3:
op << this->getConditionFlag() << (m_taken ? '+' : '-');
if(m_typ < 2) {
- op << " 0x" << std::hex << m_imm << "(" << std::dec << m_imm << ")";
+ op << " 0x" << std::hex << m_imm << "(" << std::dec << m_imm << ", " << (int) m_imm << ")";
}
return op.str();
}