Commits

Anonymous committed a93c33f

Added rudimentary tester

  • Participants
  • Parent commits d1fb161

Comments (0)

Files changed (2)

File C/OperandDecoder.c

 #define disp32(pointer)   (*((unsigned int*)  (pointer)))
 #define disp8(pointer)    (*((unsigned char*) (pointer)))
 
-operandspec_t decodeOperands(registers_t* regs, unsigned char* modRM)
+inline operandspec_t decodeOperands(registers_t* regs, unsigned char* modRM)
 {
     operandspec_t decoded;
     unsigned char mod,reg,rm,scale,index,base;

File C/Test_OperandDecoder.c

+#include <stdio.h>
+#include "OperandDecoder.c"
+
+int main() {
+    registers_t regs;
+    int i;
+    unsigned char modRM[] = { 0x04, 0x20, 0xff, 0x00, 0x00, 0x00 };
+    unsigned long long starttime, endtime;
+    operandspec_t op;
+    for (i = 0; i <= 7; i++)
+        regs.reg[i] = 7-i;
+
+    asm ("rdtsc\n" : "=A"(starttime));
+    for (i = 1; i < 1000000; i++)
+        op = decodeOperands(&regs, modRM);
+    asm ("rdtsc\n" : "=A"(endtime));
+
+    printf("Source  = %s%x\n", op.sourceIsRegister ? "reg xmm" : "mem 0x", op.sourceMem);
+    printf("Dest    = reg xmm%u\n", op.destReg);
+    printf("Cycles  = %u\n", (endtime - starttime) / i);
+
+    return 0;
+}