c로 구현한 sic 어셈블리어 프로그램
본 자료는 5페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
해당 자료는 5페이지 까지만 미리보기를 제공합니다.
5페이지 이후부터 다운로드 후 확인할 수 있습니다.

본문내용

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 파일 및 결과 화면 -

키워드

  • 가격2,000
  • 페이지수17페이지
  • 등록일2011.06.16
  • 저작시기2010.1
  • 파일형식한글(hwp)
  • 자료번호#684814
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니