X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=3c_disasm%2Finstr%2Fbranch.cpp;h=f62569a5b97de3a3d8b40fe0230f21907ae8cd6f;hb=1968f329b10681b760faec9369aa893cd2af8d44;hp=90a56cbce8258d2a882f1ade81f48015784fdeb4;hpb=12d2a7c14a42e01b6caf2a097db32404a403d213;p=calu.git diff --git a/3c_disasm/instr/branch.cpp b/3c_disasm/instr/branch.cpp index 90a56cb..f62569a 100644 --- a/3c_disasm/instr/branch.cpp +++ b/3c_disasm/instr/branch.cpp @@ -1,3 +1,24 @@ +/* `Deep Thought', a softcore CPU implemented on a FPGA + + Copyright (C) 2010 Markus Hofstaetter + Copyright (C) 2010 Martin Perner + Copyright (C) 2010 Stefan Rebernig + Copyright (C) 2010 Manfred Schwarz + Copyright (C) 2010 Bernhard Urban + + 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 . */ + #include "../Iinstr.hpp" class Cbranch : public Iinstr { @@ -64,9 +85,11 @@ void Cbranch::evalInstr() 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; @@ -76,24 +99,25 @@ void Cbranch::evalInstr() 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: @@ -115,7 +139,7 @@ std::string Cbranch::toString() 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(); }