⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppc32_exec.c

📁 思科路由器仿真器,用来仿7200系列得,可以在电脑上模拟路由器
💻 C
📖 第 1 页 / 共 5 页
字号:
   int bd = bits(insn,21,25);   int bb = bits(insn,16,20);   int ba = bits(insn,11,15);   m_uint32_t tmp;   tmp =  ppc32_read_cr_bit(cpu,ba);   tmp ^= ppc32_read_cr_bit(cpu,bb);   if (!(tmp & 0x1))      ppc32_set_cr_bit(cpu,bd);   else      ppc32_clear_cr_bit(cpu,bd);   return(0);}/* CRANDC - Condition Register AND with Complement */static fastcall int ppc32_exec_CRANDC(cpu_ppc_t *cpu,ppc_insn_t insn){   int bd = bits(insn,21,25);   int bb = bits(insn,16,20);   int ba = bits(insn,11,15);   m_uint32_t tmp;   tmp =  ppc32_read_cr_bit(cpu,ba);   tmp &= ~ppc32_read_cr_bit(cpu,bb);   if (tmp & 0x1)      ppc32_set_cr_bit(cpu,bd);   else      ppc32_clear_cr_bit(cpu,bd);   return(0);}/* CRNAND - Condition Register NAND */static fastcall int ppc32_exec_CRNAND(cpu_ppc_t *cpu,ppc_insn_t insn){   int bd = bits(insn,21,25);   int bb = bits(insn,16,20);   int ba = bits(insn,11,15);   m_uint32_t tmp;   tmp =  ppc32_read_cr_bit(cpu,ba);   tmp &= ppc32_read_cr_bit(cpu,bb);   if (!(tmp & 0x1))      ppc32_set_cr_bit(cpu,bd);   else      ppc32_clear_cr_bit(cpu,bd);   return(0);}/* CRNOR - Condition Register NOR */static fastcall int ppc32_exec_CRNOR(cpu_ppc_t *cpu,ppc_insn_t insn){   int bd = bits(insn,21,25);   int bb = bits(insn,16,20);   int ba = bits(insn,11,15);   m_uint32_t tmp;   tmp =  ppc32_read_cr_bit(cpu,ba);   tmp |= ppc32_read_cr_bit(cpu,bb);   if (!(tmp & 0x1))      ppc32_set_cr_bit(cpu,bd);   else      ppc32_clear_cr_bit(cpu,bd);   return(0);}/* CROR - Condition Register OR */static fastcall int ppc32_exec_CROR(cpu_ppc_t *cpu,ppc_insn_t insn){   int bd = bits(insn,21,25);   int bb = bits(insn,16,20);   int ba = bits(insn,11,15);   m_uint32_t tmp;   tmp =  ppc32_read_cr_bit(cpu,ba);   tmp |= ppc32_read_cr_bit(cpu,bb);   if (tmp & 0x1)      ppc32_set_cr_bit(cpu,bd);   else      ppc32_clear_cr_bit(cpu,bd);   return(0);}/* CRORC - Condition Register OR with complement */static fastcall int ppc32_exec_CRORC(cpu_ppc_t *cpu,ppc_insn_t insn){   int bd = bits(insn,21,25);   int bb = bits(insn,16,20);   int ba = bits(insn,11,15);   m_uint32_t tmp;   tmp =  ppc32_read_cr_bit(cpu,ba);   tmp |= ~ppc32_read_cr_bit(cpu,bb);   if (tmp & 0x1)      ppc32_set_cr_bit(cpu,bd);   else      ppc32_clear_cr_bit(cpu,bd);   return(0);}/* CRXOR - Condition Register XOR */static fastcall int ppc32_exec_CRXOR(cpu_ppc_t *cpu,ppc_insn_t insn){   int bd = bits(insn,21,25);   int bb = bits(insn,16,20);   int ba = bits(insn,11,15);   m_uint32_t tmp;   tmp =  ppc32_read_cr_bit(cpu,ba);   tmp ^= ppc32_read_cr_bit(cpu,bb);   if (tmp & 0x1)      ppc32_set_cr_bit(cpu,bd);   else      ppc32_clear_cr_bit(cpu,bd);   return(0);}/* DCBF - Data Cache Block Flush */static fastcall int ppc32_exec_DCBF(cpu_ppc_t *cpu,ppc_insn_t insn){   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   //printf("PPC32: DBCF: vaddr=0x%8.8x\n",vaddr);   return(0);}/* DCBI - Data Cache Block Invalidate */static fastcall int ppc32_exec_DCBI(cpu_ppc_t *cpu,ppc_insn_t insn){   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   //printf("PPC32: DBCI: vaddr=0x%8.8x\n",vaddr);   return(0);}/* DCBT - Data Cache Block Touch */static fastcall int ppc32_exec_DCBT(cpu_ppc_t *cpu,ppc_insn_t insn){   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   //printf("PPC32: DBCT: vaddr=0x%8.8x\n",vaddr);   return(0);}/* DCBST - Data Cache Block Store */static fastcall int ppc32_exec_DCBST(cpu_ppc_t *cpu,ppc_insn_t insn){   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   //printf("PPC32: DBCST: vaddr=0x%8.8x\n",vaddr);   return(0);}/* DIVW - Divide Word */static fastcall int ppc32_exec_DIVW(cpu_ppc_t *cpu,ppc_insn_t insn){   int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   register m_uint32_t a,b;   a = (m_int32_t)cpu->gpr[ra];   b = (m_int32_t)cpu->gpr[rb];   if (!((b == 0) || ((cpu->gpr[ra] == 0x80000000) && (b == -1))))      cpu->gpr[rd] = a / b;   return(0);}/* DIVW. - Divide Word */static fastcall int ppc32_exec_DIVW_dot(cpu_ppc_t *cpu,ppc_insn_t insn){   int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   register m_int32_t a,b,d;   a = (m_int32_t)cpu->gpr[ra];   b = (m_int32_t)cpu->gpr[rb];   d = 0;   if (!((b == 0) || ((cpu->gpr[ra] == 0x80000000) && (b == -1))))      d = a / b;   ppc32_exec_update_cr0(cpu,d);   cpu->gpr[rd] = d;   return(0);}/* DIVWU - Divide Word Unsigned */static fastcall int ppc32_exec_DIVWU(cpu_ppc_t *cpu,ppc_insn_t insn){   int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   register m_uint32_t a,b;   a = cpu->gpr[ra];   b = cpu->gpr[rb];   if (b != 0)      cpu->gpr[rd] = a / b;   return(0);}/* DIVWU. - Divide Word Unsigned */static fastcall int ppc32_exec_DIVWU_dot(cpu_ppc_t *cpu,ppc_insn_t insn){   int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   register m_uint32_t a,b,d;   a = cpu->gpr[ra];   b = cpu->gpr[rb];   d = 0;   if (b != 0)      d = a / b;   ppc32_exec_update_cr0(cpu,d);   cpu->gpr[rd] = d;   return(0);}/* EIEIO - Enforce In-order Execution of I/O */static fastcall int ppc32_exec_EIEIO(cpu_ppc_t *cpu,ppc_insn_t insn){   return(0);}/* EQV */static fastcall int ppc32_exec_EQV(cpu_ppc_t *cpu,ppc_insn_t insn){   int rs = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   cpu->gpr[ra] = ~(cpu->gpr[rs] ^ cpu->gpr[rb]);   return(0);}/* EXTSB - Extend Sign Byte */static fastcall int ppc32_exec_EXTSB(cpu_ppc_t *cpu,ppc_insn_t insn){   int rs = bits(insn,21,25);   int ra = bits(insn,16,20);   cpu->gpr[ra] = sign_extend_32(cpu->gpr[rs],8);   return(0);}/* EXTSB. */static fastcall int ppc32_exec_EXTSB_dot(cpu_ppc_t *cpu,ppc_insn_t insn){   int rs = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint32_t tmp;   tmp = sign_extend_32(cpu->gpr[rs],8);   ppc32_exec_update_cr0(cpu,tmp);   cpu->gpr[ra] = tmp;   return(0);}/* EXTSH - Extend Sign Word */static fastcall int ppc32_exec_EXTSH(cpu_ppc_t *cpu,ppc_insn_t insn){   int rs = bits(insn,21,25);   int ra = bits(insn,16,20);   cpu->gpr[ra] = sign_extend_32(cpu->gpr[rs],16);   return(0);}/* EXTSH. */static fastcall int ppc32_exec_EXTSH_dot(cpu_ppc_t *cpu,ppc_insn_t insn){   int rs = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint32_t tmp;   tmp = sign_extend_32(cpu->gpr[rs],16);   ppc32_exec_update_cr0(cpu,tmp);   cpu->gpr[ra] = tmp;   return(0);}/* ICBI - Instruction Cache Block Invalidate */static fastcall int ppc32_exec_ICBI(cpu_ppc_t *cpu,ppc_insn_t insn){   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   ppc32_exec_memop(cpu,PPC_MEMOP_ICBI,vaddr,0);   return(0);}/* ISYNC - Instruction Synchronize */static fastcall int ppc32_exec_ISYNC(cpu_ppc_t *cpu,ppc_insn_t insn){   return(0);}/* LBZ - Load Byte and Zero */static fastcall int ppc32_exec_LBZ(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint16_t imm = bits(insn,0,15);   m_uint32_t vaddr;   vaddr = sign_extend_32(imm,16);      if (ra != 0)      vaddr += cpu->gpr[ra];   ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);   return(0);}/* LBZU - Load Byte and Zero with Update */static fastcall int ppc32_exec_LBZU(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint16_t imm = bits(insn,0,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);   ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);   cpu->gpr[ra] = vaddr;   return(0);}/* LBZUX - Load Byte and Zero with Update Indexed */static fastcall int ppc32_exec_LBZUX(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[ra] + cpu->gpr[rb];   ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);   cpu->gpr[ra] = vaddr;   return(0);}/* LBZX - Load Byte and Zero Indexed */static fastcall int ppc32_exec_LBZX(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);   return(0);}/* LHA - Load Half-Word Algebraic */static fastcall int ppc32_exec_LHA(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint16_t imm = bits(insn,0,15);   m_uint32_t vaddr;   vaddr = sign_extend_32(imm,16);      if (ra != 0)      vaddr += cpu->gpr[ra];   ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);   return(0);}/* LHAU - Load Half-Word Algebraic with Update */static fastcall int ppc32_exec_LHAU(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint16_t imm = bits(insn,0,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);   ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);   cpu->gpr[ra] = vaddr;   return(0);}/* LHAUX - Load Half-Word Algebraic with Update Indexed */static fastcall int ppc32_exec_LHAUX(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[ra] + cpu->gpr[rb];   ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);   cpu->gpr[ra] = vaddr;   return(0);}/* LHAX - Load Half-Word Algebraic ndexed */static fastcall int ppc32_exec_LHAX(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);   return(0);}/* LHZ - Load Half-Word and Zero */static fastcall int ppc32_exec_LHZ(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint16_t imm = bits(insn,0,15);   m_uint32_t vaddr;   vaddr = sign_extend_32(imm,16);      if (ra != 0)      vaddr += cpu->gpr[ra];   ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);   return(0);}/* LHZU - Load Half-Word and Zero with Update */static fastcall int ppc32_exec_LHZU(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint16_t imm = bits(insn,0,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);   ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);   cpu->gpr[ra] = vaddr;   return(0);}/* LHZUX - Load Half-Word and Zero with Update Indexed */static fastcall int ppc32_exec_LHZUX(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[ra] + cpu->gpr[rb];   ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);   cpu->gpr[ra] = vaddr;   return(0);}/* LHZX - Load Half-Word and Zero Indexed */static fastcall int ppc32_exec_LHZX(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);   return(0);}/* LMW - Load Multiple Word */static fastcall int ppc32_exec_LMW(cpu_ppc_t *cpu,ppc_insn_t insn){   int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   m_uint16_t imm = bits(insn,0,15);   m_uint32_t vaddr;   int r;   vaddr = sign_extend_32(imm,16);      if (ra != 0)      vaddr += cpu->gpr[ra];   for(r=rd;r<=31;r++) {      ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,r);      vaddr += sizeof(m_uint32_t);   }   return(0);}/* LWBRX - Load Word Byte-Reverse Indexed */static fastcall int ppc32_exec_LWBRX(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);   int rb = bits(insn,11,15);   m_uint32_t vaddr;   vaddr = cpu->gpr[rb];   if (ra != 0)      vaddr += cpu->gpr[ra];   ppc32_exec_memop(cpu,PPC_MEMOP_LWBR,vaddr,rd);   return(0);}/* LWZ - Load Word and Zero */static fastcall int ppc32_exec_LWZ(cpu_ppc_t *cpu,ppc_insn_t insn){     int rd = bits(insn,21,25);   int ra = bits(insn,16,20);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -