void B_instruction_make()
{
unsigned int input_hex_num,imm32,imm10,imm11,current_PC, dsc_PC;
unsigned int out_instruction1,out_instruction2;
int temp_hex_num;
unsigned char I1,I2,J1,J2,S;
printf( "Please input a hex current_PC:\r\n" );
scanf( "%x", ¤t_PC );
printf( "current_PC = %x\r\n", current_PC );
printf( "Please input a hex dsc_PC:\r\n" );
scanf( "%x", &dsc_PC );
printf( "dsc_PC = %x\r\n", dsc_PC );
temp_hex_num = dsc_PC - current_PC;
printf( "temp_hex_num = %x\r\n", temp_hex_num );
if( temp_hex_num < 0 ){
S = 1;
J1 = 1;
J2 = 1;
}else{
S=0;
J1 = 0;
J2 = 0;
}
printf( "temp_hex_num = %d\r\n", temp_hex_num );
//input_hex_num = temp_hex_num & 0x1fffff;
//printf( "input_hex_num = %x\r\n", input_hex_num );
//input_hex_num = 0x200000 - input_hex_num;
//printf( "input_hex_num = %x\r\n", input_hex_num );
temp_hex_num = temp_hex_num - 4;
input_hex_num = temp_hex_num >> 1;
printf( "input_hex_num = %x\r\n", input_hex_num );
imm10 = (input_hex_num >> 11) & 0x3ff;
imm11 = input_hex_num & 0x7ff;
out_instruction1 = 0x00;
out_instruction1 = out_instruction1 | (0x1e<<11);
out_instruction1 = out_instruction1 | (S<<10);
out_instruction1 = out_instruction1 | imm10;
printf( "out_instruction1 = %x\r\n", out_instruction1 );
out_instruction2 = 0x00;
out_instruction2 = out_instruction2 | (0x2<<14);
printf( "out_instruction2 = %x\r\n", out_instruction2 );
printf( "J1 = %x\r\n", J1 );
out_instruction2 = out_instruction2 | (J1<<13);
printf( "out_instruction1 = %x\r\n", out_instruction1 );
out_instruction2 = out_instruction2 | (0x1<<12);
out_instruction2 = out_instruction2 | (J2<<11);
out_instruction2 = out_instruction2 | imm11;
printf( "out_instruction2 = %x\r\n", out_instruction2 );
printf( "imm10 = %x\r\n", imm10 );
printf( "imm11 = %x\r\n", imm11 );
//imm11 = input_hex_num
}
//2000c264
//2000a710
{
unsigned int input_hex_num,imm32,imm10,imm11,current_PC, dsc_PC;
unsigned int out_instruction1,out_instruction2;
int temp_hex_num;
unsigned char I1,I2,J1,J2,S;
printf( "Please input a hex current_PC:\r\n" );
scanf( "%x", ¤t_PC );
printf( "current_PC = %x\r\n", current_PC );
printf( "Please input a hex dsc_PC:\r\n" );
scanf( "%x", &dsc_PC );
printf( "dsc_PC = %x\r\n", dsc_PC );
temp_hex_num = dsc_PC - current_PC;
printf( "temp_hex_num = %x\r\n", temp_hex_num );
if( temp_hex_num < 0 ){
S = 1;
J1 = 1;
J2 = 1;
}else{
S=0;
J1 = 0;
J2 = 0;
}
printf( "temp_hex_num = %d\r\n", temp_hex_num );
//input_hex_num = temp_hex_num & 0x1fffff;
//printf( "input_hex_num = %x\r\n", input_hex_num );
//input_hex_num = 0x200000 - input_hex_num;
//printf( "input_hex_num = %x\r\n", input_hex_num );
temp_hex_num = temp_hex_num - 4;
input_hex_num = temp_hex_num >> 1;
printf( "input_hex_num = %x\r\n", input_hex_num );
imm10 = (input_hex_num >> 11) & 0x3ff;
imm11 = input_hex_num & 0x7ff;
out_instruction1 = 0x00;
out_instruction1 = out_instruction1 | (0x1e<<11);
out_instruction1 = out_instruction1 | (S<<10);
out_instruction1 = out_instruction1 | imm10;
printf( "out_instruction1 = %x\r\n", out_instruction1 );
out_instruction2 = 0x00;
out_instruction2 = out_instruction2 | (0x2<<14);
printf( "out_instruction2 = %x\r\n", out_instruction2 );
printf( "J1 = %x\r\n", J1 );
out_instruction2 = out_instruction2 | (J1<<13);
printf( "out_instruction1 = %x\r\n", out_instruction1 );
out_instruction2 = out_instruction2 | (0x1<<12);
out_instruction2 = out_instruction2 | (J2<<11);
out_instruction2 = out_instruction2 | imm11;
printf( "out_instruction2 = %x\r\n", out_instruction2 );
printf( "imm10 = %x\r\n", imm10 );
printf( "imm11 = %x\r\n", imm11 );
//imm11 = input_hex_num
}
//2000c264
//2000a710