[avida-cvs] avida CVS commits: /current/source defs.hh /current/source/cpu hardware_4stack.cc hardware_cpu.cc hardware_util.cc /current/source/main analyze.cc avida.cc inst_set.cc inst_set.hh /current/source/qt-viewer setup_avida.cc
kaben
avida-cvs at alife.org
Fri Jun 13 22:49:59 PDT 2003
kaben Fri Jun 13 14:49:59 2003 EDT
Modified files:
/avida/current/source defs.hh
/avida/current/source/cpu hardware_4stack.cc hardware_cpu.cc
hardware_util.cc
/avida/current/source/main analyze.cc avida.cc inst_set.cc
inst_set.hh
/avida/current/source/qt-viewer setup_avida.cc
Log:
Removed old inst_lib code.
-------------- next part --------------
Index: avida/current/source/defs.hh
diff -u avida/current/source/defs.hh:1.29 avida/current/source/defs.hh:1.30
--- avida/current/source/defs.hh:1.29 Mon Jun 9 13:59:27 2003
+++ avida/current/source/defs.hh Fri Jun 13 14:49:58 2003
@@ -18,14 +18,6 @@
#define HTMLDIR "../work/doc_html/"
#endif
-/*
-When defined, instruction sets, instruction libraries, hardware use new
-instruction set code. The old code remains, and will be used if the
-following is not defined.
-*/
-/* XXX remove after regression tests */
-#define USE_INST_SET_CODE
-/**/
// -= Various view modes =-
#define VIEW_NEWVIEWER
Index: avida/current/source/cpu/hardware_4stack.cc
diff -u avida/current/source/cpu/hardware_4stack.cc:1.8 avida/current/source/cpu/hardware_4stack.cc:1.9
--- avida/current/source/cpu/hardware_4stack.cc:1.8 Thu Jun 5 13:14:40 2003
+++ avida/current/source/cpu/hardware_4stack.cc Fri Jun 13 14:49:58 2003
@@ -136,15 +136,10 @@
char marker; fp>>marker; assert( marker == '|' );
/* YIKES! data loss below: */
-#ifdef USE_INST_SET_CODE
char the_cur_head = cur_head;
char the_input_pointer = input_pointer;
fp.get(the_cur_head);
fp.get(the_input_pointer);
-#else /* USE_INST_SET_CODE */
- fp.get((char)cur_head);
- fp.get((char)input_pointer);
-#endif /* USE_INST_SET_CODE */
// IO buffers
input_buf.LoadState(fp);
@@ -156,7 +151,6 @@
}
-#ifdef USE_INST_SET_CODE
///////////////
// cInstLib4Stack
///////////////
@@ -212,13 +206,11 @@
const cInstruction & GetInstDefault(){ return inst_default; }
const cInstruction & GetInstError(){ return inst_error; }
};
-#endif /* USE_INST_SET_CODE */
///////////////
// cHardware4Stack
///////////////
-#ifdef USE_INST_SET_CODE
const cInstruction cInstLib4Stack::inst_error(255);
const cInstruction cInstLib4Stack::inst_default(0);
cInstLibBase *cHardware4Stack::GetInstLib(){ return s_inst_slib; }
@@ -447,17 +439,14 @@
return inst_lib;
}
-#endif /* USE_INST_SET_CODE */
cHardware4Stack::cHardware4Stack(cOrganism * in_organism, cInstSet * in_inst_set)
: cHardwareBase(in_organism, in_inst_set)
, memory_array(NUM_MEMORY_SPACES)
{
-#ifdef USE_INST_SET_CODE
/* FIXME: reorganize storage of m_functions. -- kgn */
m_functions = s_inst_slib->GetFunctions();
/**/
-#endif /* USE_INST_SET_CODE */
memory_array[0] = in_organism->GetGenome(); // Initialize memory...
Reset(); // Setup the rest of the hardware...
}
@@ -607,24 +596,14 @@
bool cHardware4Stack::SingleProcess_ExecuteInst(const cInstruction & cur_inst)
{
// Get a pointer to the corrisponding method...
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int inst_idx = GetInstSet().GetLibFunctionIndex(cur_inst);
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- tHardwareMethod inst_ptr = GetInstSet().GetFunction(cur_inst);
-#endif /* USE_INST_SET_CODE */
// Mark the instruction as executed
IP().FlagExecuted() = true;
#ifdef EXECUTION_ERRORS
// If there is an execution error, execute a random instruction.
-#ifdef USE_INST_SET_CODE
if (organism->TestExeErr()) inst_idx = GetInstSet().GetRandFunctionIndex();
-#else /* USE_INST_SET_CODE */
- if (organism->TestExeErr()) inst_ptr = GetInstSet().GetRandFunction();
-#endif /* USE_INST_SET_CODE */
#endif /* EXECUTION_ERRORS */
#ifdef INSTRUCTION_COUNT
@@ -633,15 +612,7 @@
#endif
// And execute it.
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
- const bool exec_success
- //= (this->*(s_inst_slib->GetFunctions()[inst_idx]))();
- = (this->*(m_functions[inst_idx]))();
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- const bool exec_success = (this->*inst_ptr)();
-#endif /* USE_INST_SET_CODE */
+ const bool exec_success = (this->*(m_functions[inst_idx]))();
#ifdef INSTRUCTION_COUNT
// decremenet if the instruction was not executed successfully
Index: avida/current/source/cpu/hardware_cpu.cc
diff -u avida/current/source/cpu/hardware_cpu.cc:1.50 avida/current/source/cpu/hardware_cpu.cc:1.51
--- avida/current/source/cpu/hardware_cpu.cc:1.50 Fri Jun 6 12:46:22 2003
+++ avida/current/source/cpu/hardware_cpu.cc Fri Jun 13 14:49:59 2003
@@ -13,9 +13,7 @@
#include "../tools/string_util.hh"
#include "../main/config.hh"
-#ifdef USE_INST_SET_CODE
- #include "../main/inst_set.hh"
-#endif /* USE_INST_SET_CODE */
+#include "../main/inst_set.hh"
#include "../main/inst_lib.hh"
#include "../main/genome_util.hh"
#include "../main/organism.hh"
@@ -147,7 +145,6 @@
stack.LoadState(fp);
char marker; fp>>marker; assert( marker == '|' );
-#ifdef USE_INST_SET_CODE
/* YIKES! data loss below: */
char the_cur_stack = cur_stack;
char the_cur_head = cur_head;
@@ -155,11 +152,6 @@
fp.get(the_cur_stack);
fp.get(the_cur_head);
fp.get(the_input_pointer);
-#else /* USE_INST_SET_CODE */
- fp.get((char)cur_stack);
- fp.get((char)cur_head);
- fp.get((char)input_pointer);
-#endif /* USE_INST_SET_CODE */
// IO buffers
input_buf.LoadState(fp);
@@ -171,7 +163,6 @@
}
-#ifdef USE_INST_SET_CODE
///////////////
// cInstLibCPU
///////////////
@@ -227,13 +218,11 @@
const cInstruction & GetInstDefault(){ return inst_default; }
const cInstruction & GetInstError(){ return inst_error; }
};
-#endif /* USE_INST_SET_CODE */
///////////////
// cHardwareCPU
///////////////
-#ifdef USE_INST_SET_CODE
const cInstruction cInstLibCPU::inst_error(255);
const cInstruction cInstLibCPU::inst_default(0);
cInstLibBase *cHardwareCPU::GetInstLib(){ return s_inst_slib; }
@@ -540,16 +529,13 @@
return inst_lib;
}
-#endif /* USE_INST_SET_CODE */
cHardwareCPU::cHardwareCPU(cOrganism * in_organism, cInstSet * in_inst_set)
: cHardwareBase(in_organism, in_inst_set)
{
-#ifdef USE_INST_SET_CODE
/* FIXME: reorganize storage of m_functions. -- kgn */
m_functions = s_inst_slib->GetFunctions();
/**/
-#endif /* USE_INST_SET_CODE */
memory = in_organism->GetGenome(); // Initialize memory...
Reset(); // Setup the rest of the hardware...
}
@@ -689,24 +675,14 @@
bool cHardwareCPU::SingleProcess_ExecuteInst(const cInstruction & cur_inst)
{
// Get a pointer to the corrisponding method...
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int inst_idx = GetInstSet().GetLibFunctionIndex(cur_inst);
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- tHardwareMethod inst_ptr = GetInstSet().GetFunction(cur_inst);
-#endif /* USE_INST_SET_CODE */
// Mark the instruction as executed
IP().FlagExecuted() = true;
#ifdef EXECUTION_ERRORS
// If there is an execution error, execute a random instruction.
-#ifdef USE_INST_SET_CODE
if (organism->TestExeErr()) inst_idx = GetInstSet().GetRandFunctionIndex();
-#else /* USE_INST_SET_CODE */
- if (organism->TestExeErr()) inst_ptr = GetInstSet().GetRandFunction();
-#endif /* USE_INST_SET_CODE */
#endif /* EXECUTION_ERRORS */
#ifdef INSTRUCTION_COUNT
@@ -715,15 +691,9 @@
#endif
// And execute it.
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
const bool exec_success
//= (this->*(s_inst_slib->GetFunctions()[inst_idx]))();
= (this->*(m_functions[inst_idx]))();
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- const bool exec_success = (this->*inst_ptr)();
-#endif /* USE_INST_SET_CODE */
#ifdef INSTRUCTION_COUNT
// decremenet if the instruction was not executed successfully
Index: avida/current/source/cpu/hardware_util.cc
diff -u avida/current/source/cpu/hardware_util.cc:1.29 avida/current/source/cpu/hardware_util.cc:1.30
--- avida/current/source/cpu/hardware_util.cc:1.29 Fri May 30 14:39:49 2003
+++ avida/current/source/cpu/hardware_util.cc Fri Jun 13 14:49:59 2003
@@ -22,17 +22,10 @@
using namespace std;
-#ifdef USE_INST_SET_CODE
void cHardwareUtil::LoadInstSet(cString filename, cInstSet & inst_set,
tDictionary<int> & nop_dict,
tDictionary<int> & inst_dict
){
-#else /* USE_INST_SET_CODE */
-void cHardwareUtil::LoadInstSet(cString & filename, cInstSet & inst_set,
- tDictionary<int> & nop_dict,
- tDictionary<tHardwareMethod> & inst_dict
-){
-#endif /* USE_INST_SET_CODE */
// If there is no filename, use the default for the appropriate hardware.
cString default_filename = "unknown";
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
@@ -92,45 +85,18 @@
// Otherwise, this instruction will be in the set.
// First, determine if it is a nop...
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int nop_mod = -1;
if(nop_dict.Find(inst_name, nop_mod) == true) {
inst_set.AddNop2(nop_mod, redundancy, ft_cost, cost, prob_fail);
continue;
}
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- int nop_mod = -1;
- /* XXX start -- kgn */
- int nop_mod_2 = -1;
- /* XXX end */
- if (nop_dict.Find(inst_name, nop_mod) == true) {
- inst_set.AddNop(inst_name, &cHardwareBase::Inst_Nop, nop_mod,
- redundancy, ft_cost, cost, prob_fail);
- continue;
- }
-#endif /* USE_INST_SET_CODE */
// Otherwise, it had better be in the main dictionary...
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int fun_id = -1;
if(inst_dict.Find(inst_name, fun_id) == true){
inst_set.Add2(fun_id, redundancy, ft_cost, cost, prob_fail);
continue;
}
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- tHardwareMethod cpu_method = NULL;
- /* XXX start -- kgn */
- int fun_id = -1;
- /* XXX end */
- if (inst_dict.Find(inst_name, cpu_method) == true) {
- inst_set.Add(inst_name, cpu_method, redundancy, ft_cost, cost, prob_fail);
- continue;
- }
-#endif /* USE_INST_SET_CODE */
// Oh oh! Didn't find an instruction!
cerr << endl
@@ -148,221 +114,9 @@
{
// Nops (or other modifying-instructions...) Note: Nops must be the
// first instructions added to the set.
-#ifndef USE_INST_SET_CODE
- tDictionary< int > nop_dict;
- nop_dict.Add("nop-A", REG_AX);
- nop_dict.Add("nop-B", REG_BX);
- nop_dict.Add("nop-C", REG_CX);
-#endif /* !USE_INST_SET_CODE */
// Build a dictionary of instructions and their corresponding methods...
-#ifndef USE_INST_SET_CODE
- tDictionary< tHardwareMethod > inst_dict;
-
- // Remaining instructions.
- inst_dict.Add("nop-X", (tHardwareMethod) &cHardwareCPU::Inst_Nop);
- inst_dict.Add("if-equ-0", (tHardwareMethod) &cHardwareCPU::Inst_If0);
- inst_dict.Add("if-not-0", (tHardwareMethod) &cHardwareCPU::Inst_IfNot0);
- inst_dict.Add("if-n-equ", (tHardwareMethod) &cHardwareCPU::Inst_IfNEqu);
- inst_dict.Add("if-equ", (tHardwareMethod) &cHardwareCPU::Inst_IfEqu);
- inst_dict.Add("if-grt-0", (tHardwareMethod) &cHardwareCPU::Inst_IfGr0);
- inst_dict.Add("if-grt", (tHardwareMethod) &cHardwareCPU::Inst_IfGr);
- inst_dict.Add("if->=-0", (tHardwareMethod) &cHardwareCPU::Inst_IfGrEqu0);
- inst_dict.Add("if->=", (tHardwareMethod) &cHardwareCPU::Inst_IfGrEqu);
- inst_dict.Add("if-les-0", (tHardwareMethod) &cHardwareCPU::Inst_IfLess0);
- inst_dict.Add("if-less", (tHardwareMethod) &cHardwareCPU::Inst_IfLess);
- inst_dict.Add("if-<=-0", (tHardwareMethod) &cHardwareCPU::Inst_IfLsEqu0);
- inst_dict.Add("if-<=", (tHardwareMethod) &cHardwareCPU::Inst_IfLsEqu);
- inst_dict.Add("if-A!=B", (tHardwareMethod) &cHardwareCPU::Inst_IfANotEqB);
- inst_dict.Add("if-B!=C", (tHardwareMethod) &cHardwareCPU::Inst_IfBNotEqC);
- inst_dict.Add("if-A!=C", (tHardwareMethod) &cHardwareCPU::Inst_IfANotEqC);
-
- inst_dict.Add("if-bit-1", (tHardwareMethod) &cHardwareCPU::Inst_IfBit1);
- inst_dict.Add("jump-f", (tHardwareMethod) &cHardwareCPU::Inst_JumpF);
- inst_dict.Add("jump-b", (tHardwareMethod) &cHardwareCPU::Inst_JumpB);
- inst_dict.Add("jump-p", (tHardwareMethod) &cHardwareCPU::Inst_JumpP);
- inst_dict.Add("jump-slf", (tHardwareMethod) &cHardwareCPU::Inst_JumpSelf);
- inst_dict.Add("call", (tHardwareMethod) &cHardwareCPU::Inst_Call);
- inst_dict.Add("return", (tHardwareMethod) &cHardwareCPU::Inst_Return);
-
- inst_dict.Add("pop", (tHardwareMethod) &cHardwareCPU::Inst_Pop);
- inst_dict.Add("push", (tHardwareMethod) &cHardwareCPU::Inst_Push);
- inst_dict.Add("swap-stk",(tHardwareMethod) &cHardwareCPU::Inst_SwitchStack);
- inst_dict.Add("flip-stk",(tHardwareMethod) &cHardwareCPU::Inst_FlipStack);
- inst_dict.Add("swap", (tHardwareMethod) &cHardwareCPU::Inst_Swap);
- inst_dict.Add("swap-AB", (tHardwareMethod) &cHardwareCPU::Inst_SwapAB);
- inst_dict.Add("swap-BC", (tHardwareMethod) &cHardwareCPU::Inst_SwapBC);
- inst_dict.Add("swap-AC", (tHardwareMethod) &cHardwareCPU::Inst_SwapAC);
- inst_dict.Add("copy-reg",(tHardwareMethod) &cHardwareCPU::Inst_CopyReg);
- inst_dict.Add("set_A=B", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegAB);
- inst_dict.Add("set_A=C", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegAC);
- inst_dict.Add("set_B=A", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegBA);
- inst_dict.Add("set_B=C", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegBC);
- inst_dict.Add("set_C=A", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegCA);
- inst_dict.Add("set_C=B", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegCB);
- inst_dict.Add("reset", (tHardwareMethod) &cHardwareCPU::Inst_Reset);
-
- inst_dict.Add("pop-A", (tHardwareMethod) &cHardwareCPU::Inst_PopA);
- inst_dict.Add("pop-B", (tHardwareMethod) &cHardwareCPU::Inst_PopB);
- inst_dict.Add("pop-C", (tHardwareMethod) &cHardwareCPU::Inst_PopC);
- inst_dict.Add("push-A", (tHardwareMethod) &cHardwareCPU::Inst_PushA);
- inst_dict.Add("push-B", (tHardwareMethod) &cHardwareCPU::Inst_PushB);
- inst_dict.Add("push-C", (tHardwareMethod) &cHardwareCPU::Inst_PushC);
-
- inst_dict.Add("shift-r", (tHardwareMethod) &cHardwareCPU::Inst_ShiftR);
- inst_dict.Add("shift-l", (tHardwareMethod) &cHardwareCPU::Inst_ShiftL);
- inst_dict.Add("bit-1", (tHardwareMethod) &cHardwareCPU::Inst_Bit1);
- inst_dict.Add("set-num", (tHardwareMethod) &cHardwareCPU::Inst_SetNum);
- inst_dict.Add("inc", (tHardwareMethod) &cHardwareCPU::Inst_Inc);
- inst_dict.Add("dec", (tHardwareMethod) &cHardwareCPU::Inst_Dec);
- inst_dict.Add("zero", (tHardwareMethod) &cHardwareCPU::Inst_Zero);
- inst_dict.Add("neg", (tHardwareMethod) &cHardwareCPU::Inst_Neg);
- inst_dict.Add("square", (tHardwareMethod) &cHardwareCPU::Inst_Square);
- inst_dict.Add("sqrt", (tHardwareMethod) &cHardwareCPU::Inst_Sqrt);
- inst_dict.Add("not", (tHardwareMethod) &cHardwareCPU::Inst_Not);
- inst_dict.Add("log", (tHardwareMethod) &cHardwareCPU::Inst_Log);
- inst_dict.Add("log10", (tHardwareMethod) &cHardwareCPU::Inst_Log10);
- inst_dict.Add("minus-17", (tHardwareMethod) &cHardwareCPU::Inst_Minus17);
-
- inst_dict.Add("add", (tHardwareMethod) &cHardwareCPU::Inst_Add);
- inst_dict.Add("sub", (tHardwareMethod) &cHardwareCPU::Inst_Sub);
- inst_dict.Add("mult", (tHardwareMethod) &cHardwareCPU::Inst_Mult);
- inst_dict.Add("div", (tHardwareMethod) &cHardwareCPU::Inst_Div);
- inst_dict.Add("mod", (tHardwareMethod) &cHardwareCPU::Inst_Mod);
- inst_dict.Add("nand", (tHardwareMethod) &cHardwareCPU::Inst_Nand);
- inst_dict.Add("nor", (tHardwareMethod) &cHardwareCPU::Inst_Nor);
- inst_dict.Add("and", (tHardwareMethod) &cHardwareCPU::Inst_And);
- inst_dict.Add("order", (tHardwareMethod) &cHardwareCPU::Inst_Order);
- inst_dict.Add("xor", (tHardwareMethod) &cHardwareCPU::Inst_Xor);
-
- inst_dict.Add("copy", (tHardwareMethod)&cHardwareCPU::Inst_Copy);
- inst_dict.Add("read", (tHardwareMethod)&cHardwareCPU::Inst_ReadInst);
- inst_dict.Add("write", (tHardwareMethod)&cHardwareCPU::Inst_WriteInst);
- inst_dict.Add("stk-read",(tHardwareMethod)&cHardwareCPU::Inst_StackReadInst);
- inst_dict.Add("stk-writ",(tHardwareMethod)&cHardwareCPU::Inst_StackWriteInst);
-
- inst_dict.Add("compare", (tHardwareMethod) &cHardwareCPU::Inst_Compare);
- inst_dict.Add("if-n-cpy", (tHardwareMethod) &cHardwareCPU::Inst_IfNCpy);
- inst_dict.Add("allocate", (tHardwareMethod) &cHardwareCPU::Inst_Allocate);
- inst_dict.Add("divide", (tHardwareMethod) &cHardwareCPU::Inst_Divide);
- inst_dict.Add("c-alloc", (tHardwareMethod) &cHardwareCPU::Inst_CAlloc);
- inst_dict.Add("c-divide", (tHardwareMethod) &cHardwareCPU::Inst_CDivide);
- inst_dict.Add("inject", (tHardwareMethod) &cHardwareCPU::Inst_Inject);
- inst_dict.Add("inject-r", (tHardwareMethod) &cHardwareCPU::Inst_InjectRand);
- inst_dict.Add("inject-th", (tHardwareMethod) &cHardwareCPU::Inst_InjectThread);
-
- inst_dict.Add("get", (tHardwareMethod)&cHardwareCPU::Inst_TaskGet);
- inst_dict.Add("stk-get", (tHardwareMethod)&cHardwareCPU::Inst_TaskStackGet);
- inst_dict.Add("stk-load",(tHardwareMethod)&cHardwareCPU::Inst_TaskStackLoad);
- inst_dict.Add("put", (tHardwareMethod)&cHardwareCPU::Inst_TaskPut);
- inst_dict.Add("IO", (tHardwareMethod)&cHardwareCPU::Inst_TaskIO);
- inst_dict.Add("search-f",(tHardwareMethod)&cHardwareCPU::Inst_SearchF);
- inst_dict.Add("search-b",(tHardwareMethod)&cHardwareCPU::Inst_SearchB);
- inst_dict.Add("mem-size",(tHardwareMethod)&cHardwareCPU::Inst_MemSize);
-
- inst_dict.Add("rotate-l", (tHardwareMethod) &cHardwareCPU::Inst_RotateL);
- inst_dict.Add("rotate-r", (tHardwareMethod) &cHardwareCPU::Inst_RotateR);
-
- inst_dict.Add("set-cmut", (tHardwareMethod) &cHardwareCPU::Inst_SetCopyMut);
- inst_dict.Add("mod-cmut", (tHardwareMethod) &cHardwareCPU::Inst_ModCopyMut);
-
- // Threading instructions
- inst_dict.Add("fork-th", (tHardwareMethod) &cHardwareCPU::Inst_ForkThread);
- inst_dict.Add("kill-th", (tHardwareMethod) &cHardwareCPU::Inst_KillThread);
- inst_dict.Add("id-th", (tHardwareMethod) &cHardwareCPU::Inst_ThreadID);
-
- // Head-based instructions
- inst_dict.Add("h-alloc", (tHardwareMethod) &cHardwareCPU::Inst_MaxAlloc);
- inst_dict.Add("h-divide", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide);
- inst_dict.Add("h-read", (tHardwareMethod) &cHardwareCPU::Inst_HeadRead);
- inst_dict.Add("h-write", (tHardwareMethod) &cHardwareCPU::Inst_HeadWrite);
- inst_dict.Add("h-copy", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy);
- inst_dict.Add("h-search", (tHardwareMethod) &cHardwareCPU::Inst_HeadSearch);
- inst_dict.Add("h-push", (tHardwareMethod) &cHardwareCPU::Inst_HeadPush);
- inst_dict.Add("h-pop", (tHardwareMethod) &cHardwareCPU::Inst_HeadPop);
- inst_dict.Add("set-head", (tHardwareMethod) &cHardwareCPU::Inst_SetHead);
- inst_dict.Add("adv-head", (tHardwareMethod) &cHardwareCPU::Inst_AdvanceHead);
- inst_dict.Add("mov-head", (tHardwareMethod) &cHardwareCPU::Inst_MoveHead);
- inst_dict.Add("jmp-head", (tHardwareMethod) &cHardwareCPU::Inst_JumpHead);
- inst_dict.Add("get-head", (tHardwareMethod) &cHardwareCPU::Inst_GetHead);
- inst_dict.Add("if-label", (tHardwareMethod) &cHardwareCPU::Inst_IfLabel);
- inst_dict.Add("set-flow", (tHardwareMethod) &cHardwareCPU::Inst_SetFlow);
-
- inst_dict.Add("h-copy2", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy2);
- inst_dict.Add("h-copy3", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy3);
- inst_dict.Add("h-copy4", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy4);
- inst_dict.Add("h-copy5", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy5);
- inst_dict.Add("h-copy6", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy6);
- inst_dict.Add("h-copy7", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy7);
- inst_dict.Add("h-copy8", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy8);
- inst_dict.Add("h-copy9", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy9);
- inst_dict.Add("h-copy10", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy10);
-
-
- inst_dict.Add("divide-sex", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivideSex);
- inst_dict.Add("divide-asex", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide1);
-
- inst_dict.Add("h-divide1", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide1);
- inst_dict.Add("h-divide2", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide2);
- inst_dict.Add("h-divide3", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide3);
- inst_dict.Add("h-divide4", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide4);
- inst_dict.Add("h-divide5", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide5);
- inst_dict.Add("h-divide6", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide6);
- inst_dict.Add("h-divide7", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide7);
- inst_dict.Add("h-divide8", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide8);
- inst_dict.Add("h-divide9", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide9);
- inst_dict.Add("h-divide10", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide10);
- inst_dict.Add("h-divide16", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide16);
- inst_dict.Add("h-divide32", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide32);
- inst_dict.Add("h-divide50", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide50);
- inst_dict.Add("h-divide100", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide100);
- inst_dict.Add("h-divide500", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide500);
- inst_dict.Add("h-divide1000", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide1000);
- inst_dict.Add("h-divide5000", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide5000);
- inst_dict.Add("h-divide10000", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide10000);
- inst_dict.Add("h-divide50000", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide50000);
- inst_dict.Add("h-divide0.5", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_5);
- inst_dict.Add("h-divide0.1", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_1);
- inst_dict.Add("h-divide0.05", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_05);
- inst_dict.Add("h-divide0.01", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_01);
- inst_dict.Add("h-divide0.001", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_001);
-
- // High-level instructions
- inst_dict.Add("repro", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-A", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-B", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-C", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-D", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-E", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-F", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-G", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-H", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-I", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-J", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-K", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-L", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-M", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-N", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-O", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-P", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-Q", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-R", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-S", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-T", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-U", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-V", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-W", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-X", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-Y", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-Z", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
-
- // Placebo instructions
- // nop-x (included with nops)
- inst_dict.Add("skip", (tHardwareMethod) &cHardwareCPU::Inst_Skip);
-#endif /* !USE_INST_SET_CODE */
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
tDictionary<int> nop_dict;
for(int i=0; i<inst_set.GetInstLib()->GetNumNops(); i++)
nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
@@ -370,8 +124,6 @@
tDictionary<int> inst_dict;
for(int i=0; i<inst_set.GetInstLib()->GetSize(); i++)
inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
- /* XXX end */
-#endif /* USE_INST_SET_CODE */
// And load it on up!
LoadInstSet(filename, inst_set, nop_dict, inst_dict);
@@ -381,299 +133,9 @@
{
// Nops (or other modifying-instructions...) Note: Nops must be the
// first instructions added to the set.
-#ifndef USE_INST_SET_CODE
- tDictionary< int > nop_dict;
- nop_dict.Add("Nop-A", REG_AX);
- nop_dict.Add("Nop-B", REG_BX);
- nop_dict.Add("Nop-C", REG_CX);
- nop_dict.Add("Nop-D", REG_DX);
-#endif /* !USE_INST_SET_CODE */
// Build a dictionary of instructions and their corresponding methods...
-#ifndef USE_INST_SET_CODE
- tDictionary< tHardwareMethod > inst_dict;
-
- // Remaining instructions.
- //1
- //inst_dict.Add("nop-A", &cHardware4Stack::Inst_Nop),
- //2
- //inst_dict.Add("nop-B", &cHardware4Stack::Inst_Nop),
- //3
- //inst_dict.Add("nop-C", &cHardware4Stack::Inst_Nop),
- //4 - not implemented yet...
- //inst_dict.Add("nop-D", &cHardware4Stack::Inst_Nop),
- //5
- inst_dict.Add("Nop-X", (tHardwareMethod) &cHardware4Stack::Inst_Nop);
- //6
- inst_dict.Add("Val-Shift-R", (tHardwareMethod) &cHardware4Stack::Inst_ShiftR);
- //7
- inst_dict.Add("Val-Shift-L", (tHardwareMethod) &cHardware4Stack::Inst_ShiftL);
- //8
- inst_dict.Add("Val-Nand", (tHardwareMethod) &cHardware4Stack::Inst_Nand);
- //9
- inst_dict.Add("Val-Add", (tHardwareMethod) &cHardware4Stack::Inst_Add);
- //10
- inst_dict.Add("Val-Sub", (tHardwareMethod) &cHardware4Stack::Inst_Sub);
- //11
- inst_dict.Add("Val-Mult", (tHardwareMethod) &cHardware4Stack::Inst_Mult);
- //12
- inst_dict.Add("Val-Div", (tHardwareMethod) &cHardware4Stack::Inst_Div);
- //13
- inst_dict.Add("SetMemory", (tHardwareMethod) &cHardware4Stack::Inst_MaxAlloc);
- //14
- inst_dict.Add("Divide", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide);
- //15
- inst_dict.Add("Inst-Read", (tHardwareMethod) &cHardware4Stack::Inst_HeadRead);
- //16
- inst_dict.Add("Inst-Write", (tHardwareMethod) &cHardware4Stack::Inst_HeadWrite);
- //keeping this one for the transition period
- inst_dict.Add("Inst-Copy", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy);
- //17
- inst_dict.Add("If-Equal", (tHardwareMethod) &cHardware4Stack::Inst_IfEqu);
- //18
- inst_dict.Add("If-Not-Equal", (tHardwareMethod) &cHardware4Stack::Inst_IfNEqu);
- //19
- inst_dict.Add("If-Less", (tHardwareMethod) &cHardware4Stack::Inst_IfLess);
- //20
- inst_dict.Add("If-Greater", (tHardwareMethod) &cHardware4Stack::Inst_IfGr);
- //21
- inst_dict.Add("Head-Push", (tHardwareMethod) &cHardware4Stack::Inst_HeadPush);
- //22
- inst_dict.Add("Head-Pop", (tHardwareMethod) &cHardware4Stack::Inst_HeadPop);
- //23
- inst_dict.Add("Head-Move", (tHardwareMethod) &cHardware4Stack::Inst_MoveHead);
- //24
- inst_dict.Add("Search", (tHardwareMethod) &cHardware4Stack::Inst_HeadSearch);
- //25
- inst_dict.Add("Push-Next", (tHardwareMethod) &cHardware4Stack::Inst_PushA);
- //26
- inst_dict.Add("Push-Prev", (tHardwareMethod) &cHardware4Stack::Inst_PushB);
- //27
- inst_dict.Add("Push-Comp", (tHardwareMethod) &cHardware4Stack::Inst_PushC);
- //28 - Not implemented yet...
- //inst_dict.Add("Val-Delete", &cHardware4Stack::Inst_ValDelete
- //29
- inst_dict.Add("Val-Copy", (tHardwareMethod) &cHardware4Stack::Inst_CopyReg);
- //30
- inst_dict.Add("ThreadFork", (tHardwareMethod) &cHardware4Stack::Inst_ForkThread);
- //31
- inst_dict.Add("if-label", (tHardwareMethod) &cHardware4Stack::Inst_IfLabel);
- //32
- inst_dict.Add("Val-Inc", (tHardwareMethod) &cHardware4Stack::Inst_Inc);
- //33
- inst_dict.Add("Val-Dec", (tHardwareMethod) &cHardware4Stack::Inst_Dec);
- //34
- inst_dict.Add("Val-Mod", (tHardwareMethod) &cHardware4Stack::Inst_Mod);
- //35
- inst_dict.Add("ThreadKill", (tHardwareMethod) &cHardware4Stack::Inst_KillThread);/*
- // Remaining instructions.
- inst_dict.Add("nop-X", (tHardwareMethod) &cHardware4Stack::Inst_Nop);
- inst_dict.Add("if-equ-0", (tHardwareMethod) &cHardware4Stack::Inst_If0);
- inst_dict.Add("if-not-0", (tHardwareMethod) &cHardware4Stack::Inst_IfNot0);
- inst_dict.Add("if-n-equ", (tHardwareMethod) &cHardware4Stack::Inst_IfNEqu);
- inst_dict.Add("if-equ", (tHardwareMethod) &cHardware4Stack::Inst_IfEqu);
- inst_dict.Add("if-grt-0", (tHardwareMethod) &cHardware4Stack::Inst_IfGr0);
- inst_dict.Add("if-grt", (tHardwareMethod) &cHardware4Stack::Inst_IfGr);
- inst_dict.Add("if->=-0", (tHardwareMethod) &cHardware4Stack::Inst_IfGrEqu0);
- inst_dict.Add("if->=", (tHardwareMethod) &cHardware4Stack::Inst_IfGrEqu);
- inst_dict.Add("if-les-0", (tHardwareMethod) &cHardware4Stack::Inst_IfLess0);
- inst_dict.Add("if-less", (tHardwareMethod) &cHardware4Stack::Inst_IfLess);
- inst_dict.Add("if-<=-0", (tHardwareMethod) &cHardware4Stack::Inst_IfLsEqu0);
- inst_dict.Add("if-<=", (tHardwareMethod) &cHardware4Stack::Inst_IfLsEqu);
- inst_dict.Add("if-A!=B", (tHardwareMethod) &cHardware4Stack::Inst_IfANotEqB);
- inst_dict.Add("if-B!=C", (tHardwareMethod) &cHardware4Stack::Inst_IfBNotEqC);
- inst_dict.Add("if-A!=C", (tHardwareMethod) &cHardware4Stack::Inst_IfANotEqC);
-
- inst_dict.Add("if-bit-1", (tHardwareMethod) &cHardware4Stack::Inst_IfBit1);
- inst_dict.Add("jump-f", (tHardwareMethod) &cHardware4Stack::Inst_JumpF);
- inst_dict.Add("jump-b", (tHardwareMethod) &cHardware4Stack::Inst_JumpB);
- inst_dict.Add("jump-p", (tHardwareMethod) &cHardware4Stack::Inst_JumpP);
- inst_dict.Add("jump-slf", (tHardwareMethod) &cHardware4Stack::Inst_JumpSelf);
- inst_dict.Add("call", (tHardwareMethod) &cHardware4Stack::Inst_Call);
- inst_dict.Add("return", (tHardwareMethod) &cHardware4Stack::Inst_Return);
-
- inst_dict.Add("pop", (tHardwareMethod) &cHardware4Stack::Inst_Pop);
- inst_dict.Add("push", (tHardwareMethod) &cHardware4Stack::Inst_Push);
- inst_dict.Add("swap-stk",(tHardwareMethod) &cHardware4Stack::Inst_SwitchStack);
- inst_dict.Add("flip-stk",(tHardwareMethod) &cHardware4Stack::Inst_FlipStack);
- inst_dict.Add("swap", (tHardwareMethod) &cHardware4Stack::Inst_Swap);
- inst_dict.Add("swap-AB", (tHardwareMethod) &cHardware4Stack::Inst_SwapAB);
- inst_dict.Add("swap-BC", (tHardwareMethod) &cHardware4Stack::Inst_SwapBC);
- inst_dict.Add("swap-AC", (tHardwareMethod) &cHardware4Stack::Inst_SwapAC);
- inst_dict.Add("copy-reg",(tHardwareMethod) &cHardware4Stack::Inst_CopyReg);
- inst_dict.Add("set_A=B", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegAB);
- inst_dict.Add("set_A=C", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegAC);
- inst_dict.Add("set_B=A", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegBA);
- inst_dict.Add("set_B=C", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegBC);
- inst_dict.Add("set_C=A", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegCA);
- inst_dict.Add("set_C=B", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegCB);
- inst_dict.Add("reset", (tHardwareMethod) &cHardware4Stack::Inst_Reset);
-
- inst_dict.Add("pop-A", (tHardwareMethod) &cHardware4Stack::Inst_PopA);
- inst_dict.Add("pop-B", (tHardwareMethod) &cHardware4Stack::Inst_PopB);
- inst_dict.Add("pop-C", (tHardwareMethod) &cHardware4Stack::Inst_PopC);
- // inst_dict.Add("push-A", (tHardwareMethod) &cHardware4Stack::Inst_PushA);
- inst_dict.Add("push-B", (tHardwareMethod) &cHardware4Stack::Inst_PushB);
- inst_dict.Add("push-C", (tHardwareMethod) &cHardware4Stack::Inst_PushC);
-
- inst_dict.Add("shift-r", (tHardwareMethod) &cHardware4Stack::Inst_ShiftR);
- inst_dict.Add("shift-l", (tHardwareMethod) &cHardware4Stack::Inst_ShiftL);
- inst_dict.Add("bit-1", (tHardwareMethod) &cHardware4Stack::Inst_Bit1);
- inst_dict.Add("set-num", (tHardwareMethod) &cHardware4Stack::Inst_SetNum);
- inst_dict.Add("inc", (tHardwareMethod) &cHardware4Stack::Inst_Inc);
- inst_dict.Add("dec", (tHardwareMethod) &cHardware4Stack::Inst_Dec);
- inst_dict.Add("zero", (tHardwareMethod) &cHardware4Stack::Inst_Zero);
- inst_dict.Add("neg", (tHardwareMethod) &cHardware4Stack::Inst_Neg);
- inst_dict.Add("square", (tHardwareMethod) &cHardware4Stack::Inst_Square);
- inst_dict.Add("sqrt", (tHardwareMethod) &cHardware4Stack::Inst_Sqrt);
- inst_dict.Add("not", (tHardwareMethod) &cHardware4Stack::Inst_Not);
- inst_dict.Add("log", (tHardwareMethod) &cHardware4Stack::Inst_Log);
- inst_dict.Add("log10", (tHardwareMethod) &cHardware4Stack::Inst_Log10);
- inst_dict.Add("minus-18",(tHardwareMethod) &cHardware4Stack::Inst_Minus18);
-
- inst_dict.Add("add", (tHardwareMethod) &cHardware4Stack::Inst_Add);
- inst_dict.Add("sub", (tHardwareMethod) &cHardware4Stack::Inst_Sub);
- inst_dict.Add("mult", (tHardwareMethod) &cHardware4Stack::Inst_Mult);
- inst_dict.Add("div", (tHardwareMethod) &cHardware4Stack::Inst_Div);
- inst_dict.Add("mod", (tHardwareMethod) &cHardware4Stack::Inst_Mod);
- inst_dict.Add("nand", (tHardwareMethod) &cHardware4Stack::Inst_Nand);
- inst_dict.Add("nor", (tHardwareMethod) &cHardware4Stack::Inst_Nor);
- inst_dict.Add("and", (tHardwareMethod) &cHardware4Stack::Inst_And);
- inst_dict.Add("order", (tHardwareMethod) &cHardware4Stack::Inst_Order);
- inst_dict.Add("xor", (tHardwareMethod) &cHardware4Stack::Inst_Xor);
-
- inst_dict.Add("copy", (tHardwareMethod)&cHardware4Stack::Inst_Copy);
- inst_dict.Add("read", (tHardwareMethod)&cHardware4Stack::Inst_ReadInst);
- inst_dict.Add("write", (tHardwareMethod)&cHardware4Stack::Inst_WriteInst);
- inst_dict.Add("stk-read",(tHardwareMethod)&cHardware4Stack::Inst_StackReadInst);
- inst_dict.Add("stk-writ",(tHardwareMethod)&cHardware4Stack::Inst_StackWriteInst);
-
- inst_dict.Add("compare", (tHardwareMethod) &cHardware4Stack::Inst_Compare);
- inst_dict.Add("if-n-cpy", (tHardwareMethod) &cHardware4Stack::Inst_IfNCpy);
- inst_dict.Add("allocate", (tHardwareMethod) &cHardware4Stack::Inst_Allocate);
- inst_dict.Add("divide", (tHardwareMethod) &cHardware4Stack::Inst_Divide);
- inst_dict.Add("c-alloc", (tHardwareMethod) &cHardware4Stack::Inst_CAlloc);
- inst_dict.Add("c-divide", (tHardwareMethod) &cHardware4Stack::Inst_CDivide);
- inst_dict.Add("inject", (tHardwareMethod) &cHardware4Stack::Inst_Inject);
- inst_dict.Add("inject-r", (tHardwareMethod) &cHardware4Stack::Inst_InjectRand);
- inst_dict.Add("inject-th", (tHardwareMethod) &cHardware4Stack::Inst_InjectThread);
-
- inst_dict.Add("get", (tHardwareMethod)&cHardware4Stack::Inst_TaskGet);
- inst_dict.Add("stk-get", (tHardwareMethod)&cHardware4Stack::Inst_TaskStackGet);
- inst_dict.Add("stk-load",(tHardwareMethod)&cHardware4Stack::Inst_TaskStackLoad);
- inst_dict.Add("put", (tHardwareMethod)&cHardware4Stack::Inst_TaskPut);
- inst_dict.Add("IO", (tHardwareMethod)&cHardware4Stack::Inst_TaskIO);
- inst_dict.Add("search-f",(tHardwareMethod)&cHardware4Stack::Inst_SearchF);
- inst_dict.Add("search-b",(tHardwareMethod)&cHardware4Stack::Inst_SearchB);
- inst_dict.Add("mem-size",(tHardwareMethod)&cHardware4Stack::Inst_MemSize);
-
- inst_dict.Add("rotate-l", (tHardwareMethod) &cHardware4Stack::Inst_RotateL);
- inst_dict.Add("rotate-r", (tHardwareMethod) &cHardware4Stack::Inst_RotateR);
-
- inst_dict.Add("set-cmut", (tHardwareMethod) &cHardware4Stack::Inst_SetCopyMut);
- inst_dict.Add("mod-cmut", (tHardwareMethod) &cHardware4Stack::Inst_ModCopyMut);
-
- // Threading instructions
- inst_dict.Add("fork-th", (tHardwareMethod) &cHardware4Stack::Inst_ForkThread);
- inst_dict.Add("kill-th", (tHardwareMethod) &cHardware4Stack::Inst_KillThread);
- inst_dict.Add("id-th", (tHardwareMethod) &cHardware4Stack::Inst_ThreadID);
-
- // Head-based instructions
- inst_dict.Add("h-alloc", (tHardwareMethod) &cHardware4Stack::Inst_MaxAlloc);
- inst_dict.Add("h-divide", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide);
- inst_dict.Add("h-read", (tHardwareMethod) &cHardware4Stack::Inst_HeadRead);
- inst_dict.Add("h-write", (tHardwareMethod) &cHardware4Stack::Inst_HeadWrite);
- inst_dict.Add("h-copy", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy);
- inst_dict.Add("h-search", (tHardwareMethod) &cHardware4Stack::Inst_HeadSearch);
- inst_dict.Add("h-push", (tHardwareMethod) &cHardware4Stack::Inst_HeadPush);
- inst_dict.Add("h-pop", (tHardwareMethod) &cHardware4Stack::Inst_HeadPop);
- inst_dict.Add("set-head", (tHardwareMethod) &cHardware4Stack::Inst_SetHead);
- inst_dict.Add("adv-head", (tHardwareMethod) &cHardware4Stack::Inst_AdvanceHead);
- inst_dict.Add("mov-head", (tHardwareMethod) &cHardware4Stack::Inst_MoveHead);
- inst_dict.Add("jmp-head", (tHardwareMethod) &cHardware4Stack::Inst_JumpHead);
- inst_dict.Add("get-head", (tHardwareMethod) &cHardware4Stack::Inst_GetHead);
- inst_dict.Add("if-label", (tHardwareMethod) &cHardware4Stack::Inst_IfLabel);
- inst_dict.Add("set-flow", (tHardwareMethod) &cHardware4Stack::Inst_SetFlow);
-
- inst_dict.Add("h-copy2", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy2);
- inst_dict.Add("h-copy3", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy3);
- inst_dict.Add("h-copy4", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy4);
- inst_dict.Add("h-copy5", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy5);
- inst_dict.Add("h-copy6", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy6);
- inst_dict.Add("h-copy7", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy7);
- inst_dict.Add("h-copy8", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy8);
- inst_dict.Add("h-copy9", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy9);
- inst_dict.Add("h-copy10", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy10);
-
-
- inst_dict.Add("divide-sex", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivideSex);
- inst_dict.Add("divide-asex", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide1);
-
- inst_dict.Add("h-divide1", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide1);
- inst_dict.Add("h-divide2", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide2);
- inst_dict.Add("h-divide3", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide3);
- inst_dict.Add("h-divide4", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide4);
- inst_dict.Add("h-divide5", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide5);
- inst_dict.Add("h-divide6", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide6);
- inst_dict.Add("h-divide7", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide7);
- inst_dict.Add("h-divide8", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide8);
- inst_dict.Add("h-divide9", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide9);
- inst_dict.Add("h-divide10", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide10);
- inst_dict.Add("h-divide16", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide16);
- inst_dict.Add("h-divide32", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide32);
- inst_dict.Add("h-divide50", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide50);
- inst_dict.Add("h-divide100", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide100);
- inst_dict.Add("h-divide500", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide500);
- inst_dict.Add("h-divide1000", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide1000);
- inst_dict.Add("h-divide5000", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide5000);
- inst_dict.Add("h-divide10000", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide10000);
- inst_dict.Add("h-divide50000", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide50000);
- inst_dict.Add("h-divide0.5", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_5);
- inst_dict.Add("h-divide0.1", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_1);
- inst_dict.Add("h-divide0.05", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_05);
- inst_dict.Add("h-divide0.01", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_01);
- inst_dict.Add("h-divide0.001", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_001);
-
- // High-level instructions
- inst_dict.Add("repro", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-A", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-B", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-C", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-D", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-E", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-F", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-G", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-H", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-I", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-J", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-K", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-L", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-M", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-N", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-O", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-P", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-Q", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-R", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-S", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-T", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-U", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-V", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-W", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-X", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-Y", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-Z", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
-
- // Placebo instructions
- // nop-x (included with nops)
- inst_dict.Add("skip", (tHardwareMethod) &cHardware4Stack::Inst_Skip);
- */
- cout << "BLEE! Instruction Library in util has " << inst_dict.GetSize()
- << " instructions + " << nop_dict.GetSize() << " nops." << endl;
-
-#endif /* !USE_INST_SET_CODE */
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
tDictionary<int> nop_dict;
for(int i=0; i<inst_set.GetInstLib()->GetNumNops(); i++)
nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
@@ -681,8 +143,6 @@
tDictionary<int> inst_dict;
for(int i=0; i<inst_set.GetInstLib()->GetSize(); i++)
inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
- /* XXX end */
-#endif /* USE_INST_SET_CODE */
cout << "Instruction Library in util has " << inst_dict.GetSize()
<< " instructions and " << nop_dict.GetSize() << " nops." << endl;
@@ -700,15 +160,11 @@
// set it up.
if (inst_filename != "" && inst_set.GetSize() == 0) {
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
-#ifdef USE_INST_SET_CODE
inst_set.SetInstLib(cHardwareCPU::GetInstLib());
-#endif /* USE_INST_SET_CODE */
LoadInstSet_CPUOriginal(inst_filename, inst_set);
}
else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
-#ifdef USE_INST_SET_CODE
inst_set.SetInstLib(cHardware4Stack::GetInstLib());
-#endif /* USE_INST_SET_CODE */
LoadInstSet_CPU4Stack(inst_filename, inst_set);
}
}
Index: avida/current/source/main/analyze.cc
diff -u avida/current/source/main/analyze.cc:1.73 avida/current/source/main/analyze.cc:1.74
--- avida/current/source/main/analyze.cc:1.73 Mon May 26 21:21:55 2003
+++ avida/current/source/main/analyze.cc Fri Jun 13 14:49:59 2003
@@ -1806,8 +1806,6 @@
}
cInstSet map_inst_set(inst_set);
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
// Locate instruction corresponding to "NULL" in the instruction library.
{
const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
@@ -1824,12 +1822,6 @@
map_inst_set.Add2(inst_lib_null_inst.GetOp());
}
const cInstruction null_inst = map_inst_set.GetInst("NULL");
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- // Build an empty instruction into the instruction set.
- map_inst_set.Add("NULL", &cHardwareBase::Inst_Nop);
- const cInstruction null_inst = map_inst_set.GetInst("NULL");
-#endif /* USE_INST_SET_CODE */
// Loop through all the lines of code, testing the removal of each.
for (int line_num = 0; line_num < max_line; line_num++) {
@@ -2016,8 +2008,6 @@
// Build an empty instruction into the an instruction library.
cInstSet map_inst_set(inst_set);
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
// Locate instruction corresponding to "NULL" in the instruction library.
{
const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
@@ -2034,12 +2024,6 @@
map_inst_set.Add2(inst_lib_null_inst.GetOp());
}
const cInstruction null_inst = map_inst_set.GetInst("NULL");
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- // Build an empty instruction into the instruction set.
- map_inst_set.Add("NULL", &cHardwareBase::Inst_Nop);
- const cInstruction null_inst = map_inst_set.GetInst("NULL");
-#endif /* USE_INST_SET_CODE */
cString color_string; // For coloring cells...
Index: avida/current/source/main/avida.cc
diff -u avida/current/source/main/avida.cc:1.42 avida/current/source/main/avida.cc:1.43
--- avida/current/source/main/avida.cc:1.42 Fri May 23 04:43:22 2003
+++ avida/current/source/main/avida.cc Fri Jun 13 14:49:59 2003
@@ -82,16 +82,12 @@
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
-#ifdef USE_INST_SET_CODE
environment.GetInstSet().SetInstLib(cHardwareCPU::GetInstLib());
-#endif /* USE_INST_SET_CODE */
cHardwareUtil::LoadInstSet_CPUOriginal(cConfig::GetInstFilename(),
environment.GetInstSet());
}
else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
-#ifdef USE_INST_SET_CODE
environment.GetInstSet().SetInstLib(cHardware4Stack::GetInstLib());
-#endif /* USE_INST_SET_CODE */
cHardwareUtil::LoadInstSet_CPU4Stack(cConfig::GetInstFilename(),
environment.GetInstSet());
}
Index: avida/current/source/main/inst_set.cc
diff -u avida/current/source/main/inst_set.cc:1.3 avida/current/source/main/inst_set.cc:1.4
--- avida/current/source/main/inst_set.cc:1.3 Mon May 26 21:21:56 2003
+++ avida/current/source/main/inst_set.cc Fri Jun 13 14:49:59 2003
@@ -18,21 +18,13 @@
//////////////////////
// Initialize static variables
-/* XXX start -- kgn */
-#ifdef USE_INST_SET_CODE
cInstruction cInstSet::inst_default2( 0 );
cInstruction cInstSet::inst_error2 ( 255 );
-#else /* USE_INST_SET_CODE */
-/* XXX end */
-const cInstruction cInstSet::inst_default( 0 );
-const cInstruction cInstSet::inst_error ( 255 );
-#endif /* USE_INST_SET_CODE */
cInstSet::cInstSet()
{
}
-#ifdef USE_INST_SET_CODE
cInstSet::cInstSet(const cInstSet & in_inst_set)
: m_inst_lib(in_inst_set.m_inst_lib)
, m_lib_name_map(in_inst_set.m_lib_name_map)
@@ -40,14 +32,6 @@
, mutation_chart2(in_inst_set.mutation_chart2)
{
}
-#else /* USE_INST_SET_CODE */
-cInstSet::cInstSet(const cInstSet & in_inst_set)
- : inst_array(in_inst_set.inst_array)
- , nop_mods(in_inst_set.nop_mods)
- , mutation_chart(in_inst_set.mutation_chart)
-{
-}
-#endif /* USE_INST_SET_CODE */
cInstSet::~cInstSet()
{
@@ -55,25 +39,15 @@
cInstSet & cInstSet::operator=(const cInstSet & _in)
{
- /* XXX start -- kgn */
-#ifdef USE_INST_SET_CODE
m_inst_lib = _in.m_inst_lib;
m_lib_name_map = _in.m_lib_name_map;
m_lib_nopmod_map = _in.m_lib_nopmod_map;
mutation_chart2 = _in.mutation_chart2;
-#else /* USE_INST_SET_CODE */
- /* XXX end */
- inst_array = _in.inst_array;
- nop_mods = _in.nop_mods;
- mutation_chart = _in.mutation_chart;
-#endif /* USE_INST_SET_CODE */
return *this;
}
bool cInstSet::OK() const
{
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
assert(m_lib_name_map.GetSize() < 256);
assert(m_lib_nopmod_map.GetSize() < m_lib_name_map.GetSize());
@@ -88,42 +62,16 @@
for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
assert(m_lib_name_map[i].redundancy == test_redundancy2[i]);
}
- /* XXX end */
-#else /* USE_INST_SET_CODE */
-
- // assert(inst_array.OK());
- // assert(nop_mods.OK());
- assert(inst_array.GetSize() < 256);
- assert(nop_mods.GetSize() < inst_array.GetSize());
-
- // Make sure that all of the redundancies are represented the appropriate
- // number of times.
- tArray<int> test_redundancy(inst_array.GetSize());
- test_redundancy.SetAll(0);
- for (int i = 0; i < mutation_chart.GetSize(); i++) {
- int test_id = mutation_chart[i];
- test_redundancy[test_id]++;
- }
- for (int i = 0; i < inst_array.GetSize(); i++) {
- assert(inst_array[i].redundancy == test_redundancy[i]);
- }
-#endif /* USE_INST_SET_CODE */
return true;
}
cInstruction cInstSet::GetRandomInst() const
{
-#ifdef USE_INST_SET_CODE
int inst_op = mutation_chart2[g_random.GetUInt(mutation_chart2.GetSize())];
-#else /* USE_INST_SET_CODE */
- int inst_op = mutation_chart[g_random.GetUInt(mutation_chart.GetSize())];
-#endif /* USE_INST_SET_CODE */
return cInstruction(inst_op);
}
-/**/
-#ifdef USE_INST_SET_CODE
int cInstSet::Add2(
const int lib_fun_id,
const int redundancy,
@@ -173,65 +121,14 @@
return inst_id;
}
-#else /* USE_INST_SET_CODE */
-/**/
-
-int cInstSet::Add(const cString & _name, tHardwareMethod _fun,
- const int redundancy, const int ft_cost, const int cost,
- const double prob_fail)
-{
- const int inst_id = inst_array.GetSize();
-
- assert(inst_id < 255);
-
- // Increase the size of the array...
- inst_array.Resize(inst_id + 1);
-
- // Setup the new function...
- inst_array[inst_id].name = _name;
- inst_array[inst_id].function = _fun;
- inst_array[inst_id].redundancy = redundancy;
- inst_array[inst_id].cost = cost;
- inst_array[inst_id].ft_cost = ft_cost;
- inst_array[inst_id].prob_fail = prob_fail;
-
- const int total_redundancy = mutation_chart.GetSize();
- mutation_chart.Resize(total_redundancy + redundancy);
- for (int i = 0; i < redundancy; i++) {
- mutation_chart[total_redundancy + i] = inst_id;
- }
-
- return inst_id;
-}
-
-int cInstSet::AddNop(const cString & _name, tHardwareMethod _fun,
- const int reg, const int redundancy, const int ft_cost,
- const int cost, const double prob_fail)
-{
- // Assert nops are at the _beginning_ of an inst_set.
- assert(inst_array.GetSize() == nop_mods.GetSize());
-
- const int inst_id = Add(_name, _fun, redundancy, ft_cost, cost, prob_fail);
-
- nop_mods.Resize(inst_id + 1);
- nop_mods[inst_id] = reg;
-
- return inst_id;
-}
-#endif /* USE_INST_SET_CODE */
cString cInstSet::FindBestMatch(const cString & in_name) const
{
int best_dist = 1024;
cString best_name("");
-#ifdef USE_INST_SET_CODE
for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
const cString & cur_name = m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id);
-#else /* USE_INST_SET_CODE */
- for (int i = 0; i < inst_array.GetSize(); i++) {
- const cString & cur_name = inst_array[i].name;
-#endif /* USE_INST_SET_CODE */
const int cur_dist = cStringUtil::EditDistance(cur_name, in_name);
if (cur_dist < best_dist) {
best_dist = cur_dist;
Index: avida/current/source/main/inst_set.hh
diff -u avida/current/source/main/inst_set.hh:1.2 avida/current/source/main/inst_set.hh:1.3
--- avida/current/source/main/inst_set.hh:1.2 Fri May 23 04:43:22 2003
+++ avida/current/source/main/inst_set.hh Fri Jun 13 14:49:59 2003
@@ -35,7 +35,6 @@
**/
class cInstSet {
-#ifdef USE_INST_SET_CODE
public:
cInstLibBase *m_inst_lib;
class cInstEntry2 {
@@ -53,23 +52,6 @@
static cInstruction inst_error2;
// static const cInstruction inst_none;
static cInstruction inst_default2;
-#else /* USE_INST_SET_CODE */
-private:
- // This class gives full info about a single instruction in the library.
- class cInstEntry {
- public:
- cString name; // Name of this instruction.
- tHardwareMethod function; // Pointer to hardware method.
- int redundancy; // Weight in instruction set (not impl.)
- int cost; // additional time spent to exectute inst.
- int ft_cost; // time spent first time exec (in add to cost)
- double prob_fail; // probability of failing to execute inst
- };
-
- tArray<cInstEntry> inst_array; // The instructions indexed by ID
- tArray<int> nop_mods; // Modification table for nops
- tArray<int> mutation_chart; // ID's represented by redundancy values.
-#endif /* USE_INST_SET_CODE */
// Static components...
static const cInstruction inst_error;
@@ -88,13 +70,7 @@
// Accessors
const cString & GetName(int id) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_inst_lib->GetName(m_lib_name_map[id].lib_fun_id);
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array[id].name;
-#endif /* USE_INST_SET_CODE */
}
const cString & GetName(const cInstruction & inst) const
{
@@ -102,116 +78,51 @@
}
int GetCost(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map[inst.GetOp()].cost;
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array[inst.GetOp()].cost;
-#endif /* USE_INST_SET_CODE */
}
int GetFTCost(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map[inst.GetOp()].ft_cost;
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array[inst.GetOp()].ft_cost;
-#endif /* USE_INST_SET_CODE */
}
double GetProbFail(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map[inst.GetOp()].prob_fail;
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array[inst.GetOp()].prob_fail;
-#endif /* USE_INST_SET_CODE */
}
int GetRedundancy(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map[inst.GetOp()].redundancy;
-#else /* USE_INST_SET_CODE */
- ///* XXX end */
- return inst_array[inst.GetOp()].redundancy;
-#endif /* USE_INST_SET_CODE */
}
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int GetLibFunctionIndex(const cInstruction & inst) const
{
return m_lib_name_map[inst.GetOp()].lib_fun_id;
}
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- tHardwareMethod GetFunction(const cInstruction & inst) const
- {
- return inst_array[inst.GetOp()].function;
- }
-#endif /* USE_INST_SET_CODE */
int GetNopMod(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_inst_lib->GetNopMod(m_lib_nopmod_map[inst.GetOp()]);
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return nop_mods[inst.GetOp()];
-#endif /* USE_INST_SET_CODE */
}
cInstruction GetRandomInst() const;
-#ifdef USE_INST_SET_CODE
int GetRandFunctionIndex() const
{
return m_lib_name_map[ GetRandomInst().GetOp() ].lib_fun_id;
}
-#else /* USE_INST_SET_CODE */
- tHardwareMethod GetRandFunction() const
- {
- return inst_array[ GetRandomInst().GetOp() ].function;
- }
-#endif /* USE_INST_SET_CODE */
int GetSize() const {
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map.GetSize();
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array.GetSize();
-#endif /* USE_INST_SET_CODE */
}
int GetNumNops() const {
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_nopmod_map.GetSize();
-#else /* USE_INST_SET_CODE */
- ///* XXX end */
- return nop_mods.GetSize();
-#endif /* USE_INST_SET_CODE */
}
// Instruction Analysis.
int IsNop(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return (inst.GetOp() < m_lib_nopmod_map.GetSize());
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return (inst.GetOp() < nop_mods.GetSize());
-#endif /* USE_INST_SET_CODE */
}
// Insertion of new instructions...
-#ifdef USE_INST_SET_CODE
int Add2(
const int lib_fun_id,
const int redundancy=1,
@@ -226,16 +137,7 @@
const int cost=0,
const double prob_fail=0.0
);
-#else /* USE_INST_SET_CODE */
- int Add(const cString & _name, tHardwareMethod _fun, const int redundancy=1,
- const int ft_cost=0, const int cost=0, const double prob_fail=0.0);
- int AddNop(const cString & _name, tHardwareMethod _fun, const int reg,
- const int redundancy=1, const int ft_cost=0, const int cost=0,
- const double prob_fail=0.0);
-#endif /* USE_INST_SET_CODE */
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
// accessors for instruction library
cInstLibBase *GetInstLib(){ return m_inst_lib; }
void SetInstLib(cInstLibBase *inst_lib){
@@ -243,34 +145,16 @@
inst_error2 = inst_lib->GetInstError();
inst_default2 = inst_lib->GetInstDefault();
}
- /* XXX end */
-#endif /* USE_INST_SET_CODE */
inline cInstruction GetInst(const cString & in_name) const;
cString FindBestMatch(const cString & in_name) const;
// Static methods..
static const cInstruction & GetInstDefault() {
-#ifdef USE_INST_SET_CODE
- /* XXX start --- kgn */
- //if(inst_default != inst_default2)
- //{ std::cout << "<cInstSet::GetInstDefault> mismatch!" << std::endl; }
return inst_default2;
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_default;
-#endif /* USE_INST_SET_CODE */
}
static const cInstruction & GetInstError() {
- /* XXX start --- kgn */
- //if(inst_error != inst_error2)
- //{ std::cout << "<cInstSet::GetInstError> mismatch!" << std::endl; }
-#ifdef USE_INST_SET_CODE
return inst_error2;
-#else /* USE_INST_SET_CODE */
- /* XXX end */
- return inst_error;
-#endif /* USE_INST_SET_CODE */
}
// static const cInstruction & GetInstNone() { return inst_none; }
};
@@ -278,7 +162,6 @@
inline cInstruction cInstSet::GetInst(const cString & in_name) const
{
-#ifdef USE_INST_SET_CODE
for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
if (m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id) == in_name) {
return cInstruction(i);
@@ -291,15 +174,6 @@
-- kgn
*/
return cInstruction(0);
-#else /* USE_INST_SET_CODE */
- /* XXX start --- kgn */
- for (int i = 0; i < inst_array.GetSize(); i++) {
- if (inst_array[i].name == in_name) return cInstruction(i);
- }
- // assert(false); // Requesting ID for unknown inst.
- return cInstSet::GetInstError();
- /* XXX end */
-#endif /* USE_INST_SET_CODE */
}
Index: avida/current/source/qt-viewer/setup_avida.cc
diff -u avida/current/source/qt-viewer/setup_avida.cc:1.22 avida/current/source/qt-viewer/setup_avida.cc:1.23
--- avida/current/source/qt-viewer/setup_avida.cc:1.22 Fri May 23 04:43:40 2003
+++ avida/current/source/qt-viewer/setup_avida.cc Fri Jun 13 14:49:59 2003
@@ -80,16 +80,12 @@
}
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
-#ifdef USE_INST_SET_CODE
environment.GetInstSet().SetInstLib(cHardwareCPU::GetInstLib());
-#endif /* USE_INST_SET_CODE */
cHardwareUtil::LoadInstSet_CPUOriginal(cConfig::GetInstFilename(),
environment.GetInstSet());
}
else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
-#ifdef USE_INST_SET_CODE
environment.GetInstSet().SetInstLib(cHardware4Stack::GetInstLib());
-#endif /* USE_INST_SET_CODE */
cHardwareUtil::LoadInstSet_CPU4Stack(cConfig::GetInstFilename(),
environment.GetInstSet());
}
More information about the Avida-cvs
mailing list