/[dynamips]/trunk/ppc32_exec.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/ppc32_exec.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.7/ppc32_exec.c revision 10 by dpavlin, Sat Oct 6 16:29:14 2007 UTC upstream/dynamips-0.2.8-RC1/ppc32_exec.c revision 11 by dpavlin, Sat Oct 6 16:33:40 2007 UTC
# Line 76  void ppc32_dump_stats(cpu_ppc_t *cpu) Line 76  void ppc32_dump_stats(cpu_ppc_t *cpu)
76  }  }
77    
78  /* Execute a memory operation */  /* Execute a memory operation */
79  static forced_inline int ppc32_exec_memop(cpu_ppc_t *cpu,int memop,  static forced_inline void ppc32_exec_memop(cpu_ppc_t *cpu,int memop,
80                                            m_uint32_t vaddr,u_int dst_reg)                                             m_uint32_t vaddr,u_int dst_reg)
81  {      {    
82     fastcall ppc_memop_fn fn;     fastcall ppc_memop_fn fn;
83            
84     fn = cpu->mem_op_fn[memop];     fn = cpu->mem_op_fn[memop];
85     return(fn(cpu,vaddr,dst_reg));     fn(cpu,vaddr,dst_reg);
86  }  }
87    
88  /* Fetch an instruction */  /* Fetch an instruction */
# Line 118  ppc32_exec_single_instruction(cpu_ppc_t Line 118  ppc32_exec_single_instruction(cpu_ppc_t
118     register fastcall int (*exec)(cpu_ppc_t *,ppc_insn_t) = NULL;     register fastcall int (*exec)(cpu_ppc_t *,ppc_insn_t) = NULL;
119     struct ppc32_insn_exec_tag *tag;     struct ppc32_insn_exec_tag *tag;
120     int index;     int index;
121      
122  #if DEBUG_INSN_PERF_CNT  #if DEBUG_INSN_PERF_CNT
123     cpu->perf_counter++;     cpu->perf_counter++;
124  #endif  #endif
# Line 186  void *ppc32_exec_run_cpu(cpu_gen_t *gen) Line 186  void *ppc32_exec_run_cpu(cpu_gen_t *gen)
186     }     }
187    
188     gen->cpu_thread_running = TRUE;     gen->cpu_thread_running = TRUE;
189       cpu_exec_loop_set(gen);
190    
191   start_cpu:   start_cpu:
192     for(;;) {     for(;;) {
# Line 1500  static fastcall int ppc32_exec_ICBI(cpu_ Line 1501  static fastcall int ppc32_exec_ICBI(cpu_
1501     if (ra != 0)     if (ra != 0)
1502        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1503    
1504     return(ppc32_exec_memop(cpu,PPC_MEMOP_ICBI,vaddr,0));     ppc32_exec_memop(cpu,PPC_MEMOP_ICBI,vaddr,0);
1505       return(0);
1506  }  }
1507    
1508  /* ISYNC - Instruction Synchronize */  /* ISYNC - Instruction Synchronize */
# Line 1522  static fastcall int ppc32_exec_LBZ(cpu_p Line 1524  static fastcall int ppc32_exec_LBZ(cpu_p
1524     if (ra != 0)     if (ra != 0)
1525        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1526    
1527     return(ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);
1528       return(0);
1529  }  }
1530    
1531  /* LBZU - Load Byte and Zero with Update */  /* LBZU - Load Byte and Zero with Update */
# Line 1532  static fastcall int ppc32_exec_LBZU(cpu_ Line 1535  static fastcall int ppc32_exec_LBZU(cpu_
1535     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1536     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
1537     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1538    
1539     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
1540     res = ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);
1541     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1542     return(res);     return(0);
1543  }  }
1544    
1545  /* LBZUX - Load Byte and Zero with Update Indexed */  /* LBZUX - Load Byte and Zero with Update Indexed */
# Line 1547  static fastcall int ppc32_exec_LBZUX(cpu Line 1549  static fastcall int ppc32_exec_LBZUX(cpu
1549     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1550     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
1551     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1552    
1553     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
1554     res = ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);
1555     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1556     return(res);     return(0);
1557  }  }
1558    
1559  /* LBZX - Load Byte and Zero Indexed */  /* LBZX - Load Byte and Zero Indexed */
# Line 1568  static fastcall int ppc32_exec_LBZX(cpu_ Line 1569  static fastcall int ppc32_exec_LBZX(cpu_
1569     if (ra != 0)     if (ra != 0)
1570        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1571    
1572     return(ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd);
1573       return(0);
1574  }  }
1575    
1576  /* LHA - Load Half-Word Algebraic */  /* LHA - Load Half-Word Algebraic */
# Line 1584  static fastcall int ppc32_exec_LHA(cpu_p Line 1586  static fastcall int ppc32_exec_LHA(cpu_p
1586     if (ra != 0)     if (ra != 0)
1587        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1588    
1589     return(ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);
1590       return(0);
1591  }  }
1592    
1593  /* LHAU - Load Half-Word Algebraic with Update */  /* LHAU - Load Half-Word Algebraic with Update */
# Line 1594  static fastcall int ppc32_exec_LHAU(cpu_ Line 1597  static fastcall int ppc32_exec_LHAU(cpu_
1597     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1598     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
1599     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1600    
1601     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
1602     res = ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);
1603     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1604     return(res);     return(0);
1605  }  }
1606    
1607  /* LHAUX - Load Half-Word Algebraic with Update Indexed */  /* LHAUX - Load Half-Word Algebraic with Update Indexed */
# Line 1609  static fastcall int ppc32_exec_LHAUX(cpu Line 1611  static fastcall int ppc32_exec_LHAUX(cpu
1611     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1612     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
1613     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1614    
1615     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
1616     res = ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);
1617     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1618     return(res);     return(0);
1619  }  }
1620    
1621  /* LHAX - Load Half-Word Algebraic ndexed */  /* LHAX - Load Half-Word Algebraic ndexed */
# Line 1630  static fastcall int ppc32_exec_LHAX(cpu_ Line 1631  static fastcall int ppc32_exec_LHAX(cpu_
1631     if (ra != 0)     if (ra != 0)
1632        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1633    
1634     return(ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd);
1635       return(0);
1636  }  }
1637    
1638  /* LHZ - Load Half-Word and Zero */  /* LHZ - Load Half-Word and Zero */
# Line 1646  static fastcall int ppc32_exec_LHZ(cpu_p Line 1648  static fastcall int ppc32_exec_LHZ(cpu_p
1648     if (ra != 0)     if (ra != 0)
1649        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1650    
1651     return(ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);
1652       return(0);
1653  }  }
1654    
1655  /* LHZU - Load Half-Word and Zero with Update */  /* LHZU - Load Half-Word and Zero with Update */
# Line 1656  static fastcall int ppc32_exec_LHZU(cpu_ Line 1659  static fastcall int ppc32_exec_LHZU(cpu_
1659     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1660     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
1661     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1662    
1663     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
1664     res = ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);
1665     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1666     return(res);     return(0);
1667  }  }
1668    
1669  /* LHZUX - Load Half-Word and Zero with Update Indexed */  /* LHZUX - Load Half-Word and Zero with Update Indexed */
# Line 1671  static fastcall int ppc32_exec_LHZUX(cpu Line 1673  static fastcall int ppc32_exec_LHZUX(cpu
1673     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1674     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
1675     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1676    
1677     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
1678     res = ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);
1679     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1680     return(res);     return(0);
1681  }  }
1682    
1683  /* LHZX - Load Half-Word and Zero Indexed */  /* LHZX - Load Half-Word and Zero Indexed */
# Line 1692  static fastcall int ppc32_exec_LHZX(cpu_ Line 1693  static fastcall int ppc32_exec_LHZX(cpu_
1693     if (ra != 0)     if (ra != 0)
1694        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1695    
1696     return(ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd);
1697       return(0);
1698  }  }
1699    
1700  /* LMW - Load Multiple Word */  /* LMW - Load Multiple Word */
# Line 1702  static fastcall int ppc32_exec_LMW(cpu_p Line 1704  static fastcall int ppc32_exec_LMW(cpu_p
1704     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1705     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
1706     m_uint32_t vaddr;     m_uint32_t vaddr;
1707     int r,res;     int r;
1708    
1709     vaddr = sign_extend_32(imm,16);     vaddr = sign_extend_32(imm,16);
1710        
# Line 1710  static fastcall int ppc32_exec_LMW(cpu_p Line 1712  static fastcall int ppc32_exec_LMW(cpu_p
1712        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1713    
1714     for(r=rd;r<=31;r++) {     for(r=rd;r<=31;r++) {
1715        res = ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,r);        ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,r);
       if (res != 0) return(res);  
   
1716        vaddr += sizeof(m_uint32_t);        vaddr += sizeof(m_uint32_t);
1717     }     }
1718    
# Line 1732  static fastcall int ppc32_exec_LWBRX(cpu Line 1732  static fastcall int ppc32_exec_LWBRX(cpu
1732     if (ra != 0)     if (ra != 0)
1733        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1734    
1735     return(ppc32_exec_memop(cpu,PPC_MEMOP_LWBR,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LWBR,vaddr,rd);
1736       return(0);
1737  }  }
1738    
1739  /* LWZ - Load Word and Zero */  /* LWZ - Load Word and Zero */
# Line 1748  static fastcall int ppc32_exec_LWZ(cpu_p Line 1749  static fastcall int ppc32_exec_LWZ(cpu_p
1749     if (ra != 0)     if (ra != 0)
1750        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1751    
1752     return(ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd);
1753       return(0);
1754  }  }
1755    
1756  /* LWZU - Load Word and Zero with Update */  /* LWZU - Load Word and Zero with Update */
# Line 1758  static fastcall int ppc32_exec_LWZU(cpu_ Line 1760  static fastcall int ppc32_exec_LWZU(cpu_
1760     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1761     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
1762     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1763    
1764     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
1765     res = ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd);
1766     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1767     return(res);     return(0);
1768  }  }
1769    
1770  /* LWZUX - Load Word and Zero with Update Indexed */  /* LWZUX - Load Word and Zero with Update Indexed */
# Line 1773  static fastcall int ppc32_exec_LWZUX(cpu Line 1774  static fastcall int ppc32_exec_LWZUX(cpu
1774     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1775     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
1776     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1777    
1778     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
1779     res = ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd);
1780     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1781     return(res);     return(0);
1782  }  }
1783    
1784  /* LWZX - Load Word and Zero Indexed */  /* LWZX - Load Word and Zero Indexed */
# Line 1794  static fastcall int ppc32_exec_LWZX(cpu_ Line 1794  static fastcall int ppc32_exec_LWZX(cpu_
1794     if (ra != 0)     if (ra != 0)
1795        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1796    
1797     return(ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd);
1798       return(0);
1799  }  }
1800    
1801  /* LWARX - Load Word and Reserve Indexed */  /* LWARX - Load Word and Reserve Indexed */
# Line 1811  static fastcall int ppc32_exec_LWARX(cpu Line 1812  static fastcall int ppc32_exec_LWARX(cpu
1812        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1813    
1814     cpu->reserve = 1;     cpu->reserve = 1;
1815       ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd);
1816     return(ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd));     return(0);
1817  }  }
1818    
1819  /* LFD - Load Floating-Point Double */  /* LFD - Load Floating-Point Double */
# Line 1828  static fastcall int ppc32_exec_LFD(cpu_p Line 1829  static fastcall int ppc32_exec_LFD(cpu_p
1829     if (ra != 0)     if (ra != 0)
1830        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1831    
1832     return(ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd);
1833       return(0);
1834  }  }
1835    
1836  /* LFDU - Load Floating-Point Double with Update */  /* LFDU - Load Floating-Point Double with Update */
# Line 1838  static fastcall int ppc32_exec_LFDU(cpu_ Line 1840  static fastcall int ppc32_exec_LFDU(cpu_
1840     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1841     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
1842     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1843    
1844     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
1845     res = ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd);
1846     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1847     return(res);     return(0);
1848  }  }
1849    
1850  /* LFDUX - Load Floating-Point Double with Update Indexed */  /* LFDUX - Load Floating-Point Double with Update Indexed */
# Line 1853  static fastcall int ppc32_exec_LFDUX(cpu Line 1854  static fastcall int ppc32_exec_LFDUX(cpu
1854     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1855     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
1856     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
1857    
1858     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
1859     res = ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd);     ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd);
1860     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
1861     return(res);     return(0);
1862  }  }
1863    
1864  /* LFDX - Load Floating-Point Double Indexed */  /* LFDX - Load Floating-Point Double Indexed */
# Line 1874  static fastcall int ppc32_exec_LFDX(cpu_ Line 1874  static fastcall int ppc32_exec_LFDX(cpu_
1874     if (ra != 0)     if (ra != 0)
1875        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
1876    
1877     return(ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd));     ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd);
1878       return(0);
1879  }  }
1880    
1881  /* LSWI - Load String Word Immediate */  /* LSWI - Load String Word Immediate */
# Line 1884  static fastcall int ppc32_exec_LSWI(cpu_ Line 1885  static fastcall int ppc32_exec_LSWI(cpu_
1885     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1886     int nb = bits(insn,11,15);     int nb = bits(insn,11,15);
1887     m_uint32_t vaddr = 0;     m_uint32_t vaddr = 0;
1888     int res,r;     int r;
1889    
1890     if (ra != 0)     if (ra != 0)
1891        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
# Line 1901  static fastcall int ppc32_exec_LSWI(cpu_ Line 1902  static fastcall int ppc32_exec_LSWI(cpu_
1902           cpu->gpr[r] = 0;           cpu->gpr[r] = 0;
1903        }        }
1904                
1905        if (unlikely(res = ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r)) != 0)        ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r);
          return(res);  
   
