본문내용
ssReference(FILE *fixed_txt){ // defined과used 검색
printf("\n=====Cross Reference List======\n");
printf("Symbol Defined Used \n");
printf("-------------------------------\n");
//operand를배열에대입//////////////////////////////////////////
char operand[50][10]; // operand 배열
int lnum = TotalLineNum + 1; // fixed_txt의전체줄수
LineCount = 0; // 줄번호
fseek(fixed_txt, 0, 0); // 파일포인터를시작점으로돌림
for( i=0 ; i
fgets(Temp, 30, fixed_txt); // 30글자를fixed_txt에서str에저장
if(Temp[0] == '.'){
i--;
continue;
}
if(strlen(Temp) < 20){ // str의길이가20보다작으면
j=0;
}
else{ // 20이상일경우
for( j=0, k=20 ; (c=Temp[k])!=' ' && c!='\n' && c!=',' ; j++, k++) // 공백,개행,주석이아닐경우에
operand[i][j] = c; //문자저장
}
operand[i][j] = '\0'; // 배열을비움
if( feof(fixed_txt) ) // 파일의끝이면탈출
break;
}
//비교연산및결과출력/////////////////////////////////////////
fseek(fixed_txt, 0, 0); // 파일포인터를시작점으로돌림
while(1){
if(fgetc(fixed_txt) == ' '){ // 줄의처음이공백이면
fgets(Temp, 30, fixed_txt); // 한줄로입력받음
LineCount += 10;
}
else{ // 줄의처음이문자면
if( feof(fixed_txt) ) // 파일의끝이면탈출
break;
fseek(fixed_txt, -1, 1); // 파일포인터를현제에서하나뒤로돌림
if(fgetc(fixed_txt) != '.'){
fseek(fixed_txt,-1,1); // 파일포인터를문자를받기전으로돌림
fscanf(fixed_txt, "%s", Temp); // lable을입력받음
LineCount += 10; // 줄번호증가
printf("%-10s", Temp); // lable 출력
printf("%3d", LineCount); // defined 출력
char c = ' '; // 정렬을위한공백
printf("%-7c", c); // 정렬을위한공백출력
int CharCount = 0; // operand에서lable의중복사용횟수
for(j=0 ; j<=lnum ; j++){
if(strcmp(Temp, operand[j]) == 0){ // operand와str의비교
++CharCount; // 중복사용횟수증가
if(CharCount>1)// 한번이상사용
printf(", %d", (j+1)*10); //used 출력(j+1)*10
else // 한번사용
printf("%d", (j+1)*10); //used 출력(j+1)*10
}
}
printf("\n");
fgets(Temp, 30, fixed_txt); // 다음줄로드
}
}
if( feof(fixed_txt) ) // 파일의끝이면탈출
break;
}
}
void CheckError(FILE *fixed_txt, FILE *oplist_txt){ // opcode txt로오류검사
printf("\n========= Check Error =========\n");
/////////////fixed_txt에서opcode불러와opcode[]에저장///////////////
char opcode[50][6]; // fixed_txt에서opcode를이력받아저장될배열
fseek(fixed_txt, 0, 0); // 파일포인터를시작점으로돌림
for(i=0 ; i < TotalLineNum+1 ; i++){ // fixed_txt의전체줄수만큼반복
fgets(Temp, 31, fixed_txt);
if(Temp[0] == '.'){ // 주석의경우
i--;
continue;
}
if(strlen(Temp) < 10){ // str의길이가20보다작으면
j=0;
}
else{ // 20이상일경우
for(j=0, k=10 ; (c=Temp[k])!=' ' && c!='\n' && c!='.' ; j++, k++) // 공백,개행,주석이아닐경우에
opcode[i][j] = c;
}
opcode[i][j] = '\0'; // 배열을비움
if( feof(fixed_txt) ) // 파일의끝이면탈출
break;
}
////////////////// optxt에서불러와optxt[]에저장/////////////
char oplist[50][6]; // oplist.txt에서opcode를저장
int Test_CharCount=0;
for(i=0 ; i<32 ; i++){ // oplist.txt에서optxt에저장
fscanf(oplist_txt, "%s", oplist[i]);
}
for(i=0 ; i < TotalLineNum +1 ; i++){ // 전체opcode수만큼반복
for(j=0 ; j < 32 ; j++){
if(strcmp(opcode[i], oplist[j]) == 0){ // opcode에대하여oplist 비교
Test_CharCount++; // 비교하여같은opcode가발견되면Test_CharCount을증가
break;
}
}
if(Test_CharCount == 0) // 같은opcode가발견되지않았을경우
printf("Error Line No.%-3d , [ %s ] is undefined OPcode !\n",(i+1)*10, opcode[i]); // 해당line num와opcode출력
Test_CharCount=0;
}
printf("\n");
}
- TXT 파일 및 결과 화면 -
printf("\n=====Cross Reference List======\n");
printf("Symbol Defined Used \n");
printf("-------------------------------\n");
//operand를배열에대입//////////////////////////////////////////
char operand[50][10]; // operand 배열
int lnum = TotalLineNum + 1; // fixed_txt의전체줄수
LineCount = 0; // 줄번호
fseek(fixed_txt, 0, 0); // 파일포인터를시작점으로돌림
for( i=0 ; i
if(Temp[0] == '.'){
i--;
continue;
}
if(strlen(Temp) < 20){ // str의길이가20보다작으면
j=0;
}
else{ // 20이상일경우
for( j=0, k=20 ; (c=Temp[k])!=' ' && c!='\n' && c!=',' ; j++, k++) // 공백,개행,주석이아닐경우에
operand[i][j] = c; //문자저장
}
operand[i][j] = '\0'; // 배열을비움
if( feof(fixed_txt) ) // 파일의끝이면탈출
break;
}
//비교연산및결과출력/////////////////////////////////////////
fseek(fixed_txt, 0, 0); // 파일포인터를시작점으로돌림
while(1){
if(fgetc(fixed_txt) == ' '){ // 줄의처음이공백이면
fgets(Temp, 30, fixed_txt); // 한줄로입력받음
LineCount += 10;
}
else{ // 줄의처음이문자면
if( feof(fixed_txt) ) // 파일의끝이면탈출
break;
fseek(fixed_txt, -1, 1); // 파일포인터를현제에서하나뒤로돌림
if(fgetc(fixed_txt) != '.'){
fseek(fixed_txt,-1,1); // 파일포인터를문자를받기전으로돌림
fscanf(fixed_txt, "%s", Temp); // lable을입력받음
LineCount += 10; // 줄번호증가
printf("%-10s", Temp); // lable 출력
printf("%3d", LineCount); // defined 출력
char c = ' '; // 정렬을위한공백
printf("%-7c", c); // 정렬을위한공백출력
int CharCount = 0; // operand에서lable의중복사용횟수
for(j=0 ; j<=lnum ; j++){
if(strcmp(Temp, operand[j]) == 0){ // operand와str의비교
++CharCount; // 중복사용횟수증가
if(CharCount>1)// 한번이상사용
printf(", %d", (j+1)*10); //used 출력(j+1)*10
else // 한번사용
printf("%d", (j+1)*10); //used 출력(j+1)*10
}
}
printf("\n");
fgets(Temp, 30, fixed_txt); // 다음줄로드
}
}
if( feof(fixed_txt) ) // 파일의끝이면탈출
break;
}
}
void CheckError(FILE *fixed_txt, FILE *oplist_txt){ // opcode txt로오류검사
printf("\n========= Check Error =========\n");
/////////////fixed_txt에서opcode불러와opcode[]에저장///////////////
char opcode[50][6]; // fixed_txt에서opcode를이력받아저장될배열
fseek(fixed_txt, 0, 0); // 파일포인터를시작점으로돌림
for(i=0 ; i < TotalLineNum+1 ; i++){ // fixed_txt의전체줄수만큼반복
fgets(Temp, 31, fixed_txt);
if(Temp[0] == '.'){ // 주석의경우
i--;
continue;
}
if(strlen(Temp) < 10){ // str의길이가20보다작으면
j=0;
}
else{ // 20이상일경우
for(j=0, k=10 ; (c=Temp[k])!=' ' && c!='\n' && c!='.' ; j++, k++) // 공백,개행,주석이아닐경우에
opcode[i][j] = c;
}
opcode[i][j] = '\0'; // 배열을비움
if( feof(fixed_txt) ) // 파일의끝이면탈출
break;
}
////////////////// optxt에서불러와optxt[]에저장/////////////
char oplist[50][6]; // oplist.txt에서opcode를저장
int Test_CharCount=0;
for(i=0 ; i<32 ; i++){ // oplist.txt에서optxt에저장
fscanf(oplist_txt, "%s", oplist[i]);
}
for(i=0 ; i < TotalLineNum +1 ; i++){ // 전체opcode수만큼반복
for(j=0 ; j < 32 ; j++){
if(strcmp(opcode[i], oplist[j]) == 0){ // opcode에대하여oplist 비교
Test_CharCount++; // 비교하여같은opcode가발견되면Test_CharCount을증가
break;
}
}
if(Test_CharCount == 0) // 같은opcode가발견되지않았을경우
printf("Error Line No.%-3d , [ %s ] is undefined OPcode !\n",(i+1)*10, opcode[i]); // 해당line num와opcode출력
Test_CharCount=0;
}
printf("\n");
}
- TXT 파일 및 결과 화면 -
추천자료
- N명의 학생의 이름과 국/영/수 성적을 입력받아서 이름과 과목점수 평균 출력하는 프로그램
- 경제성공학 계산식 프로그램
- OpenGL을 이용한 3D 자동차 시뮬레이션 프로그램
- 스택을이용하여 중위->후위연산으로바꾸고 계산하는 프로그램
- 스택(stack)을 이용한 계산기(calculator) 프로그램 작성
- MATLAB으로 구현한 FFT의 Cosine wave 프로그램
- Jacobi 반복법 (C언어, 수치해석 프로그램 소스)
- RS-232C 직렬통신 프로그램
- 스택을 이용한 계산기프로그램
- [c언어]성적처리프로그램(ppt포함)
- Rose Compiler and Compass Installation Guide (로즈 컴파일러와 컴패스 검사기 설치 가이드)
- [마이크로 프로세서 소스] 키친타이머 소스 작성 소스코드 - pic 16f84