[ros-diffs] [greatlrd] 25500: fixing dymatic abi for ppc, and implement a dymatic abi even for ia32 converter

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Wed Jan 17 21:25:46 CET 2007


Author: greatlrd
Date: Wed Jan 17 23:25:46 2007
New Revision: 25500

URL: http://svn.reactos.org/svn/reactos?rev=25500&view=rev
Log:
fixing dymatic abi for ppc, and implement a dymatic abi even for ia32 converter  

Modified:
    trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c
    trunk/rosapps/devutils/cputointel/ConvertingProcess.c
    trunk/rosapps/devutils/cputointel/any_op.h

Modified: trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c?rev=25500&r1=25499&r2=25500&view=diff
==============================================================================
--- trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c (original)
+++ trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c Wed Jan 17 23:25:46 2007
@@ -8,21 +8,67 @@
 #include "misc.h"
 #include "any_op.h"
 
-CPU_INT ConvertToIA32Process( FILE *outfp, CPU_INT eax, CPU_INT ebp,
-                               CPU_INT edx, CPU_INT esp, 
+/*
+ * eax = register 3
+ * edx = register 4
+ * esp = register 1
+ * ebp = register 31
+
+ * ecx = 8
+ * ebx = 9
+ * esi = 10
+ * edi = 11
+ * mmx/sse/fpu 0 = 12
+ * mmx/sse/fpu 1 = 14
+ * mmx/sse/fpu 2 = 16
+ * mmx/sse/fpu 3 = 18
+ * mmx/sse/fpu 4 = 20
+ * mmx/sse/fpu 5 = 22
+ * mmx/sse/fpu 6 = 24
+ * mmx/sse/fpu 7 = 28
+ */
+
+CPU_INT ConvertToIA32Process( FILE *outfp,
                                PMYBrainAnalys pMystart, 
                                PMYBrainAnalys pMyend, CPU_INT regbits,
-                               CPU_INT HowManyRegInUse)
+                               CPU_INT HowManyRegInUse,
+                               CPU_INT *RegTableCount)
 {
 
     CPU_INT stack = 0;
     CPU_UNINT tmp;
     CPU_INT setup_ebp = 0 ; /* 0 = no, 1 = yes */
-
-    /* Fixme at moment we can not optimze code */
+    CPU_INT t=0;
+
+    /* Fixme optimze the RegTableCount table  */
+
     //if (HowManyRegInUse > 9)
-    if (HowManyRegInUse > 4)
-    {
+    if (HowManyRegInUse > 8)
+    {
+        setup_ebp =1; /* we will use ebx as ebp */
+        stack = HowManyRegInUse * regbits;
+    }
+
+    if (RegTableCount[1]!=0)
+        t++;
+    if (RegTableCount[3]!=0)
+        t++;
+    if (RegTableCount[4]!=0)
+        t++;
+    if (RegTableCount[8]!=0)
+        t++;
+    if (RegTableCount[9]!=0)
+        t++;
+    if (RegTableCount[10]!=0)
+        t++;
+    if (RegTableCount[11]!=0)
+        t++;
+    if (RegTableCount[31]!=0)
+        t++;
+
+    if (HowManyRegInUse != t)
+    {
+        /* fixme optimze the table or active the frame pointer */
         setup_ebp =1; /* we will use ebx as ebp */
         stack = HowManyRegInUse * regbits;
     }
@@ -42,19 +88,7 @@
         fprintf(outfp,"mov  ebx,esp\n");
         fprintf(outfp,"sub  esp, %d ; Alloc %d bytes for reg\n\n",stack,stack);
     }
-    else
-    {
-         /*
-        0 EAX
-        1 ECX
-        2 EDX
-        5 EBX
-        6 ESP
-        7 EBP
-        8 ESI
-        9 EDI
-        */
-    }
+
 
     fprintf(outfp,"; Start the program \n");
     while (pMystart!=NULL)
@@ -75,33 +109,73 @@
                 {
                     /* source are imm */
 
-                    if (pMystart->dst == eax)
+                     /* 
+                     * esi = 10
+                     * edi = 11 */
+
+                    /* eax */
+                    if (pMystart->dst == RegTableCount[3])
                     {
                         if (pMystart->src == 0)
                             fprintf(outfp,"xor eax,eax\n");
                         else
                             fprintf(outfp,"mov eax,%llu\n",pMystart->src);
                     }
-                    else if (pMystart->dst == ebp)
+                    /* ebp */
+                    else if (pMystart->dst == RegTableCount[31])
                     {
                         if (pMystart->src == 0)
                             fprintf(outfp,"xor ebp,ebp\n");
                         else
                             fprintf(outfp,"mov ebp,%llu\n",pMystart->src);
                     }
-                    else if (pMystart->dst == edx)
+                    /* edx */
+                    else if (pMystart->dst == RegTableCount[4])
                     {
                         if (pMystart->src == 0)
                             fprintf(outfp,"xor edx,edx\n");
                         else
                             fprintf(outfp,"mov edx,%llu\n",pMystart->src);
                     }
-                    else if (pMystart->dst == esp)
+                    /* esp */
+                    else if (pMystart->dst == RegTableCount[1])
                     {
                         if (pMystart->src == 0)
                             fprintf(outfp,"xor esp,esp\n");
                         else
                             fprintf(outfp,"mov esp,%llu\n",pMystart->src);
+                    }
+                    /* ecx */
+                    else if (pMystart->dst == RegTableCount[8])
+                    {
+                        if (pMystart->src == 0)
+                            fprintf(outfp,"xor ecx,ecx\n");
+                        else
+                            fprintf(outfp,"mov ecx,%llu\n",pMystart->src);
+                    }
+                    /* ebx */
+                    else if (pMystart->dst == RegTableCount[9])
+                    {
+                        if (pMystart->src == 0)
+                            fprintf(outfp,"xor ebx,ebx\n");
+                        else
+                            fprintf(outfp,"mov ebx,%llu\n",pMystart->src);
+                    }
+                    /* esi */
+                    else if (pMystart->dst == RegTableCount[10])
+                    {
+                        if (pMystart->src == 0)
+                            fprintf(outfp,"xor esi,esi\n");
+                        else
+                            fprintf(outfp,"mov esi,%llu\n",pMystart->src);
+                    }
+                    /* edi */
+                    else if (pMystart->dst == RegTableCount[10])
+                    {
+                        if (pMystart->src == 0)
+                            fprintf(outfp,"xor edi,edi\n");
+                        else
+                            fprintf(outfp,"mov edi,%llu\n",pMystart->src);
                     }
                     else
                     {

Modified: trunk/rosapps/devutils/cputointel/ConvertingProcess.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/ConvertingProcess.c?rev=25500&r1=25499&r2=25500&view=diff
==============================================================================
--- trunk/rosapps/devutils/cputointel/ConvertingProcess.c (original)
+++ trunk/rosapps/devutils/cputointel/ConvertingProcess.c Wed Jan 17 23:25:46 2007
@@ -13,10 +13,6 @@
 CPU_INT ConvertProcess(FILE *outfp, CPU_INT FromCpuid, CPU_INT ToCpuid)
 {
     CPU_INT ret=0;
-   CPU_INT eax =-1;
-   CPU_INT ebp =-1;
-   CPU_INT edx =-1;
-   CPU_INT esp =-1;
    CPU_INT regbits=-1;
    CPU_INT HowManyRegInUse = 0;
    CPU_INT RegTableCount[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
@@ -31,10 +27,6 @@
         (FromCpuid == IMAGE_FILE_MACHINE_I386))
     {
         regbits = 32 / 8;
-        esp = 1;
-        eax = 3;
-        edx = 4;
-        ebp = 31;
     }
 
     /* FIXME calc where todo first split */
@@ -61,19 +53,19 @@
         if (RegTableCount[t]!=0)
         {
             HowManyRegInUse++;
+            RegTableCount[t]=t;
         }
-        
     }
+
 
     /* switch to the acual converting now */
     switch (ToCpuid)
     {
         case IMAGE_FILE_MACHINE_I386:
-             ret = ConvertToIA32Process( outfp, eax, ebp,
-                                edx, esp, 
-                               pMystart, 
-                               pMyend, regbits,
-                               HowManyRegInUse);
+             ret = ConvertToIA32Process( outfp, pMystart, 
+                                         pMyend, regbits,
+                                         HowManyRegInUse,
+                                         RegTableCount);
              if (ret !=0)
              {
                  printf("should not happen contact a devloper, x86 fail\n");
@@ -82,11 +74,10 @@
              break;
 
         case IMAGE_FILE_MACHINE_POWERPC:
-             ret = ConvertToPPCProcess( outfp, eax, ebp,
-                                edx, esp, 
-                               pMystart, 
-                               pMyend, regbits,
-                               HowManyRegInUse);
+             ret = ConvertToPPCProcess( outfp, pMystart, 
+                                        pMyend, regbits,
+                                        HowManyRegInUse,
+                                        RegTableCount);
              if (ret !=0)
              {
                  printf("should not happen contact a devloper, x86 fail\n");

Modified: trunk/rosapps/devutils/cputointel/any_op.h
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/any_op.h?rev=25500&r1=25499&r2=25500&view=diff
==============================================================================
--- trunk/rosapps/devutils/cputointel/any_op.h (original)
+++ trunk/rosapps/devutils/cputointel/any_op.h Wed Jan 17 23:25:46 2007
@@ -11,18 +11,18 @@
  * esp = register 1
  * ebp = register 31
 
- * ecx = 5
- * ebx = 6
- * esi = 7
- * edi = 8
- * mmx/sse/fpu 0 = 10
- * mmx/sse/fpu 1 = 12
- * mmx/sse/fpu 2 = 14
- * mmx/sse/fpu 3 = 16
- * mmx/sse/fpu 4 = 18
- * mmx/sse/fpu 5 = 20
- * mmx/sse/fpu 6 = 22
- * mmx/sse/fpu 7 = 24
+ * ecx = 8
+ * ebx = 9
+ * esi = 10
+ * edi = 11
+ * mmx/sse/fpu 0 = 12
+ * mmx/sse/fpu 1 = 14
+ * mmx/sse/fpu 2 = 16
+ * mmx/sse/fpu 3 = 18
+ * mmx/sse/fpu 4 = 20
+ * mmx/sse/fpu 5 = 22
+ * mmx/sse/fpu 6 = 24
+ * mmx/sse/fpu 7 = 28
  */
 
 typedef struct _BrainAnalys
@@ -53,16 +53,16 @@
 extern PMYBrainAnalys pMyBrainAnalys;     /* current working address */
 extern PMYBrainAnalys pStartMyBrainAnalys; /* start address */
 
-CPU_INT ConvertToIA32Process( FILE *outfp, CPU_INT eax, CPU_INT ebp,
-                               CPU_INT edx, CPU_INT esp, 
+CPU_INT ConvertToIA32Process( FILE *outfp, 
                                PMYBrainAnalys pMystart, 
                                PMYBrainAnalys pMyend, CPU_INT regbits,
-                               CPU_INT HowManyRegInUse);
+                               CPU_INT HowManyRegInUse,
+                               CPU_INT *RegTableCount);
 
-CPU_INT ConvertToPPCProcess( FILE *outfp, CPU_INT r3, CPU_INT r31,
-                               CPU_INT r4, CPU_INT r1, 
+CPU_INT ConvertToPPCProcess( FILE *outfp, 
                                PMYBrainAnalys pMystart, 
                                PMYBrainAnalys pMyend, CPU_INT regbits,
-                               CPU_INT HowManyRegInUse);
+                               CPU_INT HowManyRegInUse,
+                               CPU_INT *RegTableCount);
 
 #endif




More information about the Ros-diffs mailing list