1906        cpu->sw_pos += 8;        cpu->sw_pos += 8;
1907    
1908        if (cpu->sw_pos == 32)        if (cpu->sw_pos == 32)
# Line 1923  static fastcall int ppc32_exec_LSWX(cpu_ Line 1922  static fastcall int ppc32_exec_LSWX(cpu_
1922     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
1923     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
1924     m_uint32_t vaddr;     m_uint32_t vaddr;
1925     int res,r,nb;     int r,nb;
1926    
1927     vaddr = cpu->gpr[rb];     vaddr = cpu->gpr[rb];
1928    
# Line 1940  static fastcall int ppc32_exec_LSWX(cpu_ Line 1939  static fastcall int ppc32_exec_LSWX(cpu_
1939           cpu->gpr[r] = 0;           cpu->gpr[r] = 0;
1940        }        }
1941                
1942        if (unlikely(res = ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r)) != 0)        ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r);
          return(res);  
   
1943        cpu->sw_pos += 8;        cpu->sw_pos += 8;
1944    
1945        if (cpu->sw_pos == 32)        if (cpu->sw_pos == 32)
# Line 2076  static fastcall int ppc32_exec_MFSPR(cpu Line 2073  static fastcall int ppc32_exec_MFSPR(cpu
2073    
2074        /* MPC860 IMMR */        /* MPC860 IMMR */
2075        case 638:        case 638:
2076           cpu->gpr[rd] = 0x68010000;           cpu->gpr[rd] = cpu->mpc860_immr;
2077           break;           break;
2078    
2079        default:        default:
# Line 2837  static fastcall int ppc32_exec_STB(cpu_p Line 2834  static fastcall int ppc32_exec_STB(cpu_p
2834     if (ra != 0)     if (ra != 0)
2835        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
2836    
2837     return(ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs);
2838       return(0);
2839  }  }
2840    
2841  /* STBU - Store Byte with Update */  /* STBU - Store Byte with Update */
# Line 2847  static fastcall int ppc32_exec_STBU(cpu_ Line 2845  static fastcall int ppc32_exec_STBU(cpu_
2845     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
2846     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
2847     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
2848    
2849     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
2850     res = ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs);     ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs);
2851     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
2852     return(res);     return(0);
2853  }  }
2854    
2855  /* STBUX - Store Byte with Update Indexed */  /* STBUX - Store Byte with Update Indexed */
# Line 2862  static fastcall int ppc32_exec_STBUX(cpu Line 2859  static fastcall int ppc32_exec_STBUX(cpu
2859     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
2860     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
2861     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
2862    
2863     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
2864     res = ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs);     ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs);
2865     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
2866     return(res);     return(0);
2867  }  }
2868    
2869  /* STBX - Store Byte Indexed */  /* STBX - Store Byte Indexed */
# Line 2883  static fastcall int ppc32_exec_STBX(cpu_ Line 2879  static fastcall int ppc32_exec_STBX(cpu_
2879     if (ra != 0)     if (ra != 0)
2880        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
2881    
2882     return(ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs);
2883       return(0);
2884  }  }
2885    
2886  /* STH - Store Half-Word */  /* STH - Store Half-Word */
# Line 2899  static fastcall int ppc32_exec_STH(cpu_p Line 2896  static fastcall int ppc32_exec_STH(cpu_p
2896     if (ra != 0)     if (ra != 0)
2897        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
2898    
2899     return(ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs);
2900       return(0);
2901  }  }
2902    
2903  /* STHU - Store Half-Word with Update */  /* STHU - Store Half-Word with Update */
# Line 2909  static fastcall int ppc32_exec_STHU(cpu_ Line 2907  static fastcall int ppc32_exec_STHU(cpu_
2907     int ra  = bits(insn,16,20);     int ra  = bits(insn,16,20);
2908     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
2909     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
2910    
2911     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
2912     res = ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs);     ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs);
2913     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
2914     return(res);     return(0);
2915  }  }
2916    
2917  /* STHUX - Store Half-Word with Update Indexed */  /* STHUX - Store Half-Word with Update Indexed */
# Line 2924  static fastcall int ppc32_exec_STHUX(cpu Line 2921  static fastcall int ppc32_exec_STHUX(cpu
2921     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
2922     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
2923     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
2924    
2925     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
2926     res = ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs);     ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs);
2927     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
2928     return(res);     return(0);
2929  }  }
2930    
2931  /* STHX - Store Half-Word Indexed */  /* STHX - Store Half-Word Indexed */
# Line 2945  static fastcall int ppc32_exec_STHX(cpu_ Line 2941  static fastcall int ppc32_exec_STHX(cpu_
2941     if (ra != 0)     if (ra != 0)
2942        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
2943    
2944     return(ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs);
2945       return(0);
2946  }  }
2947    
2948  /* STMW - Store Multiple Word */  /* STMW - Store Multiple Word */
# Line 2955  static fastcall int ppc32_exec_STMW(cpu_ Line 2952  static fastcall int ppc32_exec_STMW(cpu_
2952     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
2953     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
2954     m_uint32_t vaddr;     m_uint32_t vaddr;
2955     int r,res;     int r;
2956    
2957     vaddr = sign_extend_32(imm,16);     vaddr = sign_extend_32(imm,16);
2958        
# Line 2963  static fastcall int ppc32_exec_STMW(cpu_ Line 2960  static fastcall int ppc32_exec_STMW(cpu_
2960        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
2961    
2962     for(r=rs;r<=31;r++) {     for(r=rs;r<=31;r++) {
2963        res = ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,r);        ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,r);
       if (res != 0) return(res);  
   
