[Avida-SVN] r2428 - development/source/cpu
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Thu Mar 6 08:47:24 PST 2008
Author: brysonda
Date: 2008-03-06 11:47:24 -0500 (Thu, 06 Mar 2008)
New Revision: 2428
Modified:
development/source/cpu/cHardwareExperimental.cc
development/source/cpu/cHardwareExperimental.h
Log:
Implement separate input/output instructions in experimental cpu.
Modified: development/source/cpu/cHardwareExperimental.cc
===================================================================
--- development/source/cpu/cHardwareExperimental.cc 2008-03-06 14:56:32 UTC (rev 2427)
+++ development/source/cpu/cHardwareExperimental.cc 2008-03-06 16:47:24 UTC (rev 2428)
@@ -122,6 +122,8 @@
tInstLibEntry<tMethod>("nand", &cHardwareExperimental::Inst_Nand, nInstFlag::DEFAULT, "Nand BX by CX and place the result in ?BX?"),
tInstLibEntry<tMethod>("IO", &cHardwareExperimental::Inst_TaskIO, (nInstFlag::DEFAULT | nInstFlag::STALL), "Output ?BX?, and input new number back into ?BX?"),
+ tInstLibEntry<tMethod>("input", &cHardwareExperimental::Inst_TaskInput, nInstFlag::STALL, "Input new number into ?BX?"),
+ tInstLibEntry<tMethod>("output", &cHardwareExperimental::Inst_TaskOutput, nInstFlag::STALL, "Output ?BX?"),
tInstLibEntry<tMethod>("mult", &cHardwareExperimental::Inst_Mult, 0, "Multiple BX by CX and place the result in ?BX?"),
tInstLibEntry<tMethod>("div", &cHardwareExperimental::Inst_Div, 0, "Divide BX by CX and place the result in ?BX?"),
@@ -1209,6 +1211,31 @@
}
+bool cHardwareExperimental::Inst_TaskInput(cAvidaContext& ctx)
+{
+ const int reg_used = FindModifiedRegister(REG_BX);
+
+ // Do the "get" component
+ const int value_in = organism->GetNextInput();
+ GetRegister(reg_used) = value_in;
+ organism->DoInput(value_in);
+
+ return true;
+}
+
+
+bool cHardwareExperimental::Inst_TaskOutput(cAvidaContext& ctx)
+{
+ const int reg_used = FindModifiedRegister(REG_BX);
+
+ // Do the "put" component
+ const int value_out = GetRegister(reg_used);
+ organism->DoOutput(ctx, value_out); // Check for tasks completed.
+
+ return true;
+}
+
+
bool cHardwareExperimental::Inst_MoveHead(cAvidaContext& ctx)
{
const int head_used = FindModifiedHead(nHardware::HEAD_IP);
Modified: development/source/cpu/cHardwareExperimental.h
===================================================================
--- development/source/cpu/cHardwareExperimental.h 2008-03-06 14:56:32 UTC (rev 2427)
+++ development/source/cpu/cHardwareExperimental.h 2008-03-06 16:47:24 UTC (rev 2428)
@@ -347,6 +347,8 @@
// I/O and Sensory
bool Inst_TaskIO(cAvidaContext& ctx);
+ bool Inst_TaskInput(cAvidaContext& ctx);
+ bool Inst_TaskOutput(cAvidaContext& ctx);
// Head-based instructions...
bool Inst_HeadAlloc(cAvidaContext& ctx);
More information about the Avida-cvs
mailing list