[Avida-SVN] r1440 - in branches/uml/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Thu Mar 29 20:47:47 PDT 2007
Author: hjg
Date: 2007-03-29 23:47:47 -0400 (Thu, 29 Mar 2007)
New Revision: 1440
Modified:
branches/uml/source/cpu/cHardwareCPU.cc
branches/uml/source/cpu/cHardwareCPU.h
branches/uml/source/main/cOrganism.h
Log:
Added a first and last instruction in a preliminary attempt to increase modularity in the construction of the diagram elements.
Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc 2007-03-28 21:43:18 UTC (rev 1439)
+++ branches/uml/source/cpu/cHardwareCPU.cc 2007-03-30 03:47:47 UTC (rev 1440)
@@ -364,6 +364,10 @@
"Add a transition"),
cInstEntryCPU("jump", &cHardwareCPU::Inst_JumpIndex, false,
"Jump to a position in the list"),
+ cInstEntryCPU("first", &cHardwareCPU::Inst_First, false,
+ "Go to the first position in the list"),
+ cInstEntryCPU("last", &cHardwareCPU::Inst_Last, false,
+ "Go to the last position in the list"),
};
const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
@@ -3489,7 +3493,81 @@
return true;
}
+bool cHardwareCPU::Inst_First(cAvidaContext& ctx)
+{
+ // by default, this instruction increments the triggers vector index
+
+ int reg_used = FindModifiedRegister(REG_AX);
+
+// int jump_amount = 1;
+
+ switch (reg_used){
+ case 0:
+ // decrement the triggers vector index
+ organism->firstTrigger();
+ break;
+ case 1:
+ // decrement the guards vector index
+ organism->firstGuard();
+ break;
+ case 2:
+ // decrement the actions vector index
+ organism->firstAction();
+ break;
+ case 3:
+ // decrement the transition labels index
+ organism->firstTransitionLabel();
+ break;
+ case 4:
+ // decrement the original state index
+ organism->firstOriginState();
+ break;
+ case 5:
+ // decement the destination state index
+ organism->firstDestinationState();
+ break;
+ }
+ return true;
+}
+bool cHardwareCPU::Inst_Last(cAvidaContext& ctx)
+{
+ // by default, this instruction increments the triggers vector index
+
+ int reg_used = FindModifiedRegister(REG_AX);
+
+// int jump_amount = 1;
+
+ switch (reg_used){
+ case 0:
+ // decrement the triggers vector index
+ organism->lastTrigger();
+ break;
+ case 1:
+ // decrement the guards vector index
+ organism->lastGuard();
+ break;
+ case 2:
+ // decrement the actions vector index
+ organism->lastAction();
+ break;
+ case 3:
+ // decrement the transition labels index
+ organism->lastTransitionLabel();
+ break;
+ case 4:
+ // decrement the original state index
+ organism->lastOriginState();
+ break;
+ case 5:
+ // decement the destination state index
+ organism->lastDestinationState();
+ break;
+ }
+ return true;
+}
+
+
bool cHardwareCPU::Inst_AddTransitionLabel(cAvidaContext& ctx)
{
return organism->addTransitionLabel();
Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h 2007-03-28 21:43:18 UTC (rev 1439)
+++ branches/uml/source/cpu/cHardwareCPU.h 2007-03-30 03:47:47 UTC (rev 1440)
@@ -478,6 +478,8 @@
bool Inst_JumpIndex(cAvidaContext& ctx);
bool Inst_AddTransitionLabel(cAvidaContext& ctx);
bool Inst_AddTransition(cAvidaContext& ctx);
+ bool Inst_Last(cAvidaContext& ctx);
+ bool Inst_First(cAvidaContext& ctx);
};
Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h 2007-03-28 21:43:18 UTC (rev 1439)
+++ branches/uml/source/main/cOrganism.h 2007-03-30 03:47:47 UTC (rev 1440)
@@ -237,6 +237,8 @@
template <typename T>
bool moveIndex (T x, int &y, int z);
+
+
// The jump functions jump the index of the various vectors either forward (+ int) or backwards (- int)
bool jumpGuard(int);
@@ -246,6 +248,23 @@
bool jumpOriginState(int);
bool jumpDestinationState(int);
+
+// The first functions jump the index to the beginning of various vectors
+ bool firstGuard() {guard_index = 0;}
+ bool firstAction() {action_index = 0;}
+ bool firstTrigger() {trigger_index = 0;}
+ bool firstTransitionLabel() {trans_label_index = 0;}
+ bool firstOriginState() {orig_state_index = 0;}
+ bool firstDestinationState() {dest_state_index = 0;}
+
+// The last functions jump the index to the end of various vectors
+ bool lastGuard() {guard_index = (guards.size()-1);}
+ bool lastAction() {action_index = (actions.size()-1);}
+ bool lastTrigger() {trigger_index = (triggers.size()-1);}
+ bool lastTransitionLabel() {trans_label_index = (transition_labels.size()-1);}
+ bool lastOriginState() {orig_state_index = (states.size()-1);}
+ bool lastDestinationState() {dest_state_index = (states.size()-1);}
+
// The get functions get the value of the index of various vectors
std::string getTrigger();
More information about the Avida-cvs
mailing list