2964        vaddr += sizeof(m_uint32_t);        vaddr += sizeof(m_uint32_t);
2965     }     }
2966    
# Line 2985  static fastcall int ppc32_exec_STW(cpu_p Line 2980  static fastcall int ppc32_exec_STW(cpu_p
2980     if (ra != 0)     if (ra != 0)
2981        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
2982    
2983     return(ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs);
2984       return(0);
2985  }  }
2986    
2987  /* STWU - Store Word with Update */  /* STWU - Store Word with Update */
# Line 2995  static fastcall int ppc32_exec_STWU(cpu_ Line 2991  static fastcall int ppc32_exec_STWU(cpu_
2991     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
2992     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
2993     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
2994    
2995     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
2996     res = ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs);     ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs);
2997     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
2998     return(res);     return(0);
2999  }  }
3000    
3001  /* STWUX - Store Word with Update Indexed */  /* STWUX - Store Word with Update Indexed */
# Line 3010  static fastcall int ppc32_exec_STWUX(cpu Line 3005  static fastcall int ppc32_exec_STWUX(cpu
3005     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
3006     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
3007     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
3008    
3009     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
3010     res = ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs);     ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs);
3011     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
3012     return(res);     return(0);
3013  }  }
3014    
3015  /* STWX - Store Word Indexed */  /* STWX - Store Word Indexed */
# Line 3031  static fastcall int ppc32_exec_STWX(cpu_ Line 3025  static fastcall int ppc32_exec_STWX(cpu_
3025     if (ra != 0)     if (ra != 0)
3026        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
3027    
3028     return(ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs);
3029       return(0);
3030  }  }
3031    
3032  /* STWBRX - Store Word Byte-Reverse Indexed */  /* STWBRX - Store Word Byte-Reverse Indexed */
# Line 3047  static fastcall int ppc32_exec_STWBRX(cp Line 3042  static fastcall int ppc32_exec_STWBRX(cp
3042     if (ra != 0)     if (ra != 0)
3043        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
3044    
3045     return(ppc32_exec_memop(cpu,PPC_MEMOP_STWBR,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STWBR,vaddr,rs);
3046       return(0);
3047  }  }
3048    
3049  /* STWCX. - Store Word Conditional Indexed */  /* STWCX. - Store Word Conditional Indexed */
# Line 3057  static fastcall int ppc32_exec_STWCX_dot Line 3053  static fastcall int ppc32_exec_STWCX_dot
3053     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
3054     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
3055     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
3056    
3057     vaddr = cpu->gpr[rb];     vaddr = cpu->gpr[rb];
3058    
# Line 3065  static fastcall int ppc32_exec_STWCX_dot Line 3060  static fastcall int ppc32_exec_STWCX_dot
3060        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
3061    
3062     if (cpu->reserve) {     if (cpu->reserve) {
3063        res = ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs);        ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs);
       if (res != 0) return(res);  
