[Avida-SVN] r1460 - in branches/uml/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Wed Apr 4 18:55:56 PDT 2007
Author: hjg
Date: 2007-04-04 21:55:55 -0400 (Wed, 04 Apr 2007)
New Revision: 1460
Modified:
branches/uml/source/cpu/cHardwareCPU.cc
branches/uml/source/cpu/cHardwareCPU.h
branches/uml/source/main/cTaskLib.cc
Log:
Added jump command for vector indices that reads in a nop label.
Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc 2007-04-05 01:49:27 UTC (rev 1459)
+++ branches/uml/source/cpu/cHardwareCPU.cc 2007-04-05 01:55:55 UTC (rev 1460)
@@ -367,7 +367,9 @@
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"),
+ "Go to the last position in the list"),
+ cInstEntryCPU("jump-d", &cHardwareCPU::Inst_JumpDist, false,
+ "Jump to a position in the list using labels."),
};
const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
@@ -3493,6 +3495,44 @@
return true;
}
+bool cHardwareCPU::Inst_JumpDist(cAvidaContext& ctx)
+{
+ const int reg_used = FindModifiedRegister(REG_AX);
+ ReadLabel();
+ int jump_amount = GetLabel().AsInt(NUM_NOPS);
+ //const int reg_jump = FindModifiedRegister(REG_BX);
+ //int jump_amount = GetRegister(reg_jump);
+
+
+ switch (reg_used){
+ case 0:
+ // decrement the triggers vector index
+ organism->absoluteJumpTrigger(jump_amount);
+ break;
+ case 1:
+ // decrement the guards vector index
+ organism->absoluteJumpGuard(jump_amount);
+ break;
+ case 2:
+ // decrement the actions vector index
+ organism->absoluteJumpAction(jump_amount);
+ break;
+ case 3:
+ // decrement the transition labels index
+ organism->absoluteJumpTransitionLabel(jump_amount);
+ break;
+ case 4:
+ // decrement the original state index
+ organism->absoluteJumpOriginState(jump_amount);
+ break;
+ case 5:
+ // decement the destination state index
+ organism->absoluteJumpDestinationState(jump_amount);
+ break;
+ }
+ return true;
+}
+
bool cHardwareCPU::Inst_First(cAvidaContext& ctx)
{
// by default, this instruction increments the triggers vector index
Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h 2007-04-05 01:49:27 UTC (rev 1459)
+++ branches/uml/source/cpu/cHardwareCPU.h 2007-04-05 01:55:55 UTC (rev 1460)
@@ -476,6 +476,7 @@
bool Inst_Next(cAvidaContext& ctx);
bool Inst_Prev(cAvidaContext& ctx);
bool Inst_JumpIndex(cAvidaContext& ctx);
+ bool Inst_JumpDist(cAvidaContext& ctx);
bool Inst_AddTransitionLabel(cAvidaContext& ctx);
bool Inst_AddTransition(cAvidaContext& ctx);
bool Inst_Last(cAvidaContext& ctx);
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-04-05 01:49:27 UTC (rev 1459)
+++ branches/uml/source/main/cTaskLib.cc 2007-04-05 01:55:55 UTC (rev 1460)
@@ -1857,7 +1857,7 @@
double cTaskLib::Task_Trans1(cTaskContext* ctx) const
{
double bonus = 0.0;
- if (ctx->organism->findTrans(1,2, "tagaaa")) {
+ if (ctx->organism->findTrans(0,1, "tagaaa")) {
bonus = 1.0;
}
@@ -1868,7 +1868,7 @@
double cTaskLib::Task_Trans2(cTaskContext* ctx) const
{
double bonus = 0.0;
- if (ctx->organism->findTrans(2,3, "tagdab")){
+ if (ctx->organism->findTrans(1,2, "tagdab")){
bonus = 1.0;
}
@@ -1880,7 +1880,7 @@
double cTaskLib::Task_Trans3(cTaskContext* ctx) const
{
double bonus = 0.0;
- if (ctx->organism->findTrans(3,4, "tcgbac")){
+ if (ctx->organism->findTrans(2,3, "tcgbac")){
bonus = 1.0;
}
@@ -1892,7 +1892,7 @@
double cTaskLib::Task_Trans4(cTaskContext* ctx) const
{
double bonus = 0.0;
- if (ctx->organism->findTrans(0,1, "tbgcad")){
+ if (ctx->organism->findTrans(3,4, "tbgcad")){
bonus = 1.0;
}
More information about the Avida-cvs
mailing list