[Avida-SVN] r3170 - development/source/cpu
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Fri Feb 27 18:48:27 PST 2009
Author: brysonda
Date: 2009-02-27 21:48:27 -0500 (Fri, 27 Feb 2009)
New Revision: 3170
Modified:
development/source/cpu/cHardwareCPU.cc
development/source/cpu/cHardwareCPU.h
development/source/cpu/cHardwareExperimental.cc
development/source/cpu/cHardwareExperimental.h
Log:
Add support for direct match templates in cHardwareCPU and cHardwareExperimental for comparison purposes.
Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc 2009-02-27 16:54:29 UTC (rev 3169)
+++ development/source/cpu/cHardwareCPU.cc 2009-02-28 02:48:27 UTC (rev 3170)
@@ -313,6 +313,7 @@
tInstLibEntry<tMethod>("h-write", &cHardwareCPU::Inst_HeadWrite),
tInstLibEntry<tMethod>("h-copy", &cHardwareCPU::Inst_HeadCopy, nInstFlag::DEFAULT, "Copy from read-head to write-head; advance both"),
tInstLibEntry<tMethod>("h-search", &cHardwareCPU::Inst_HeadSearch, nInstFlag::DEFAULT, "Find complement template and make with flow head"),
+ tInstLibEntry<tMethod>("h-search-direct", &cHardwareCPU::Inst_HeadSearch, nInstFlag::DEFAULT, "Find direct template and move the flow head"),
tInstLibEntry<tMethod>("h-push", &cHardwareCPU::Inst_HeadPush),
tInstLibEntry<tMethod>("h-pop", &cHardwareCPU::Inst_HeadPop),
tInstLibEntry<tMethod>("set-head", &cHardwareCPU::Inst_SetHead),
@@ -321,6 +322,7 @@
tInstLibEntry<tMethod>("jmp-head", &cHardwareCPU::Inst_JumpHead, nInstFlag::DEFAULT, "Move head ?IP? by amount in CX register; CX = old pos."),
tInstLibEntry<tMethod>("get-head", &cHardwareCPU::Inst_GetHead, nInstFlag::DEFAULT, "Copy the position of the ?IP? head into CX"),
tInstLibEntry<tMethod>("if-label", &cHardwareCPU::Inst_IfLabel, nInstFlag::DEFAULT, "Execute next if we copied complement of attached label"),
+ tInstLibEntry<tMethod>("if-label-direct", &cHardwareCPU::Inst_IfLabel, nInstFlag::DEFAULT, "Execute next if we copied direct match of the attached label"),
tInstLibEntry<tMethod>("if-label2", &cHardwareCPU::Inst_IfLabel2, 0, "If copied label compl., exec next inst; else SKIP W/NOPS"),
tInstLibEntry<tMethod>("set-flow", &cHardwareCPU::Inst_SetFlow, nInstFlag::DEFAULT, "Set flow-head to position in ?CX?"),
@@ -5179,6 +5181,13 @@
return true;
}
+bool cHardwareCPU::Inst_IfLabelDirect(cAvidaContext& ctx)
+{
+ ReadLabel();
+ if (GetLabel() != GetReadLabel()) IP().Advance();
+ 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(cAvidaContext& ctx)
@@ -5468,6 +5477,18 @@
return true;
}
+bool cHardwareCPU::Inst_HeadSearchDirect(cAvidaContext& ctx)
+{
+ ReadLabel();
+ cHeadCPU found_pos = FindLabel(0);
+ const int search_size = found_pos.GetPosition() - IP().GetPosition();
+ GetRegister(REG_BX) = search_size;
+ GetRegister(REG_CX) = GetLabel().GetSize();
+ GetHead(nHardware::HEAD_FLOW).Set(found_pos);
+ GetHead(nHardware::HEAD_FLOW).Advance();
+ return true;
+}
+
bool cHardwareCPU::Inst_SetFlow(cAvidaContext& ctx)
{
const int reg_used = FindModifiedRegister(REG_CX);
Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h 2009-02-27 16:54:29 UTC (rev 3169)
+++ development/source/cpu/cHardwareCPU.h 2009-02-28 02:48:27 UTC (rev 3170)
@@ -580,6 +580,7 @@
bool Inst_JumpHead(cAvidaContext& ctx);
bool Inst_GetHead(cAvidaContext& ctx);
bool Inst_IfLabel(cAvidaContext& ctx);
+ bool Inst_IfLabelDirect(cAvidaContext& ctx);
bool Inst_IfLabel2(cAvidaContext& ctx);
bool Inst_HeadDivide(cAvidaContext& ctx);
bool Inst_HeadDivideRS(cAvidaContext& ctx); //AWC 06/29/06
@@ -589,6 +590,7 @@
bool Inst_HeadWrite(cAvidaContext& ctx);
bool Inst_HeadCopy(cAvidaContext& ctx);
bool Inst_HeadSearch(cAvidaContext& ctx);
+ bool Inst_HeadSearchDirect(cAvidaContext& ctx);
bool Inst_SetFlow(cAvidaContext& ctx);
bool Inst_HeadCopy2(cAvidaContext& ctx);
Modified: development/source/cpu/cHardwareExperimental.cc
===================================================================
--- development/source/cpu/cHardwareExperimental.cc 2009-02-27 16:54:29 UTC (rev 3169)
+++ development/source/cpu/cHardwareExperimental.cc 2009-02-28 02:48:27 UTC (rev 3170)
@@ -139,12 +139,15 @@
tInstLibEntry<tMethod>("label", &cHardwareExperimental::Inst_Label, (nInstFlag::DEFAULT | nInstFlag::LABEL)),
tInstLibEntry<tMethod>("h-search", &cHardwareExperimental::Inst_HeadSearch, nInstFlag::DEFAULT, "Find complement template and make with flow head"),
+ tInstLibEntry<tMethod>("h-search-direct", &cHardwareExperimental::Inst_HeadSearchDirect, nInstFlag::DEFAULT, "Find direct template and move the flow head"),
+ tInstLibEntry<tMethod>("h-search-lbl", &cHardwareExperimental::Inst_HeadSearchLabel, nInstFlag::LABEL, "Find complement template and make with flow head"),
+ tInstLibEntry<tMethod>("h-search-direct-lbl", &cHardwareExperimental::Inst_HeadSearchDirectLabel, nInstFlag::LABEL, "Find direct template and move the flow head"),
+
tInstLibEntry<tMethod>("mov-head", &cHardwareExperimental::Inst_MoveHead, nInstFlag::DEFAULT, "Move head ?IP? to the flow head"),
tInstLibEntry<tMethod>("jmp-head", &cHardwareExperimental::Inst_JumpHead, nInstFlag::DEFAULT, "Move head ?Flow? by amount in ?CX? register"),
tInstLibEntry<tMethod>("get-head", &cHardwareExperimental::Inst_GetHead, nInstFlag::DEFAULT, "Copy the position of the ?IP? head into ?CX?"),
- tInstLibEntry<tMethod>("h-search-lbl", &cHardwareExperimental::Inst_HeadSearchLabel, nInstFlag::LABEL, "Find complement template and make with flow head"),
// Replication Instructions
@@ -153,6 +156,7 @@
tInstLibEntry<tMethod>("h-divide-sex", &cHardwareExperimental::Inst_HeadDivideSex, (nInstFlag::DEFAULT | nInstFlag::STALL), "Divide code between read and write heads."),
tInstLibEntry<tMethod>("h-copy", &cHardwareExperimental::Inst_HeadCopy, nInstFlag::DEFAULT, "Copy from read-head to write-head; advance both"),
tInstLibEntry<tMethod>("if-label", &cHardwareExperimental::Inst_IfLabel, nInstFlag::DEFAULT, "Execute next if we copied complement of attached label"),
+ tInstLibEntry<tMethod>("if-label-direct", &cHardwareExperimental::Inst_IfLabelDirect, nInstFlag::DEFAULT, "Execute next if we copied direct match of the attached label"),
tInstLibEntry<tMethod>("h-read", &cHardwareExperimental::Inst_HeadRead, 0, "Read from the read-head, place into ?BX?, advance read-head"),
tInstLibEntry<tMethod>("h-write", &cHardwareExperimental::Inst_HeadWrite, 0, "Write from ?BX? to the write head, advance write-head"),
@@ -1342,7 +1346,14 @@
return true;
}
+bool cHardwareExperimental::Inst_IfLabelDirect(cAvidaContext& ctx)
+{
+ ReadLabel();
+ if (GetLabel() != GetReadLabel()) IP().Advance();
+ return true;
+}
+
bool cHardwareExperimental::Inst_HeadDivide(cAvidaContext& ctx)
{
m_organism->GetPhenotype().SetDivideSex(false);
@@ -1485,6 +1496,27 @@
return true;
}
+bool cHardwareExperimental::Inst_HeadSearchDirect(cAvidaContext& ctx)
+{
+ ReadLabel();
+ cHeadCPU found_pos = FindLabelStart(true);
+ const int search_size = found_pos.GetPosition() - IP().GetPosition();
+ setInternalValue(m_threads[m_cur_thread].reg[REG_BX], search_size);
+ setInternalValue(m_threads[m_cur_thread].reg[REG_CX], GetLabel().GetSize());
+ GetHead(nHardware::HEAD_FLOW).Set(found_pos);
+ GetHead(nHardware::HEAD_FLOW).Advance();
+ return true;
+}
+
+bool cHardwareExperimental::Inst_HeadSearchDirectLabel(cAvidaContext& ctx)
+{
+ ReadLabel();
+ cHeadCPU found_pos = FindLabelStart(true);
+ GetHead(nHardware::HEAD_FLOW).Set(found_pos);
+ GetHead(nHardware::HEAD_FLOW).Advance();
+ return true;
+}
+
bool cHardwareExperimental::Inst_SetFlow(cAvidaContext& ctx)
{
const int reg_used = FindModifiedRegister(REG_CX);
Modified: development/source/cpu/cHardwareExperimental.h
===================================================================
--- development/source/cpu/cHardwareExperimental.h 2009-02-27 16:54:29 UTC (rev 3169)
+++ development/source/cpu/cHardwareExperimental.h 2009-02-28 02:48:27 UTC (rev 3170)
@@ -424,6 +424,7 @@
bool Inst_JumpHead(cAvidaContext& ctx);
bool Inst_GetHead(cAvidaContext& ctx);
bool Inst_IfLabel(cAvidaContext& ctx);
+ bool Inst_IfLabelDirect(cAvidaContext& ctx);
bool Inst_HeadDivide(cAvidaContext& ctx);
bool Inst_HeadDivideSex(cAvidaContext& ctx);
bool Inst_HeadRead(cAvidaContext& ctx);
@@ -431,6 +432,8 @@
bool Inst_HeadCopy(cAvidaContext& ctx);
bool Inst_HeadSearch(cAvidaContext& ctx);
bool Inst_HeadSearchLabel(cAvidaContext& ctx);
+ bool Inst_HeadSearchDirect(cAvidaContext& ctx);
+ bool Inst_HeadSearchDirectLabel(cAvidaContext& ctx);
bool Inst_SetFlow(cAvidaContext& ctx);
// Goto Variants
More information about the Avida-cvs
mailing list