3064    
3065        cpu->cr_fields[0] = 1 << PPC32_CR_EQ_BIT;        cpu->cr_fields[0] = 1 << PPC32_CR_EQ_BIT;
3066    
# Line 3097  static fastcall int ppc32_exec_STFD(cpu_ Line 3091  static fastcall int ppc32_exec_STFD(cpu_
3091     if (ra != 0)     if (ra != 0)
3092        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
3093    
3094     return(ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs);
3095       return(0);
3096  }  }
3097    
3098  /* STFDU - Store Floating-Point Double with Update */  /* STFDU - Store Floating-Point Double with Update */
# Line 3107  static fastcall int ppc32_exec_STFDU(cpu Line 3102  static fastcall int ppc32_exec_STFDU(cpu
3102     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
3103     m_uint16_t imm = bits(insn,0,15);     m_uint16_t imm = bits(insn,0,15);
3104     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
3105    
3106     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);     vaddr = cpu->gpr[ra] + sign_extend_32(imm,16);
3107     res = ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs);     ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs);
3108     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
3109     return(res);     return(0);
3110  }  }
3111    
3112  /* STFDUX - Store Floating-Point Double with Update Indexed */  /* STFDUX - Store Floating-Point Double with Update Indexed */
# Line 3122  static fastcall int ppc32_exec_STFDUX(cp Line 3116  static fastcall int ppc32_exec_STFDUX(cp
3116     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
3117     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
3118     m_uint32_t vaddr;     m_uint32_t vaddr;
    int res;  
