본문내용
typedef struct Code{
char opcode[6];
char machine[3];
short int offset;
} CodeSet;
//opcode table의 정의
CodeSet OpcodeTable[26]={
{"JLT","38",2},{"LDA","00",-1},{"SUB","1C",-1},{"AND","40",-1},
{"MUL","20",6},{"OR","44",-1},{"RSUB","4C",-1},{"DIV","24",-1},
{"STCH","54",-1},{"STL","14",-1},{"STX","10",-1},{"TIX","2C",-1},
{"LDL","08",-1},{"JSUB","48",14},{"TD","E0",-1},{"STA","0C",-1},
{"JEQ","30",-1},{"COMP","28",-1},{"WD","DC",-1},{"ADD","18",7},
{"RD","D8",8},{"JGT","34",10},{"J","3C",13},{"LDCH","50",-1},
{"LDX","04",15},{"STSW","E8",18}
};
//OpcodeTable은 전역변수로 설정하였다.
int HashFunction(char * string, int mod);
//HashFunction에 mod를 parameter로 전해주며 OpcodeTable은 각 character의 합을 26으로 나눈 값을 반환하며 SymTable은 각 character의 합을 40으로 나눈 값을 반환한다.(hash value로 갖는다.)
int StrComp(char * string1, char * string2);
//string1과 string2를 비교하여 같으면 0을 다르면 1을 반환한다.
int StrCopy(char * stringS, char * stringD);
//stringS(source)를 stringD(destination)에 복사한다.
void HexAddDec(char * Hex, int aValue);
//char 4자리인 Hex를 받아서 3을 더해서 다시 Hex에 저장한다.
int HconvD(char * Hex);
//char Hex를 받아서 Decimal로 바꿔서 integer로 반환한다.
void DconvH(int Dec, char * Hex);
//int인 Decimal을 char인 Hex(4자리 수)로 변환
int Decimal(char * Dec);
//char형인 Decimal을 integer로 변환하여 반환
int OpcodeSearch(char * code, char * machine)
//opcode를 table에서 찾아서 2자리 hex로 반환한다.
struct Node;
typedef struct Node SymNode;
char opcode[6];
char machine[3];
short int offset;
} CodeSet;
//opcode table의 정의
CodeSet OpcodeTable[26]={
{"JLT","38",2},{"LDA","00",-1},{"SUB","1C",-1},{"AND","40",-1},
{"MUL","20",6},{"OR","44",-1},{"RSUB","4C",-1},{"DIV","24",-1},
{"STCH","54",-1},{"STL","14",-1},{"STX","10",-1},{"TIX","2C",-1},
{"LDL","08",-1},{"JSUB","48",14},{"TD","E0",-1},{"STA","0C",-1},
{"JEQ","30",-1},{"COMP","28",-1},{"WD","DC",-1},{"ADD","18",7},
{"RD","D8",8},{"JGT","34",10},{"J","3C",13},{"LDCH","50",-1},
{"LDX","04",15},{"STSW","E8",18}
};
//OpcodeTable은 전역변수로 설정하였다.
int HashFunction(char * string, int mod);
//HashFunction에 mod를 parameter로 전해주며 OpcodeTable은 각 character의 합을 26으로 나눈 값을 반환하며 SymTable은 각 character의 합을 40으로 나눈 값을 반환한다.(hash value로 갖는다.)
int StrComp(char * string1, char * string2);
//string1과 string2를 비교하여 같으면 0을 다르면 1을 반환한다.
int StrCopy(char * stringS, char * stringD);
//stringS(source)를 stringD(destination)에 복사한다.
void HexAddDec(char * Hex, int aValue);
//char 4자리인 Hex를 받아서 3을 더해서 다시 Hex에 저장한다.
int HconvD(char * Hex);
//char Hex를 받아서 Decimal로 바꿔서 integer로 반환한다.
void DconvH(int Dec, char * Hex);
//int인 Decimal을 char인 Hex(4자리 수)로 변환
int Decimal(char * Dec);
//char형인 Decimal을 integer로 변환하여 반환
int OpcodeSearch(char * code, char * machine)
//opcode를 table에서 찾아서 2자리 hex로 반환한다.
struct Node;
typedef struct Node SymNode;
소개글