Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include<string.h>
- void main()
- {
- int s=0,i,flag=1,j,adr,val=0;
- char temp[100],temp1[100],temp2[100],ch[10],f[100],f1[100];
- strcpy(f,"F");
- FILE *fptr,*sptr,*aptr,*bptr,*cptr;
- fptr = fopen("SIC.txt","r");
- sptr = fopen("s.txt","w+");
- aptr = fopen("a.txt","w+");
- bptr = fopen("b.txt","w+");
- cptr = fopen("c.txt","w+");
- if(fptr == NULL)
- {
- printf("Error!");
- exit(1);
- }
- flag=1;
- for(i=0;i<40;i++)
- {
- fscanf(fptr,"%s",temp);
- fscanf(fptr,"%s",temp1);
- if(strcmp("START",temp1)==0)
- {
- fscanf(fptr,"%d",&s);
- fprintf(cptr,"%s\t%d\n",temp,s);
- printf("%s\t%d\n",temp,s);
- strcpy(f,temp);
- //s+=3;
- }
- else if( strcmp("WORD",temp1)==0 && strcmp("RESW",temp1)==0 && strcmp("BYTE",temp1)==0 && strcmp("RESB",temp1)==0)
- fscanf(fptr,"%d",&val);
- else
- fscanf(fptr,"%s",temp2);
- //adressing
- if(strcmp(f,temp)!=0 && strcmp("**",temp)!=0)
- { if(strcmp("RESW",temp1)==0)
- {
- fprintf(cptr,"%s\t%d\n",temp,s);
- printf("%s\t%d\n",temp,s);
- strcpy(f,temp);
- s=s+(3*val);
- }
- else
- if(strcmp("RESB",temp1)==0)
- {
- fprintf(cptr,"%s\t%d\n",temp,s);
- printf("%s\t%d\n",temp,s);
- strcpy(f,temp);s=s+val;
- }
- else
- {
- //s=s+3;
- fprintf(cptr,"%s\t%d\n",temp,s);
- printf("%s\t%d\n",temp,s);
- strcpy(f,temp);
- s+=3;
- }
- //s+=3;
- }
- else
- {
- s+=3;
- }
- }
- fclose(sptr);fclose(aptr);fclose(bptr);fclose(cptr);
- /*if(strcmp("LDA",temp)!=0 && strcmp("STA",temp)!=0 && strcmp("LDCH",temp)!=0 && strcmp("STCH",temp)!=0 && strcmp("WORD",temp)!=0 && strcmp("RESW",temp)!=0 && strcmp("BYTE",temp)!=0 && strcmp("RESB",temp)!=0 && strcmp("**",temp)!=0)
- printf("%s",temp);
- if(start!=0)
- printf(" %d\n",start);
- else
- printf("\n");
- start=0;
- }*/
- }
Add Comment
Please, Sign In to add comment