3119    
3120     vaddr = cpu->gpr[ra] + cpu->gpr[rb];     vaddr = cpu->gpr[ra] + cpu->gpr[rb];
3121     res = ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs);     ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs);
3122     cpu->gpr[ra] = vaddr;     cpu->gpr[ra] = vaddr;
3123     return(res);     return(0);
3124  }  }
3125    
3126  /* STFDX - Store Floating-Point Double Indexed */  /* STFDX - Store Floating-Point Double Indexed */
# Line 3143  static fastcall int ppc32_exec_STFDX(cpu Line 3136  static fastcall int ppc32_exec_STFDX(cpu
3136     if (ra != 0)     if (ra != 0)
3137        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
3138    
3139     return(ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs));     ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs);
3140       return(0);
3141  }  }
3142    
3143  /* STSWI - Store String Word Immediate */  /* STSWI - Store String Word Immediate */
# Line 3153  static fastcall int ppc32_exec_STSWI(cpu Line 3147  static fastcall int ppc32_exec_STSWI(cpu
3147     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
3148     int nb = bits(insn,11,15);     int nb = bits(insn,11,15);
3149     m_uint32_t vaddr = 0;     m_uint32_t vaddr = 0;
3150     int res,r;     int r;
3151    
3152     if (ra != 0)     if (ra != 0)
3153        vaddr += cpu->gpr[ra];        vaddr += cpu->gpr[ra];
# Line 3168  static fastcall int ppc32_exec_STSWI(cpu Line 3162  static fastcall int ppc32_exec_STSWI(cpu
3162        if (cpu->sw_pos == 0)        if (cpu->sw_pos == 0)
3163           r = (r + 1) & 0x1F;           r = (r + 1) & 0x1F;
3164                
3165        if (unlikely(res = ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r)) != 0)        ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r);
          return(res);  
   
