home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s260 / 1.ddi / PART1.EXE / CONVERT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-15  |  2.4 KB  |  92 lines

  1. /* note the requirement of list file to use keyword   org   */
  2. /* read a list file from assembler and write a Nohau compatible */
  3. /* line number symbol file....... */
  4. /* records are "filename line#(dec) address(hex)\n"  */
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8.  
  9. #define TRUE 1
  10. char version[] = {"1.10" };
  11.  
  12. /* main()  */
  13. void main(argc,argv)
  14. int argc;
  15. char *argv[];
  16. {
  17.    FILE *fptr1, *fptr2;
  18.    int i,line=1,lnflg,slflg=0,orgflg=0,orgold=0;
  19.    char *ptr;
  20.    char string[133],xaddr[]={"    "};
  21.    char s1[] = {"           "},s2[]={"       "};
  22.    char s4[] = {"org "}; /* works for Franklin and Avocet  */
  23.    char s5[5];
  24.  
  25.    if (argc != 3){
  26.        printf("CONVERT.EXE   version %s\n",version);
  27.        printf("start program with >convert listfile lsymfile \n");
  28.        exit();
  29.     }
  30.        printf("CONVERT.EXE   version %s\n",version);
  31.     printf("Input = %s  Output = %s\n",argv[1],argv[2]);
  32.  
  33.    if( (fptr1=fopen(argv[1], "r")) == NULL)
  34.      {printf("Can't open file %s\n", argv[1]); exit(); }
  35.  
  36.    if( (fptr2=fopen(argv[2],"w")) == NULL)
  37.      {printf("Can't open file %s\n", argv[2]); exit();}
  38.  
  39.    while( fgets(string,133,fptr1) != NULL) {
  40.        itoa(line,s2,10);
  41.        strcpy(&s1[1],&s2);
  42.        ptr=strstr(&string,&s1);
  43.        if (*ptr== NULL) lnflg = 0;
  44.        else {
  45.             switch(*ptr) {
  46.                   case ' '  : lnflg = TRUE; break;
  47.                   case '\t' : lnflg = TRUE; break;
  48.                    default   : lnflg = 0;
  49.             }
  50.        }
  51.        if (*(ptr = strstr(&string,&s4)) != NULL) 
  52.                orgflg ++;
  53.        else 
  54.                orgold = orgflg;
  55.     strcpy(s5,s4);
  56.     s5[3] = '\t';
  57.        if (*(ptr = strstr(&string,&s5)) != NULL) 
  58.                orgflg ++;
  59.        else 
  60.                orgold = orgflg;
  61.     strcpy(s5,s4);
  62.     strupr(s5);
  63.        if (*(ptr = strstr(&string,&s5)) != NULL) 
  64.                orgflg ++;
  65.        else 
  66.                orgold = orgflg;
  67.     strcpy(s5,s4);
  68.     strupr(s5);
  69.     s5[3] = '\t';
  70.        if (*(ptr = strstr(&string,&s5)) != NULL) 
  71.                orgflg ++;
  72.        else 
  73.                orgold = orgflg;
  74.  
  75.        
  76.        for (i=0;i<4;i++) {
  77.           if ((string[i] >= '0')  && (string[i] <= 'F')) {
  78.               slflg = orgflg;
  79.              xaddr[i] = string[i];}
  80.           else {slflg = 0; break; }
  81.        }
  82.        if(orgflg==orgold) {
  83.               if(lnflg) {
  84.                 if (slflg) fprintf(fptr2, "%s %d %s\n", argv[1],line,xaddr);
  85.             }     
  86.        }
  87.        if(lnflg) line++;
  88.    }
  89.    fclose(fptr1); fclose(fptr2);
  90.  /* end main */
  91. }
  92.