[Avida-SVN] r1157 - development/source/cpu
barrick at myxo.css.msu.edu
barrick at myxo.css.msu.edu
Wed Dec 27 22:14:21 PST 2006
Author: barrick
Date: 2006-12-28 01:14:20 -0500 (Thu, 28 Dec 2006)
New Revision: 1157
Modified:
development/source/cpu/cHardwareCPU.cc
Log:
Bug fix for goto/label instructions.
Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc 2006-12-28 01:33:27 UTC (rev 1156)
+++ development/source/cpu/cHardwareCPU.cc 2006-12-28 06:14:20 UTC (rev 1157)
@@ -1784,7 +1784,7 @@
bool match = true;
int size_matched = 0;
- while ( match && m_inst_set->IsNop(search_head.GetInst()) && (GetLabel().GetSize() > size_matched) )
+ while ( match && m_inst_set->IsNop(search_head.GetInst()) && (size_matched < GetLabel().GetSize()) )
{
if ( GetLabel()[size_matched] != m_inst_set->GetNopMod( search_head.GetInst()) ) match = false;
search_head++;
@@ -1842,16 +1842,19 @@
search_head++;
int size_matched = 0;
bool match = true;
- while ( match && m_inst_set->IsNop(search_head.GetInst()) && (GetLabel().GetSize() > size_matched) )
+ while ( size_matched < GetLabel().GetSize() )
{
- if ( GetLabel()[size_matched] != m_inst_set->GetNopMod( search_head.GetInst()) ) match = false;
+ if ( !m_inst_set->IsNop(search_head.GetInst()) ) break;
+ if ( GetLabel()[size_matched] != m_inst_set->GetNopMod( search_head.GetInst()) ) break;
+ if ( !m_inst_set->IsNop(search_head.GetInst()) ) break;
+
+ size_matched++;
search_head++;
- size_matched++;
}
// We found a matching 'label' instruction only if the next
- // instruction (at the search head now) is not a NOP
- if ( match && !m_inst_set->IsNop(search_head.GetInst()) )
+ // instruction (at the search head now) is also not a NOP
+ if ( (size_matched == GetLabel().GetSize()) && !m_inst_set->IsNop(search_head.GetInst()) )
{
IP().Set(label_pos);
m_advance_ip = false; // Don't automatically move the IP
More information about the Avida-cvs
mailing list