[Avida-SVN] r2116 - branches/dkdev/source/cpu

dknoester at myxo.css.msu.edu dknoester at myxo.css.msu.edu
Thu Sep 27 19:42:11 PDT 2007


Author: dknoester
Date: 2007-09-27 22:42:11 -0400 (Thu, 27 Sep 2007)
New Revision: 2116

Modified:
   branches/dkdev/source/cpu/cHardwareCPU.cc
   branches/dkdev/source/cpu/cHardwareCPU.h
Log:
Added decomposed instructions for cell one, two, and self, and an instruction that reports whether or not the values in the registers are sorted in either ascending or descending order.

Modified: branches/dkdev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/dkdev/source/cpu/cHardwareCPU.cc	2007-09-27 20:48:16 UTC (rev 2115)
+++ branches/dkdev/source/cpu/cHardwareCPU.cc	2007-09-28 02:42:11 UTC (rev 2116)
@@ -378,7 +378,16 @@
     cInstEntryCPU("sat-send", &cHardwareCPU::Inst_SatelliteSend),
     
     // Two-cells instructions.
-    cInstEntryCPU("region", &cHardwareCPU::Inst_Region)
+    cInstEntryCPU("region", &cHardwareCPU::Inst_Region),
+    cInstEntryCPU("cell-one.x", &cHardwareCPU::Inst_CellOneX),
+    cInstEntryCPU("cell-one.y", &cHardwareCPU::Inst_CellOneY),
+    cInstEntryCPU("cell-two.x", &cHardwareCPU::Inst_CellTwoX),
+    cInstEntryCPU("cell-two.y", &cHardwareCPU::Inst_CellTwoY),
+    cInstEntryCPU("self.x", &cHardwareCPU::Inst_SelfX),
+    cInstEntryCPU("self.y", &cHardwareCPU::Inst_SelfY),
+    cInstEntryCPU("sorted?", &cHardwareCPU::Inst_Sorted)
+//    cInstEntryCPU("", &cHardwareCPU::Inst_),
+//    cInstEntryCPU("", &cHardwareCPU::Inst_),
   };
   
   const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
@@ -3808,3 +3817,84 @@
   organism->SetRegion(GetRegister(FindModifiedRegister(REG_BX)));
   return true;
 }
+
+//! Returns the x (er, first) coordinate of the first randomly selected cell.
+bool cHardwareCPU::Inst_CellOneX(cAvidaContext& ctx) {
+  if(organism->GetCellID()==-1) return false;
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+  cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+  const int x = FindModifiedRegister(REG_BX);
+  GetRegister(x) = deme.GetCellPosition(deme.GetCellsToLink().first).first;
+  return true;
+}
+
+
+//! Returns the y coordinate of the first randomly selected cell.
+bool cHardwareCPU::Inst_CellOneY(cAvidaContext& ctx) {
+  if(organism->GetCellID()==-1) return false;
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+  cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+  const int x = FindModifiedRegister(REG_BX);
+  GetRegister(x) = deme.GetCellPosition(deme.GetCellsToLink().first).second;
+  return true;
+}
+
+
+//! Returns the x coordinate of the second randomly selected cell.
+bool cHardwareCPU::Inst_CellTwoX(cAvidaContext& ctx) {
+  if(organism->GetCellID()==-1) return false;
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+  cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+  const int x = FindModifiedRegister(REG_BX);
+  GetRegister(x) = deme.GetCellPosition(deme.GetCellsToLink().second).first;
+  return true;
+}
+
+
+//! Returns the y coordinate of the second randomly selected cell.
+bool cHardwareCPU::Inst_CellTwoY(cAvidaContext& ctx) {
+  if(organism->GetCellID()==-1) return false;
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+  cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+  const int x = FindModifiedRegister(REG_BX);
+  GetRegister(x) = deme.GetCellPosition(deme.GetCellsToLink().second).second;
+  return true;
+}
+
+
+//! Returns the x coordinate of the caller.
+bool cHardwareCPU::Inst_SelfX(cAvidaContext& ctx) {
+  if(organism->GetCellID()==-1) return false;
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+  cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+  const int x = FindModifiedRegister(REG_BX);
+  GetRegister(x) = deme.GetCellPosition(cell.GetID()).first;
+  return true;
+}
+
+
+//! Returns the y coordinate of the caller.
+bool cHardwareCPU::Inst_SelfY(cAvidaContext& ctx) {
+  if(organism->GetCellID()==-1) return false;
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+  cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+  const int x = FindModifiedRegister(REG_BX);
+  GetRegister(x) = deme.GetCellPosition(cell.GetID()).first;
+  return true;
+}
+
+
+//! Executes the next instruction if all available registers are sorted in 
+bool cHardwareCPU::Inst_Sorted(cAvidaContext& ctx) {
+  const int dest = FindModifiedRegister(REG_BX);
+  if(((GetRegister(REG_AX) <= GetRegister(REG_BX))
+      && (GetRegister(REG_BX) <= GetRegister(REG_CX)))
+     || ((GetRegister(REG_AX) >= GetRegister(REG_BX))
+         && (GetRegister(REG_BX) >= GetRegister(REG_CX)))) {
+    GetRegister(dest) = 1;
+  } else {
+    GetRegister(dest) = 0;
+  }
+
+  return true;
+}

Modified: branches/dkdev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/dkdev/source/cpu/cHardwareCPU.h	2007-09-27 20:48:16 UTC (rev 2115)
+++ branches/dkdev/source/cpu/cHardwareCPU.h	2007-09-28 02:42:11 UTC (rev 2116)
@@ -496,6 +496,13 @@
   
   // Two cells instructions.
   bool Inst_Region(cAvidaContext& ctx);
+  bool cHardwareCPU::Inst_CellOneX(cAvidaContext& ctx);
+  bool cHardwareCPU::Inst_CellOneY(cAvidaContext& ctx);
+  bool cHardwareCPU::Inst_CellTwoX(cAvidaContext& ctx);
+  bool cHardwareCPU::Inst_CellTwoY(cAvidaContext& ctx);
+  bool cHardwareCPU::Inst_SelfX(cAvidaContext& ctx);
+  bool cHardwareCPU::Inst_SelfY(cAvidaContext& ctx);
+  bool cHardwareCPU::Inst_Sorted(cAvidaContext& ctx);
 };
 
 




More information about the Avida-cvs mailing list