Commits

Anonymous committed be7c463

Improved operanddecoder tester even more. Now you can set registers too.

Comments (0)

Files changed (1)

C/Test_OperandDecoder.c

 
 int main(int argc, char* argv[]) {
     registers_t regs;
-    int i;
+    int i = 0;
     unsigned char* modRM;
-    if (argc > 1) modRM = (unsigned char*) getchararray(argv[1]);
+    if (argc > 1) {
+        modRM = (unsigned char*) getchararray(argv[1]);
+        for (i = 0; i < argc-2; i++) {
+            regs.reg[i] = atoi(argv[i+2]);
+        }
+    }
     else modRM = (unsigned char*) getchararray("C0");
 
     unsigned long long starttime, endtime;
 
     printf("Source  = %s%x\n", op.sourceIsRegister ? "reg xmm" : "mem 0x", op.sourceMem);
     printf("Dest    = reg xmm%u\n", op.destReg);
-    printf("Read    = %d bytes incl. modrm\n", op.bytesToSkip + 1);
+    printf("Bytes   = %d incl. modrm\n", op.bytesToSkip + 1);
     printf("Cycles  = %u / decode\n", (endtime - starttime) / i);
 
+    if (!op.sourceIsRegister) {
+        printf("Registers: [edi] [esi] [ebp] [esp] [edx] [ebx] [ecx] [eax]\n");
+        printf("           ");
+        for (i = 0; i <= 7; i++)
+            printf(" %03d  ", regs.reg[i]);
+    }
+    printf("\n");
+
     if (!modRM) free(modRM);
 
     return 0;