From 0dc13f5405f41d70654f96c9215d2b68123d227c Mon Sep 17 00:00:00 2001 From: Martin Perner Date: Fri, 17 Dec 2010 14:49:51 +0100 Subject: [PATCH] [sim] bug + display fixed bug in branch, jumps are not counting the instr. amount, not the address difference displaying of branch and add changed/fixed --- 3c_disasm/instr/add.cpp | 2 +- 3c_disasm/instr/branch.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/3c_disasm/instr/add.cpp b/3c_disasm/instr/add.cpp index b5cd4f9..a6967e4 100644 --- a/3c_disasm/instr/add.cpp +++ b/3c_disasm/instr/add.cpp @@ -76,6 +76,6 @@ std::string Cadd::toString() if(m_d) op << 'D'; if(m_c) op << 'C'; - op << " r" << m_rd << ", r" << m_ra << ", r" << m_rb; + op << this->getConditionFlag() << " r" << m_rd << ", r" << m_ra << ", r" << m_rb; return op.str(); } diff --git a/3c_disasm/instr/branch.cpp b/3c_disasm/instr/branch.cpp index b8781da..b797762 100644 --- a/3c_disasm/instr/branch.cpp +++ b/3c_disasm/instr/branch.cpp @@ -94,8 +94,9 @@ void Cbranch::execInstr() 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*4)); break; case 2: case 3: @@ -117,7 +118,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(); } -- 2.25.1