#include #include #include void main(){ FILE *file_pointer1, *file_pointer2, *file_pointer3, *file_pointer4; char opcode[20], operand [20], label[20], code[20], mnemonic[20]; int loc_counter start, length; file_pointer1 = fopen("input.dat", "r"); file_pointer2 = fopen("optab.dat", "r"); file_pointer3 = fopen("symtab.dat", "w"); file_pointer4 = fopen("out.dat", "w"); fscanf(file_pointer1, "%s\t%s\t%s", label, opcode, operand); if(strcmp(opcode, "START") == 0) { start= atoi(operand), loc_counter = start; fprintf(file_pointer4, "\t%s\t%s\t%s\n", label, opcode, operand); escanf(file pointer1, "%s\t%s\t%s" label opcode operand): } else { loc_counter = 0; } while(strcmp(opcode, "END") != 0) { fprintf(file_pointer4, "%d\t", loc_counter); if(strcmp(label, "**") !=0) { fprintfile_pointer3, "sm", label, loc_counter); } fscanf(file_pointer2, "%s", code); while strcmptcode, END TOTT if(strempfopcode, coole)-0){ loc counter loc_counter + 3; break; } fscanf(file_pointer2, "%s", code); } if(strcmp(opcode, "WORD")==0) { loc_counter = loc_counter + 3; } else if(strcmp(opcode, "RESW")==0) { loc_counter = loc_counter + (3* (atoi(operand))); } else iffstrompopcode, "NESS")){ loc_counter = loc_counter + (atoi(operand)); } else if(strcmp(opcode, "BYTE")==0) { ++lac_counter: } fprintf(file_pointer4, "%s\t%s\t%s\t\n", label, opcode, operand); fscanf(file_pointer1, "%s\t%s\t%s", label, opcode, operand); } fprintf(file_pointer4, "%d \t%s\t%s\t%s\n", loc_counter, label, opcode, operand); length = loc_counter - start; printf("The length of the code: Mall", length); fclose(file_pointer1); fclose(file_pointer2); fclose(file_painter3): fclose(file_pointer4); }