[Avida-cvs] [Avida2-svn] r287 - in trunk/source: cpu viewers

ofria@myxo.css.msu.edu ofria at myxo.css.msu.edu
Tue Aug 16 22:51:50 PDT 2005


Author: ofria
Date: 2005-08-17 01:51:50 -0400 (Wed, 17 Aug 2005)
New Revision: 287

Modified:
   trunk/source/cpu/hardware_cpu.cc
   trunk/source/cpu/hardware_cpu.hh
   trunk/source/viewers/zoom_screen.cc
Log:
Minor fix to zoom mode of text viewer.

Added a command "if-label2" that, when the if fails, will skip both the
subsequent command and any nops that follow it.


Modified: trunk/source/cpu/hardware_cpu.cc
===================================================================
--- trunk/source/cpu/hardware_cpu.cc	2005-08-15 19:23:29 UTC (rev 286)
+++ trunk/source/cpu/hardware_cpu.cc	2005-08-17 05:51:50 UTC (rev 287)
@@ -246,6 +246,8 @@
 		  "Copy the position of the ?IP? head into CX"),
     cInstEntryCPU("if-label",  &cHardwareCPU::Inst_IfLabel, true,
 		  "Execute next if we copied complement of attached label"),
+    cInstEntryCPU("if-label2",  &cHardwareCPU::Inst_IfLabel2, true,
+		  "If copied label compl., exec next inst; else SKIP W/NOPS"),
     cInstEntryCPU("set-flow",  &cHardwareCPU::Inst_SetFlow, true,
 		  "Set flow-head to position in ?CX?"),
 
@@ -3207,6 +3209,19 @@
   return true;
 }
 
+// This is a variation on IfLabel that will skip the next command if the "if"
+// is false, but it will also skip all nops following that command.
+bool cHardwareCPU::Inst_IfLabel2()
+{
+  ReadLabel();
+  GetLabel().Rotate(1, NUM_NOPS);
+  if (GetLabel() != GetReadLabel()) {
+    IP().Advance();
+    if (inst_set->IsNop( IP().GetNextInst() ))  IP().Advance();
+  }
+  return true;
+}
+
 bool cHardwareCPU::Inst_HeadDivideMut(double mut_multiplier)
 {
   AdjustHeads();

Modified: trunk/source/cpu/hardware_cpu.hh
===================================================================
--- trunk/source/cpu/hardware_cpu.hh	2005-08-15 19:23:29 UTC (rev 286)
+++ trunk/source/cpu/hardware_cpu.hh	2005-08-17 05:51:50 UTC (rev 287)
@@ -412,6 +412,7 @@
   bool Inst_JumpHead();
   bool Inst_GetHead();
   bool Inst_IfLabel();
+  bool Inst_IfLabel2();
   bool Inst_HeadDivide();
   bool Inst_HeadRead();
   bool Inst_HeadWrite();

Modified: trunk/source/viewers/zoom_screen.cc
===================================================================
--- trunk/source/viewers/zoom_screen.cc	2005-08-15 19:23:29 UTC (rev 286)
+++ trunk/source/viewers/zoom_screen.cc	2005-08-17 05:51:50 UTC (rev 287)
@@ -435,6 +435,9 @@
 
 void cZoomScreen::Update()
 {
+  if (info.GetActiveCell() == NULL ||
+      info.GetActiveCell()->IsOccupied() == false) return;
+
   cHardwareBase & hardware = info.GetActiveCell()->GetOrganism()->GetHardware();
   if(mode == ZOOM_MODE_CPU) UpdateCPU(hardware);
   else if (mode == ZOOM_MODE_STATS) UpdateStats(hardware);




More information about the Avida-cvs mailing list