본문내용
\"TIXR\") == 0)
find = 1;
return find;
}
void address_str_fill1(char *address, char *temp_r1, char *temp_r2) //형식 2의 피연산자 레지스터 2개를 결정하는 함수
{
if(strcmp(temp_r1, \"A\") == 0)
address[0] = \'0\';
else if(strcmp(temp_r1, \"X\") == 0)
address[0] = \'1\';
else if(strcmp(temp_r1, \"L\") == 0)
address[0] = \'2\';
else if(strcmp(temp_r1, \"PC\") == 0)
address[0] = \'8\';
else if(strcmp(temp_r1, \"SW\") == 0)
address[0] = \'9\';
else if(strcmp(temp_r1, \"B\") == 0)
address[0] = \'3\';
else if(strcmp(temp_r1, \"S\") == 0)
address[0] = \'4\';
else if(strcmp(temp_r1, \"T\") == 0)
address[0] = \'5\';
else if(strcmp(temp_r1, \"F\") == 0)
address[0] = \'6\';
if(strcmp(temp_r2, \"A\") == 0)
address[1] = \'0\';
else if(strcmp(temp_r2, \"X\") == 0)
address[1] = \'1\';
else if(strcmp(temp_r2, \"L\") == 0)
address[1] = \'2\';
else if(strcmp(temp_r2, \"PC\") == 0)
address[1] = \'8\';
else if(strcmp(temp_r2, \"SW\") == 0)
address[1] = \'9\';
else if(strcmp(temp_r2, \"B\") == 0)
address[1] = \'3\';
else if(strcmp(temp_r2, \"S\") == 0)
address[1] = \'4\';
else if(strcmp(temp_r2, \"T\") == 0)
address[1] = \'5\';
else if(strcmp(temp_r2, \"F\") == 0)
address[1] = \'6\';
address[2] = \'\\0\';
}
void address_str_fill2(char *address, char *temp_r1) //형식 2의 피연산자 레지스터 1개를 결정하는 함수
{
if(strcmp(temp_r1, \"A\") == 0)
address[0] = \'0\';
else if(strcmp(temp_r1, \"X\") == 0)
address[0] = \'1\';
else if(strcmp(temp_r1, \"L\") == 0)
address[0] = \'2\';
else if(strcmp(temp_r1, \"PC\") == 0)
address[0] = \'8\';
else if(strcmp(temp_r1, \"SW\") == 0)
address[0] = \'9\';
else if(strcmp(temp_r1, \"B\") == 0)
address[0] = \'3\';
else if(strcmp(temp_r1, \"S\") == 0)
address[0] = \'4\';
else if(strcmp(temp_r1, \"T\") == 0)
address[0] = \'5\';
else if(strcmp(temp_r1, \"F\") == 0)
address[0] = \'6\';
address[1] = \'0\';
address[2] = \'\\0\';
}
void get_token_from_regmode_operand(char *operand, char *temp_r1, char *temp_r2) //형식 2이고 피연산자 레지스터가 2개인 opcode일때 레지스터를 구분하는 함수
{
int i = 0, j = 0;
while(operand[i] != \',\')
{
temp_r1[i] = operand[i];
i++;
}
temp_r1[i] = \'\\0\';
i++;
while(operand[i] != \'\\0\')
{
temp_r2[j] = operand[i];
j++;
i++;
}
}
char *int_to_string( int data, char *string, int length ) //정수를 스트링으로 변환하는 함수
{
char buffer[ 20 ] = \"\";
char temp_buf[ 20 ] = \"\";
int minus = 0;
int size = 0;
int i = 0 ;
int temp;
size = strlen( string );
for ( i = 0 ; i < size ; i++ )
string[ i ] = \'\\0\';
if ( data < 0 ) //음수인 경우 2의 보수를 취한다
{
minus = 1;
data *= -1;
data = 0xFFFF - data + 1;
}
i = 0;
do {
temp = data % 16;
if ( temp >= 10 )
temp_buf[ i ] = \'A\' + temp - 10;
else
temp_buf[ i ] = \'0\' + temp;
data /= 16;
i++;
} while ( data >= 16 );
if ( data >= 10 )
temp_buf[ i ] = \'A\' + data - 10;
else
temp_buf[ i ] = \'0\' + data;
size = i;
for ( i = 0 ; i <= size ; i++ )
buffer[ size - i ] = temp_buf[ i ];
buffer[ size + 1 ] = \'\\0\';
size = length - strlen( buffer );
//빈공간을 0으로 한다
for ( i = 0 ; i < size ; i++ )
string[ i ] = \'0\';
strcat( string, buffer );
//소문자를 대문자로 바꾼다
for ( i = 0 ; i < (int)strlen( string ) ; i++ )
if ( string[ i ] >= \'a\' && string[ i ] <= \'z\' )
string[ i ] = ( char )( ( int )string[ i ] - 32 );
return string;
}
find = 1;
return find;
}
void address_str_fill1(char *address, char *temp_r1, char *temp_r2) //형식 2의 피연산자 레지스터 2개를 결정하는 함수
{
if(strcmp(temp_r1, \"A\") == 0)
address[0] = \'0\';
else if(strcmp(temp_r1, \"X\") == 0)
address[0] = \'1\';
else if(strcmp(temp_r1, \"L\") == 0)
address[0] = \'2\';
else if(strcmp(temp_r1, \"PC\") == 0)
address[0] = \'8\';
else if(strcmp(temp_r1, \"SW\") == 0)
address[0] = \'9\';
else if(strcmp(temp_r1, \"B\") == 0)
address[0] = \'3\';
else if(strcmp(temp_r1, \"S\") == 0)
address[0] = \'4\';
else if(strcmp(temp_r1, \"T\") == 0)
address[0] = \'5\';
else if(strcmp(temp_r1, \"F\") == 0)
address[0] = \'6\';
if(strcmp(temp_r2, \"A\") == 0)
address[1] = \'0\';
else if(strcmp(temp_r2, \"X\") == 0)
address[1] = \'1\';
else if(strcmp(temp_r2, \"L\") == 0)
address[1] = \'2\';
else if(strcmp(temp_r2, \"PC\") == 0)
address[1] = \'8\';
else if(strcmp(temp_r2, \"SW\") == 0)
address[1] = \'9\';
else if(strcmp(temp_r2, \"B\") == 0)
address[1] = \'3\';
else if(strcmp(temp_r2, \"S\") == 0)
address[1] = \'4\';
else if(strcmp(temp_r2, \"T\") == 0)
address[1] = \'5\';
else if(strcmp(temp_r2, \"F\") == 0)
address[1] = \'6\';
address[2] = \'\\0\';
}
void address_str_fill2(char *address, char *temp_r1) //형식 2의 피연산자 레지스터 1개를 결정하는 함수
{
if(strcmp(temp_r1, \"A\") == 0)
address[0] = \'0\';
else if(strcmp(temp_r1, \"X\") == 0)
address[0] = \'1\';
else if(strcmp(temp_r1, \"L\") == 0)
address[0] = \'2\';
else if(strcmp(temp_r1, \"PC\") == 0)
address[0] = \'8\';
else if(strcmp(temp_r1, \"SW\") == 0)
address[0] = \'9\';
else if(strcmp(temp_r1, \"B\") == 0)
address[0] = \'3\';
else if(strcmp(temp_r1, \"S\") == 0)
address[0] = \'4\';
else if(strcmp(temp_r1, \"T\") == 0)
address[0] = \'5\';
else if(strcmp(temp_r1, \"F\") == 0)
address[0] = \'6\';
address[1] = \'0\';
address[2] = \'\\0\';
}
void get_token_from_regmode_operand(char *operand, char *temp_r1, char *temp_r2) //형식 2이고 피연산자 레지스터가 2개인 opcode일때 레지스터를 구분하는 함수
{
int i = 0, j = 0;
while(operand[i] != \',\')
{
temp_r1[i] = operand[i];
i++;
}
temp_r1[i] = \'\\0\';
i++;
while(operand[i] != \'\\0\')
{
temp_r2[j] = operand[i];
j++;
i++;
}
}
char *int_to_string( int data, char *string, int length ) //정수를 스트링으로 변환하는 함수
{
char buffer[ 20 ] = \"\";
char temp_buf[ 20 ] = \"\";
int minus = 0;
int size = 0;
int i = 0 ;
int temp;
size = strlen( string );
for ( i = 0 ; i < size ; i++ )
string[ i ] = \'\\0\';
if ( data < 0 ) //음수인 경우 2의 보수를 취한다
{
minus = 1;
data *= -1;
data = 0xFFFF - data + 1;
}
i = 0;
do {
temp = data % 16;
if ( temp >= 10 )
temp_buf[ i ] = \'A\' + temp - 10;
else
temp_buf[ i ] = \'0\' + temp;
data /= 16;
i++;
} while ( data >= 16 );
if ( data >= 10 )
temp_buf[ i ] = \'A\' + data - 10;
else
temp_buf[ i ] = \'0\' + data;
size = i;
for ( i = 0 ; i <= size ; i++ )
buffer[ size - i ] = temp_buf[ i ];
buffer[ size + 1 ] = \'\\0\';
size = length - strlen( buffer );
//빈공간을 0으로 한다
for ( i = 0 ; i < size ; i++ )
string[ i ] = \'0\';
strcat( string, buffer );
//소문자를 대문자로 바꾼다
for ( i = 0 ; i < (int)strlen( string ) ; i++ )
if ( string[ i ] >= \'a\' && string[ i ] <= \'z\' )
string[ i ] = ( char )( ( int )string[ i ] - 32 );
return string;
}
소개글