OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [tags/] [V3_0/] [tools/] [convert.c] - Blame information for rev 26

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rhoads
//convert.c by Steve Rhoads 4/26/01
2 26 rhoads
//This program strips off the first 0x1000 bytes
3 2 rhoads
#include <stdio.h>
4
#include <stdlib.h>
5
 
6
#define BUF_SIZE (1024*1024)
7 26 rhoads
#define CODE_OFFSET 0x1000
8 2 rhoads
 
9
int main(int argc,char *argv[])
10
{
11 26 rhoads
   FILE *infile,*outfile,*txtfile;
12 2 rhoads
   unsigned char *buf;
13
   long size,i,j;
14
   unsigned long d;
15
   infile=fopen("test.exe","rb");
16
   if(infile==NULL) {
17
      printf("Can't open test.exe");
18
      return 0;
19
   }
20
   buf=(unsigned char*)malloc(BUF_SIZE);
21
   size=fread(buf,1,BUF_SIZE,infile);
22
   fclose(infile);
23 26 rhoads
   outfile=fopen("test2.exe","wb");
24
   txtfile=fopen("code.txt","w");
25 2 rhoads
   for(i=CODE_OFFSET;i<size;i+=4) {
26 26 rhoads
      d=(buf[i]<<24)|(buf[i+1]<<16)|(buf[i+2]<<8)|buf[i+3];
27
//      if((d>>24)==0x0c) {          //JAL
28
//         j=(d&0xfffff)-0x400-((i-CODE_OFFSET)>>2)-1;   //BGEZAL
29
//         d=0x04110000+(j&0xffff); 
30
//      }
31
      fprintf(txtfile,"%8.8x\n",d);
32
      fwrite(buf+i,4,1,outfile);
33 2 rhoads
   }
34
   fclose(outfile);
35 26 rhoads
   fclose(txtfile);
36 2 rhoads
   free(buf);
37
   return 0;
38
}
39
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.