3166        cpu->sw_pos += 8;        cpu->sw_pos += 8;
3167    
3168        if (cpu->sw_pos == 32)        if (cpu->sw_pos == 32)
# Line 3190  static fastcall int ppc32_exec_STSWX(cpu Line 3182  static fastcall int ppc32_exec_STSWX(cpu
3182     int ra = bits(insn,16,20);     int ra = bits(insn,16,20);
3183     int rb = bits(insn,11,15);     int rb = bits(insn,11,15);
3184     m_uint32_t vaddr;     m_uint32_t vaddr;
3185     int res,r,nb;     int r,nb;
3186    
3187     vaddr = cpu->gpr[rb];     vaddr = cpu->gpr[rb];
3188    
# Line 3205  static fastcall int ppc32_exec_STSWX(cpu Line 3197  static fastcall int ppc32_exec_STSWX(cpu
3197        if (cpu->sw_pos == 0)        if (cpu->sw_pos == 0)
3198           r = (r + 1) & 0x1F;           r = (r + 1) & 0x1F;
3199                
3200        if (unlikely(res = ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r)) != 0)        ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r);
          return(res);  
   
3201        cpu->sw_pos += 8;        cpu->sw_pos += 8;
3202    
3203        if (cpu->sw_pos == 32)        if (cpu->sw_pos == 32)

Legend:
Removed from v.10  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC 1.1.26