Commits

Anonymous committed 0c05d3f

Changed misleading comment in operanddecoder, fixed specifying registers on commandline for tester, and better register display

Comments (0)

Files changed (2)

C/OperandDecoder.c

         xmmregister_t sourceReg;
         void*         sourceMem;  // this could be any type of aligned/unaligned/128/64bit value
     };
-    unsigned int    bytesToSkip;  // after opcode, including modrm byte
+    unsigned int    bytesToSkip;  // AFTER modrm byte
 } operandspec_t;
 
 typedef struct { 

C/Test_OperandDecoder.c

     registers_t regs;
     int i = 0;
     unsigned char* modRM;
+    for (i = 0; i <= 7; i++)
+        regs.reg[i] = pow(2,i);
     if (argc > 1) {
         modRM = (unsigned char*) getchararray(argv[1]);
         for (i = 0; i < argc-2; i++) {
-            regs.reg[i] = atoi(argv[i+2]);
+            regs.reg[i] = atoll(argv[i+2]);
         }
     }
     else modRM = (unsigned char*) getchararray("C0");
 
     unsigned long long starttime, endtime;
     operandspec_t op;
-    for (i = 0; i <= 7; i++)
-        regs.reg[i] = pow(2,i);
 
     asm ("rdtsc\n" : "=A"(starttime));
     for (i = 1; i < 1000000; i++)
     printf("Cycles  = %u / decode\n", (endtime - starttime) / i);
 
     if (!op.sourceIsRegister) {
-        printf("Registers: [edi] [esi] [ebp] [esp] [ebx] [edx] [ecx] [eax]\n");
-        printf("           ");
+        printf("[edi]      [esi]      [ebp]      [esp]      [ebx]      [edx]      [ecx]      [eax]\n");
         for (i = 0; i <= 7; i++)
-            printf(" %03d  ", regs.reg[i]);
+            printf("0x%08x ", regs.reg[i]);
     }
     printf("\n");