[Avida-cvs] [avida-svn] r935 - development/source/cpu

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sat Sep 9 14:32:09 PDT 2006


Author: brysonda
Date: 2006-09-09 17:32:09 -0400 (Sat, 09 Sep 2006)
New Revision: 935

Modified:
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/nHardwareCPU.h
Log:
Fix cHardwareCPU instruction library so that it will not add NOP mods for more than the number of available registers.

Add support for two additional nops for up to 6 total.

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2006-09-08 01:16:43 UTC (rev 934)
+++ development/source/cpu/cHardwareCPU.cc	2006-09-09 21:32:09 UTC (rev 935)
@@ -53,7 +53,9 @@
     cNOPEntryCPU("nop-A", nHardwareCPU::REG_AX),
     cNOPEntryCPU("nop-B", nHardwareCPU::REG_BX),
     cNOPEntryCPU("nop-C", nHardwareCPU::REG_CX),
-    cNOPEntryCPU("nop-D", nHardwareCPU::REG_DX)
+    cNOPEntryCPU("nop-D", nHardwareCPU::REG_DX),
+    cNOPEntryCPU("nop-E", nHardwareCPU::REG_EX),
+    cNOPEntryCPU("nop-F", nHardwareCPU::REG_FX)
   };
   
   struct cInstEntryCPU { 
@@ -80,6 +82,10 @@
                   "No-operation instruction; modifies other instructions"),
     cInstEntryCPU("nop-D",     &cHardwareCPU::Inst_Nop, true,
                   "No-operation instruction; modifies other instructions"),
+    cInstEntryCPU("nop-E",     &cHardwareCPU::Inst_Nop, true,
+                  "No-operation instruction; modifies other instructions"),
+    cInstEntryCPU("nop-F",     &cHardwareCPU::Inst_Nop, true,
+                  "No-operation instruction; modifies other instructions"),
     
     cInstEntryCPU("NULL",      &cHardwareCPU::Inst_Nop, false,
                   "True no-operation instruction: does nothing"),
@@ -343,7 +349,7 @@
   
   static cString n_names[n_size];
   static int nop_mods[n_size];
-  for (int i = 0; i < n_size; i++){
+  for (int i = 0; i < n_size && i < nHardwareCPU::NUM_REGISTERS; i++) {
     n_names[i] = s_n_array[i].name;
     nop_mods[i] = s_n_array[i].nop_mod;
   }
@@ -356,16 +362,7 @@
     functions[i] = s_f_array[i].function;
   }
   
-  cInstLibCPU *inst_lib = new cInstLibCPU(
-                                          n_size,
-                                          f_size,
-                                          n_names,
-                                          f_names,
-                                          nop_mods,
-                                          functions
-                                          );
-  
-  return inst_lib;
+  return new cInstLibCPU(n_size, f_size, n_names, f_names, nop_mods, functions);
 }
 
 cHardwareCPU::cHardwareCPU(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)

Modified: development/source/cpu/nHardwareCPU.h
===================================================================
--- development/source/cpu/nHardwareCPU.h	2006-09-08 01:16:43 UTC (rev 934)
+++ development/source/cpu/nHardwareCPU.h	2006-09-09 21:32:09 UTC (rev 935)
@@ -18,7 +18,7 @@
 namespace nHardwareCPU {
   static const int NUM_REGISTERS = 3;
   
-  enum tRegisters { REG_AX = 0, REG_BX, REG_CX, REG_DX };
+  enum tRegisters { REG_AX = 0, REG_BX, REG_CX, REG_DX, REG_EX, REG_FX };
 
   static const int NUM_NOPS = 3;
 }




More information about the Avida-cvs mailing list