📄 alu.c
字号:
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 34 : printf("current pc value: 0x%08x\ncurrent instruction: sub \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=opa_ep-opb_ep;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=(((opa_ep>0)&&(opb_ep<0)&&(result_first_ep<0))||((opa_ep<0)&&(opb_ep>0)&&(result_first_ep>0)))? 19 : 0;
nullify_flag_ep=0;
break;
case 35 : printf("current pc value: 0x%08x\ncurrent instruction: subu \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=opa_ep-opb_ep;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 36 : printf("current pc value: 0x%08x\ncurrent instruction: and \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=opa_ep&opb_ep;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 37 : printf("current pc value: 0x%08x\ncurrent instruction: or \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=opa_ep|opb_ep;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 38 : printf("current pc value: 0x%08x\ncurrent instruction: xor \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=opa_ep^opb_ep;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 39 : printf("current pc value: 0x%08x\ncurrent instruction: nor \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=~(opa_ep|opb_ep);
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 42 : printf("current pc value: 0x%08x\ncurrent instruction: slt \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=(opa_ep<opb_ep)? 1 : 0;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 43 : printf("current pc value: 0x%08x\ncurrent instruction: sltu \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=(((unsigned long)opa_ep)<((unsigned long)opb_ep))? 1 : 0;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 48 : printf("current pc value: 0x%08x\ncurrent instruction: tge \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (opa_ep >= opb_ep)? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(opa_ep >= opb_ep)? 20 : 0;
nullify_flag_ep=0;
break;
case 49 : printf("current pc value: 0x%08x\ncurrent instruction: tgeu \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (((unsigned long)opa_ep) >= ((unsigned long)opb_ep))? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(((unsigned long)opa_ep) >= ((unsigned long)opb_ep))? 20 : 0;
nullify_flag_ep=0;
break;
case 50 : printf("current pc value: 0x%08x\ncurrent instruction: tlt \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (opa_ep < opb_ep)? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(opa_ep < opb_ep)? 20 : 0;
nullify_flag_ep=0;
break;
case 51 : printf("current pc value: 0x%08x\ncurrent instruction: tltu \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (((unsigned long)opa_ep)<((unsigned long)opb_ep))? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(((unsigned long)opa_ep)<((unsigned long)opb_ep))? 20 : 0;
nullify_flag_ep=0;
break;
case 52 : printf("current pc value: 0x%08x\ncurrent instruction: teq \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (opa_ep == opb_ep)? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(opa_ep == opb_ep)? 20 : 0;
nullify_flag_ep=0;
break;
case 54 : printf("current pc value: 0x%08x\ncurrent instruction: tne \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (opa_ep != opb_ep)? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(opa_ep != opb_ep)? 20 : 0;
nullify_flag_ep=0;
break;
default : printf("special instruction error!\npc_address_ep=%08x,instruction_ep=%08x\n",pc_address_ep,instruction_ep);
exception_flag_ep=18;
ErrorEPC=pc_address_ep;
EPC=pc_address_ep;
CPR[30]=pc_address_ep;
CPR[14]=pc_address_ep;
}
}else if(instruction_type_ep==1){
// regimm instrction
// printf("regimm instrction\n",pc_address_ep);
switch(regimm_instr_num_ep)
{case 0 : printf("current pc value: 0x%08x\ncurrent instruction: bltz \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=(opa_ep < 0)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 1 : printf("current pc value: 0x%08x\ncurrent instruction: bgez \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=(opa_ep >= 0)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 2 : printf("current pc value: 0x%08x\ncurrent instruction: bltzl \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=(opa_ep < 0)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=(opa_ep < 0)? 0 : 1;
break;
case 3 : printf("current pc value: 0x%08x\ncurrent instruction: bgezl \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=(opa_ep >= 0)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=(opa_ep >= 0)? 0 : 1;
break;
case 8 : printf("current pc value: 0x%08x\ncurrent instruction: tgei \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (opa_ep >= opb_ep)? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(opa_ep >= opb_ep)? 20 : 0;
if(exception_flag_ep == 20){
// ErrorEPC=pc_address_ep;
EPC=pc_address_ep;
//CPR[30]=pc_address_ep;
CPR[14]=pc_address_ep;
}
nullify_flag_ep=0;
break;
case 9 : printf("current pc value: 0x%08x\ncurrent instruction: tgeiu \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (((unsigned long)opa_ep) >= ((unsigned long)opb_ep))? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(((unsigned long)opa_ep) >= ((unsigned long)opb_ep))? 20 : 0;
if(exception_flag_ep == 20){
//ErrorEPC=pc_address_ep;
EPC=pc_address_ep;
// CPR[30]=pc_address_ep;
CPR[14]=pc_address_ep;
}
nullify_flag_ep=0;
break;
case 10 : printf("current pc value: 0x%08x\ncurrent instruction: tlti \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep=0;
trap_flag_ep=0; // (opa_ep < opb_ep)? 20 : 0;
branch_flag_ep=0;
exception_flag_ep=(opa_ep < opb_ep)? 20 : 0;
if(exception_flag_ep == 20){
//ErrorEPC=pc_address_ep;
EPC=pc_address_ep;
//CPR[30]=pc_address_ep;
CPR[14]=pc_address_ep;
}
nullify_flag_ep=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -