Fix accw opcode.
authorDavid Schleef <ds@schleef.org>
Sun, 26 Jul 2009 05:31:15 +0000 (22:31 -0700)
committerDavid Schleef <ds@schleef.org>
Sun, 26 Jul 2009 05:31:15 +0000 (22:31 -0700)
orc/orcexecutor.c
orc/orcprogram-c.c
orc/orcprogram-sse.c

index a3fc847..db2f83b 100644 (file)
@@ -114,6 +114,9 @@ orc_executor_emulate (OrcExecutor *ex)
   OrcOpcodeExecutor opcode_ex;
 
   ex->accumulators[0] = 0;
+  ex->accumulators[1] = 0;
+  ex->accumulators[2] = 0;
+  ex->accumulators[3] = 0;
 
   memset (&opcode_ex, 0, sizeof(opcode_ex));
 
@@ -190,6 +193,19 @@ orc_executor_emulate (OrcExecutor *ex)
               ORC_ERROR("unhandled size %d", program->vars[insn->dest_args[k]].size);
           }
         } else if (var->vartype == ORC_VAR_TYPE_ACCUMULATOR) {
+          switch (var->size) {
+            case 2:
+              ex->accumulators[insn->dest_args[k] - ORC_VAR_A1] +=
+                opcode_ex.dest_values[k];
+              ex->accumulators[insn->dest_args[k] - ORC_VAR_A1] &= 0xffff;
+              break;
+            case 4:
+              ex->accumulators[insn->dest_args[k] - ORC_VAR_A1] +=
+                opcode_ex.dest_values[k];
+              break;
+            default:
+              ORC_ERROR("unhandled size %d",program->vars[insn->dest_args[k]].size);
+          }
           ex->accumulators[0] += opcode_ex.dest_values[k];
         } else {
           ORC_ERROR("shouldn't be reached (%d)", var->vartype);
index bc66f6d..4368bdc 100644 (file)
@@ -170,8 +170,13 @@ orc_compiler_c_assemble (OrcCompiler *compiler)
     if (var->name == NULL) continue;
     switch (var->vartype) {
       case ORC_VAR_TYPE_ACCUMULATOR:
-        ORC_ASM_CODE(compiler,"  ex->accumulators[%d] = var%d;\n",
-            i - ORC_VAR_A1, i);
+        if (var->size == 2) {
+          ORC_ASM_CODE(compiler,"  ex->accumulators[%d] = (var%d & 0xffff);\n",
+              i - ORC_VAR_A1, i);
+        } else {
+          ORC_ASM_CODE(compiler,"  ex->accumulators[%d] = var%d;\n",
+              i - ORC_VAR_A1, i);
+        }
         break;
       default:
         break;
index 5915a69..3d3df75 100644 (file)
@@ -198,7 +198,8 @@ sse_save_accumulators (OrcCompiler *compiler)
 
         if (compiler->vars[i].size == 2) {
           orc_x86_emit_mov_sse_reg (compiler, src, compiler->gp_tmpreg);
-          orc_x86_emit_mov_reg_memoffset (compiler, 2, compiler->gp_tmpreg,
+          orc_x86_emit_and_imm_reg (compiler, 4, 0xffff, compiler->gp_tmpreg);
+          orc_x86_emit_mov_reg_memoffset (compiler, 4, compiler->gp_tmpreg,
               (int)ORC_STRUCT_OFFSET(OrcExecutor, accumulators[i-ORC_VAR_A1]),
               compiler->exec_reg);
         } else {