SherinKR

pass.c

Nov 1st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<string.h>
  4.  
  5. void main()
  6. {
  7. int s=0,i,flag=1,j,adr,val=0;
  8. char temp[100],temp1[100],temp2[100],ch[10],f[100],f1[100];
  9. strcpy(f,"F");
  10. FILE *fptr,*sptr,*aptr,*bptr,*cptr;
  11. fptr = fopen("SIC.txt","r");
  12. sptr = fopen("s.txt","w+");
  13. aptr = fopen("a.txt","w+");
  14. bptr = fopen("b.txt","w+");
  15. cptr = fopen("c.txt","w+");
  16.  
  17. if(fptr == NULL)
  18. {
  19. printf("Error!");
  20. exit(1);
  21. }
  22. flag=1;
  23. for(i=0;i<40;i++)
  24. {
  25.  
  26. fscanf(fptr,"%s",temp);
  27. fscanf(fptr,"%s",temp1);
  28. if(strcmp("START",temp1)==0)
  29. {
  30. fscanf(fptr,"%d",&s);
  31. fprintf(cptr,"%s\t%d\n",temp,s);
  32. printf("%s\t%d\n",temp,s);
  33. strcpy(f,temp);
  34. //s+=3;
  35. }
  36. else if( strcmp("WORD",temp1)==0 && strcmp("RESW",temp1)==0 && strcmp("BYTE",temp1)==0 && strcmp("RESB",temp1)==0)
  37. fscanf(fptr,"%d",&val);
  38. else
  39. fscanf(fptr,"%s",temp2);
  40. //adressing
  41. if(strcmp(f,temp)!=0 && strcmp("**",temp)!=0)
  42. { if(strcmp("RESW",temp1)==0)
  43. {
  44.  
  45. fprintf(cptr,"%s\t%d\n",temp,s);
  46. printf("%s\t%d\n",temp,s);
  47. strcpy(f,temp);
  48. s=s+(3*val);
  49. }
  50. else
  51. if(strcmp("RESB",temp1)==0)
  52. {
  53.  
  54. fprintf(cptr,"%s\t%d\n",temp,s);
  55. printf("%s\t%d\n",temp,s);
  56. strcpy(f,temp);s=s+val;
  57. }
  58. else
  59. {
  60. //s=s+3;
  61. fprintf(cptr,"%s\t%d\n",temp,s);
  62. printf("%s\t%d\n",temp,s);
  63. strcpy(f,temp);
  64. s+=3;
  65. }
  66. //s+=3;
  67. }
  68. else
  69. {
  70. s+=3;
  71. }
  72.  
  73. }
  74.  
  75. fclose(sptr);fclose(aptr);fclose(bptr);fclose(cptr);
  76.  
  77.  
  78. /*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)
  79. printf("%s",temp);
  80. if(start!=0)
  81. printf(" %d\n",start);
  82. else
  83. printf("\n");
  84. start=0;
  85. }*/
  86. }
Add Comment
Please, Sign In to add comment