/[gxemul]/trunk/src/cpus/generate_arm_dpi.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/cpus/generate_arm_dpi.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 19 by dpavlin, Mon Oct 8 16:19:11 2007 UTC revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: generate_arm_dpi.c,v 1.2 2005/10/22 12:22:13 debug Exp $   *  $Id: generate_arm_dpi.c,v 1.3 2005/11/11 07:31:31 debug Exp $
29   */   */
30    
31  #include <stdio.h>  #include <stdio.h>
# Line 72  int main(int argc, char *argv[]) Line 72  int main(int argc, char *argv[])
72          printf("extern void arm_instr_invalid(struct cpu *, "          printf("extern void arm_instr_invalid(struct cpu *, "
73              "struct arm_instr_call *);\n");              "struct arm_instr_call *);\n");
74    
75          for (reg=0; reg<=1; reg++)          for (reg=0; reg<=2; reg++)
76            for (pc=0; pc<=1; pc++)            for (pc=0; pc<=1; pc++)
77              for (s=0; s<=1; s++)              for (s=0; s<=1; s++)
78                for (a=0; a<16; a++) {                for (a=0; a<16; a++) {
79                  if (a >= 8 && a <= 11 && s == 0)                  if (a >= 8 && a <= 11 && s == 0)
80                          continue;                          continue;
81                    if (reg == 2 && pc)
82                            continue;
83                  printf("#define A__NAME arm_instr_%s%s%s%s\n",                  printf("#define A__NAME arm_instr_%s%s%s%s\n",
84                      op[a], s? "s" : "", pc? "_pc" : "", reg? "_reg" : "");                      op[a], s? "s" : "", pc? "_pc" : "", reg?
85                        (reg==2? "_regshort" : "_reg") : "");
86    
87                  for (c=0; c<14; c++)                  for (c=0; c<14; c++)
88                          printf("#define A__NAME__%s arm_instr_%s%s%s%s__%s\n",                          printf("#define A__NAME__%s arm_instr_%s%s%s%s__%s\n",
89                              cond[c], op[a], s? "s" : "", pc? "_pc" : "",                              cond[c], op[a], s? "s" : "", pc? "_pc" : "",
90                              reg? "_reg" : "", cond[c]);                              reg? (reg==2? "_regshort" : "_reg") : "", cond[c]);
91                  if (s)  printf("#define A__S\n");                  if (s)  printf("#define A__S\n");
92                  if (reg)printf("#define A__REG\n");                  switch (reg) {
93                    case 1: printf("#define A__REG\n"); break;
94                    case 2: printf("#define A__REGSHORT\n"); break;
95                    }
96                  if (pc) printf("#define A__PC\n");                  if (pc) printf("#define A__PC\n");
97                  printf("#define A__%s\n", uppercase(op[a]));                  printf("#define A__%s\n", uppercase(op[a]));
98                  printf("#include \"cpu_arm_instr_dpi.c\"\n");                  printf("#include \"cpu_arm_instr_dpi.c\"\n");
99                  printf("#undef A__%s\n", uppercase(op[a]));                  printf("#undef A__%s\n", uppercase(op[a]));
100                  if (s)  printf("#undef A__S\n");                  if (s)  printf("#undef A__S\n");
101                  if (reg)printf("#undef A__REG\n");                  switch (reg) {
102                    case 1: printf("#undef A__REG\n"); break;
103                    case 2: printf("#undef A__REGSHORT\n"); break;
104                    }
105                  if (pc) printf("#undef A__PC\n");                  if (pc) printf("#undef A__PC\n");
106                  for (c=0; c<14; c++)                  for (c=0; c<14; c++)
107                          printf("#undef A__NAME__%s\n", cond[c]);                          printf("#undef A__NAME__%s\n", cond[c]);
# Line 121  int main(int argc, char *argv[]) Line 130  int main(int argc, char *argv[])
130                                  printf(",");                                  printf(",");
131                          printf("\n");                          printf("\n");
132                    }                    }
133    
134            printf("};\n\n");
135    
136            printf("\n\tvoid (*arm_dpi_instr_regshort[2 * 16 * 16])(struct cpu *,\n"
137                "\t\tstruct arm_instr_call *) = {\n");
138            n = 0;
139            for (s=0; s<=1; s++)
140                for (a=0; a<16; a++)
141                    for (c=0; c<16; c++) {
142                            if (c == 15)
143                                    printf("\tarm_instr_nop");
144                            else if (a >= 8 && a <= 11 && s == 0)
145                                    printf("\tarm_instr_invalid");
146                            else
147                                    printf("\tarm_instr_%s%s_regshort%s%s",
148                                        op[a], s? "s" : "",
149                                        c!=14? "__" : "", cond[c]);
150                            n++;
151                            if (n != 2 * 16 * 16)
152                                    printf(",");
153                            printf("\n");
154                      }
155    
156          printf("};\n\n");          printf("};\n\n");
157    

Legend:
Removed from v.19  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26