4cb363f798f92b1a37b31c784c3a691e78149e68
11 static void standardreg(CPU_INT
*RegTableCount
, CPU_UNINT reg
,
12 CPU_INT setup_ebp
, FILE *outfp
)
17 if (reg
== RegTableCount
[t
])
19 fprintf(outfp
,"r%d",t
);
27 fprintf(outfp
,"r%d",reg
);
31 CPU_INT
ConvertToPPCProcess( FILE *outfp
,
32 PMYBrainAnalys pMystart
,
33 PMYBrainAnalys pMyend
, CPU_INT regbits
,
34 CPU_INT HowManyRegInUse
,
35 CPU_INT
*RegTableCount
)
40 CPU_INT setup_ebp
= 0 ; /* 0 = no, 1 = yes */
43 if (HowManyRegInUse
> 31)
45 setup_ebp
=1; /* we will use ebx as ebp */
46 stack
= HowManyRegInUse
* regbits
;
49 if (RegTableCount
[1]!=0)
51 if (RegTableCount
[3]!=0)
53 if (RegTableCount
[4]!=0)
55 if (RegTableCount
[8]!=0)
57 if (RegTableCount
[9]!=0)
59 if (RegTableCount
[10]!=0)
61 if (RegTableCount
[11]!=0)
63 if (RegTableCount
[31]!=0)
66 if (HowManyRegInUse
!= t
)
68 /* fixme optimze the table or active the frame pointer */
69 setup_ebp
=1; /* we will use ebx as ebp */
70 stack
= HowManyRegInUse
* regbits
;
74 /* fixme gas compatible
75 fprintf(outfp,"BITS 32\n");
76 fprintf(outfp,"GLOBAL _main\n");
77 fprintf(outfp,"SECTION .text\n\n");
78 fprintf(outfp,"; compile with nasm filename.asm -f win32, ld filename.obj -o filename.exe\n\n");
79 fprintf(outfp,"_main:\n");
82 /* setup a frame pointer */
85 /* fixme ppc frame pointer */
86 // fprintf(outfp,"\n; Setup frame pointer \n");
89 fprintf(outfp
,"; Start the program \n");
90 while (pMystart
!=NULL
)
92 /* fixme the line lookup from anaylysing process */
94 /* mov not full implement */
95 if (pMystart
->op
== OP_ANY_mov
)
97 printf("waring OP_ANY_mov are not full implement\n");
99 if ((pMystart
->type
& 8)== 8)
101 /* dst are register */
102 // FIXME frame pointer setup
103 // tmp = stack - (pMystart->dst*regbits);
105 if ((pMystart
->type
& 2)== 2)
107 fprintf(outfp
,"mr ");
108 standardreg( RegTableCount
,
112 standardreg( RegTableCount
,
118 if ((pMystart
->type
& 16)== 16)
122 fprintf(outfp
,"not supporet\n");
125 fprintf(outfp
,"li ");
126 standardreg( RegTableCount
,
129 fprintf(outfp
," , %llu\n",pMystart
->src
);
132 } /* end pMyBrainAnalys->type & 8 */
134 if ((pMystart
->type
& 64)== 64)
136 if ((pMystart
->type
& 2)== 2)
138 /* dest [eax - 0x20], source reg */
139 if ((pMystart
->type
& 128)== 128)
141 fprintf(outfp
,"stwu ");
145 fprintf(outfp
,"stw ");
148 standardreg( RegTableCount
,
151 fprintf(outfp
,", %d(",pMystart
->dst_extra
);
153 standardreg( RegTableCount
,
156 fprintf(outfp
,")\n");
158 } /* end pMyBrainAnalys->type & 64 */
162 if (pMystart
->op
== OP_ANY_ret
)
164 if (pMyBrainAnalys
->ptr_next
== NULL
)
168 // FIXME end our own frame pointer
169 fprintf(outfp
,"\n; clean up after the frame \n");
172 fprintf(outfp
,"blr\n");
174 if (pMystart
== pMyend
)
177 pMystart
= (PMYBrainAnalys
) pMystart
->ptr_next
;