📄 alu.c
字号:
}else{
for(i=31;i>=0;i--){
if(((opa_ep>>i)&(0x00000001)) == 1){
result_first_ep=result_first_ep + 0;
break;
}else{
result_first_ep=32-i;
}
//break;
}
}
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 33 : printf("current pc value: 0x%08x\ncurrent instruction: clo \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=32;
if(opa_ep>=0){
result_first_ep=0;
}else{
for(i=31;i>=0;i--){
if(((opa_ep>>i)&(0x00000001)) == 0){
result_first_ep=result_first_ep + 0;
break;
}else{
result_first_ep=32-i;
}
//break;
}
}
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 63 : printf("current pc value: 0x%08x\ncurrent instruction: sdbbp \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
break;
default : printf("special2 instruction error!special2_instr_num_ep=%08x\n",special2_instr_num_ep);
exception_flag_ep=18;
}
}else{
// normal instrction
// printf("normal instrction\n",pc_address_ep);
switch(normal_instr_num_ep)
{ case 2 : printf("current pc value: 0x%08x\ncurrent instruction: j \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=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 3 : printf("current pc value: 0x%08x\ncurrent instruction: jal \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=pc_address_ep + 8;
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 4 : printf("current pc value: 0x%08x\ncurrent instruction: beq \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 == opb_ep)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=0;
#ifdef DEBUG
printf("opa_ep=%08x,opb_ep=%08x,branch_flag_ep=%d\n",opa_ep,opb_ep,branch_flag_ep);
#endif
break;
case 5 : printf("current pc value: 0x%08x\ncurrent instruction: bne \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 != opb_ep)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=0;
#ifdef DEBUG
printf("opa_ep=%08x,opb_ep=%08x,branch_flag_ep=%d\n",opa_ep,opb_ep,branch_flag_ep);
#endif
break;
case 6 : printf("current pc value: 0x%08x\ncurrent instruction: blez \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 7 : printf("current pc value: 0x%08x\ncurrent instruction: bgtz \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 > opb_ep)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 8 : printf("current pc value: 0x%08x\ncurrent instruction: addi \ninstruction code: 0x%08x\n",pc_address_ep,instruction_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;
printf("\nStatus=%08x\n",Status);
if(exception_flag_ep == 19){
//ErrorEPC=pc_address_ep;
EPC=pc_address_ep;
// CPR[30]=pc_address_ep;
CPR[14]=pc_address_ep;
}
//exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 9 : printf("current pc value: 0x%08x\ncurrent instruction: addiu \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=((unsigned long)opa_ep)+((unsigned long)opb_ep);
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 10 : printf("current pc value: 0x%08x\ncurrent instruction: slti \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;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 11 : printf("current pc value: 0x%08x\ncurrent instruction: sltiu \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;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 12 : printf("current pc value: 0x%08x\ncurrent instruction: andi \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=(opa_ep&(opb_ep&0x0000ffff));
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 13 : printf("current pc value: 0x%08x\ncurrent instruction: ori \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=(opa_ep|(opb_ep&0x0000ffff));
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 14 : printf("current pc value: 0x%08x\ncurrent instruction: xori \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=(opa_ep^(opb_ep&0x0000ffff));
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 15 : printf("current pc value: 0x%08x\ncurrent instruction: lui \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=(opa_ep<<16);
result_second_ep=0;
trap_flag_ep=0;
branch_flag_ep=0;
exception_flag_ep=0;
exception_flag_ep=0;
nullify_flag_ep=0;
break;
case 20 : printf("current pc value: 0x%08x\ncurrent instruction: beql \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 == opb_ep)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=(opa_ep == opb_ep)? 0 : 1;
break;
case 21 : printf("current pc value: 0x%08x\ncurrent instruction: bnel \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 != opb_ep)? 1 : 0;
exception_flag_ep=0;
nullify_flag_ep=(opa_ep != opb_ep)? 0 : 1;
break;
case 22 : printf("current pc value: 0x%08x\ncurrent instruction: blezl \n",pc_address_ep);
printf("instruction code: 0x%08x\n",instruction_ep);
result_first_ep=0;
result_second_ep
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -