| 1 |
/* |
| 2 |
* Cisco router simulation platform. |
| 3 |
* Copyright (c) 2005,2006 Christophe Fillot ([email protected]) |
| 4 |
* |
| 5 |
* PowerPC (32-bit) step-by-step execution. |
| 6 |
*/ |
| 7 |
|
| 8 |
#include <stdio.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include <unistd.h> |
| 11 |
#include <string.h> |
| 12 |
#include <sys/types.h> |
| 13 |
#include <sys/stat.h> |
| 14 |
#include <fcntl.h> |
| 15 |
#include <assert.h> |
| 16 |
|
| 17 |
#include "cpu.h" |
| 18 |
#include "vm.h" |
| 19 |
#include "ppc32_exec.h" |
| 20 |
#include "ppc32_mem.h" |
| 21 |
#include "memory.h" |
| 22 |
#include "insn_lookup.h" |
| 23 |
#include "dynamips.h" |
| 24 |
|
| 25 |
/* Forward declaration of instruction array */ |
| 26 |
static struct ppc32_insn_exec_tag ppc32_exec_tags[]; |
| 27 |
static insn_lookup_t *ilt = NULL; |
| 28 |
|
| 29 |
/* ILT */ |
| 30 |
static forced_inline void *ppc32_exec_get_insn(int index) |
| 31 |
{ |
| 32 |
return(&ppc32_exec_tags[index]); |
| 33 |
} |
| 34 |
|
| 35 |
static int ppc32_exec_chk_lo(struct ppc32_insn_exec_tag *tag,int value) |
| 36 |
{ |
| 37 |
return((value & tag->mask) == (tag->value & 0xFFFF)); |
| 38 |
} |
| 39 |
|
| 40 |
static int ppc32_exec_chk_hi(struct ppc32_insn_exec_tag *tag,int value) |
| 41 |
{ |
| 42 |
return((value & (tag->mask >> 16)) == (tag->value >> 16)); |
| 43 |
} |
| 44 |
|
| 45 |
/* Destroy instruction lookup table */ |
| 46 |
static void destroy_ilt(void) |
| 47 |
{ |
| 48 |
assert(ilt); |
| 49 |
ilt_destroy(ilt); |
| 50 |
ilt = NULL; |
| 51 |
} |
| 52 |
|
| 53 |
/* Initialize instruction lookup table */ |
| 54 |
void ppc32_exec_create_ilt(void) |
| 55 |
{ |
| 56 |
int i,count; |
| 57 |
|
| 58 |
for(i=0,count=0;ppc32_exec_tags[i].exec;i++) |
| 59 |
count++; |
| 60 |
|
| 61 |
ilt = ilt_create("ppc32e",count, |
| 62 |
(ilt_get_insn_cbk_t)ppc32_exec_get_insn, |
| 63 |
(ilt_check_cbk_t)ppc32_exec_chk_lo, |
| 64 |
(ilt_check_cbk_t)ppc32_exec_chk_hi); |
| 65 |
|
| 66 |
atexit(destroy_ilt); |
| 67 |
} |
| 68 |
|
| 69 |
/* Dump statistics */ |
| 70 |
void ppc32_dump_stats(cpu_ppc_t *cpu) |
| 71 |
{ |
| 72 |
int i; |
| 73 |
|
| 74 |
#if NJM_STATS_ENABLE |
| 75 |
printf("\n"); |
| 76 |
|
| 77 |
for(i=0;ppc32_exec_tags[i].exec;i++) |
| 78 |
printf(" * %-10s : %10llu\n", |
| 79 |
ppc32_exec_tags[i].name,ppc32_exec_tags[i].count); |
| 80 |
|
| 81 |
printf("%llu instructions executed since startup.\n",cpu->insn_exec_count); |
| 82 |
#else |
| 83 |
printf("Statistics support is not compiled in.\n"); |
| 84 |
#endif |
| 85 |
} |
| 86 |
|
| 87 |
/* Execute a memory operation */ |
| 88 |
static forced_inline void ppc32_exec_memop(cpu_ppc_t *cpu,int memop, |
| 89 |
m_uint32_t vaddr,u_int dst_reg) |
| 90 |
{ |
| 91 |
fastcall ppc_memop_fn fn; |
| 92 |
|
| 93 |
fn = cpu->mem_op_fn[memop]; |
| 94 |
fn(cpu,vaddr,dst_reg); |
| 95 |
} |
| 96 |
|
| 97 |
/* Fetch an instruction */ |
| 98 |
static forced_inline int ppc32_exec_fetch(cpu_ppc_t *cpu,m_uint32_t ia, |
| 99 |
ppc_insn_t *insn) |
| 100 |
{ |
| 101 |
m_uint32_t exec_page,offset; |
| 102 |
|
| 103 |
exec_page = ia & ~PPC32_MIN_PAGE_IMASK; |
| 104 |
|
| 105 |
if (unlikely(exec_page != cpu->njm_exec_page)) { |
| 106 |
cpu->njm_exec_page = exec_page; |
| 107 |
cpu->njm_exec_ptr = cpu->mem_op_lookup(cpu,exec_page,PPC32_MTS_ICACHE); |
| 108 |
} |
| 109 |
|
| 110 |
offset = (ia & PPC32_MIN_PAGE_IMASK) >> 2; |
| 111 |
*insn = vmtoh32(cpu->njm_exec_ptr[offset]); |
| 112 |
return(0); |
| 113 |
} |
| 114 |
|
| 115 |
/* Unknown opcode */ |
| 116 |
static fastcall int ppc32_exec_unknown(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 117 |
{ |
| 118 |
printf("PPC32: unknown opcode 0x%8.8x at ia = 0x%x\n",insn,cpu->ia); |
| 119 |
ppc32_dump_regs(cpu->gen); |
| 120 |
return(0); |
| 121 |
} |
| 122 |
|
| 123 |
/* Execute a single instruction */ |
| 124 |
static forced_inline int |
| 125 |
ppc32_exec_single_instruction(cpu_ppc_t *cpu,ppc_insn_t instruction) |
| 126 |
{ |
| 127 |
register fastcall int (*exec)(cpu_ppc_t *,ppc_insn_t) = NULL; |
| 128 |
struct ppc32_insn_exec_tag *tag; |
| 129 |
int index; |
| 130 |
|
| 131 |
#if DEBUG_INSN_PERF_CNT |
| 132 |
cpu->perf_counter++; |
| 133 |
#endif |
| 134 |
|
| 135 |
/* Lookup for instruction */ |
| 136 |
index = ilt_lookup(ilt,instruction); |
| 137 |
tag = ppc32_exec_get_insn(index); |
| 138 |
exec = tag->exec; |
| 139 |
|
| 140 |
#if NJM_STATS_ENABLE |
| 141 |
cpu->insn_exec_count++; |
| 142 |
ppc32_exec_tags[index].count++; |
| 143 |
#endif |
| 144 |
return(exec(cpu,instruction)); |
| 145 |
} |
| 146 |
|
| 147 |
/* Execute a single instruction (external) */ |
| 148 |
fastcall int ppc32_exec_single_insn_ext(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 149 |
{ |
| 150 |
int res; |
| 151 |
|
| 152 |
res = ppc32_exec_single_instruction(cpu,insn); |
| 153 |
if (likely(!res)) cpu->ia += sizeof(ppc_insn_t); |
| 154 |
return(res); |
| 155 |
} |
| 156 |
|
| 157 |
/* Execute a page */ |
| 158 |
fastcall int ppc32_exec_page(cpu_ppc_t *cpu) |
| 159 |
{ |
| 160 |
m_uint32_t exec_page,offset; |
| 161 |
ppc_insn_t insn; |
| 162 |
int res; |
| 163 |
|
| 164 |
exec_page = cpu->ia & ~PPC32_MIN_PAGE_IMASK; |
| 165 |
cpu->njm_exec_page = exec_page; |
| 166 |
cpu->njm_exec_ptr = cpu->mem_op_lookup(cpu,exec_page,PPC32_MTS_ICACHE); |
| 167 |
|
| 168 |
do { |
| 169 |
offset = (cpu->ia & PPC32_MIN_PAGE_IMASK) >> 2; |
| 170 |
insn = vmtoh32(cpu->njm_exec_ptr[offset]); |
| 171 |
|
| 172 |
res = ppc32_exec_single_instruction(cpu,insn); |
| 173 |
if (likely(!res)) cpu->ia += sizeof(ppc_insn_t); |
| 174 |
}while((cpu->ia & ~PPC32_MIN_PAGE_IMASK) == exec_page); |
| 175 |
|
| 176 |
return(0); |
| 177 |
} |
| 178 |
|
| 179 |
/* Run PowerPC code in step-by-step mode */ |
| 180 |
void *ppc32_exec_run_cpu(cpu_gen_t *gen) |
| 181 |
{ |
| 182 |
cpu_ppc_t *cpu = CPU_PPC32(gen); |
| 183 |
pthread_t timer_irq_thread; |
| 184 |
int timer_irq_check = 0; |
| 185 |
ppc_insn_t insn; |
| 186 |
int res; |
| 187 |
|
| 188 |
if (pthread_create(&timer_irq_thread,NULL, |
| 189 |
(void *)ppc32_timer_irq_run,cpu)) |
| 190 |
{ |
| 191 |
fprintf(stderr,"VM '%s': unable to create Timer IRQ thread for CPU%u.\n", |
| 192 |
cpu->vm->name,gen->id); |
| 193 |
cpu_stop(gen); |
| 194 |
return NULL; |
| 195 |
} |
| 196 |
|
| 197 |
gen->cpu_thread_running = TRUE; |
| 198 |
cpu_exec_loop_set(gen); |
| 199 |
|
| 200 |
start_cpu: |
| 201 |
for(;;) { |
| 202 |
if (unlikely(gen->state != CPU_STATE_RUNNING)) |
| 203 |
break; |
| 204 |
|
| 205 |
/* Check IRQ */ |
| 206 |
if (unlikely(cpu->irq_check)) |
| 207 |
ppc32_trigger_irq(cpu); |
| 208 |
|
| 209 |
/* Handle virtual idle loop */ |
| 210 |
if (unlikely(cpu->ia == cpu->idle_pc)) { |
| 211 |
if (++gen->idle_count == gen->idle_max) { |
| 212 |
cpu_idle_loop(gen); |
| 213 |
gen->idle_count = 0; |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
/* Handle the virtual CPU clock */ |
| 218 |
if (++timer_irq_check == cpu->timer_irq_check_itv) { |
| 219 |
timer_irq_check = 0; |
| 220 |
|
| 221 |
if (cpu->timer_irq_pending && !cpu->irq_disable && |
| 222 |
(cpu->msr & PPC32_MSR_EE)) |
| 223 |
{ |
| 224 |
cpu->timer_irq_armed = 0; |
| 225 |
cpu->timer_irq_pending--; |
| 226 |
|
| 227 |
vm_set_irq(cpu->vm,0); |
| 228 |
//ppc32_trigger_timer_irq(cpu); |
| 229 |
} |
| 230 |
} |
| 231 |
|
| 232 |
/* Increment the time base */ |
| 233 |
cpu->tb += 100; |
| 234 |
|
| 235 |
/* Fetch and execute the instruction */ |
| 236 |
ppc32_exec_fetch(cpu,cpu->ia,&insn); |
| 237 |
res = ppc32_exec_single_instruction(cpu,insn); |
| 238 |
|
| 239 |
/* Normal flow ? */ |
| 240 |
if (likely(!res)) cpu->ia += sizeof(ppc_insn_t); |
| 241 |
} |
| 242 |
|
| 243 |
/* Check regularly if the CPU has been restarted */ |
| 244 |
while(gen->cpu_thread_running) { |
| 245 |
gen->seq_state++; |
| 246 |
|
| 247 |
switch(gen->state) { |
| 248 |
case CPU_STATE_RUNNING: |
| 249 |
gen->state = CPU_STATE_RUNNING; |
| 250 |
goto start_cpu; |
| 251 |
|
| 252 |
case CPU_STATE_HALTED: |
| 253 |
gen->cpu_thread_running = FALSE; |
| 254 |
pthread_join(timer_irq_thread,NULL); |
| 255 |
break; |
| 256 |
} |
| 257 |
|
| 258 |
/* CPU is paused */ |
| 259 |
usleep(200000); |
| 260 |
} |
| 261 |
|
| 262 |
return NULL; |
| 263 |
} |
| 264 |
|
| 265 |
/* ========================================================================= */ |
| 266 |
|
| 267 |
/* Update CR0 */ |
| 268 |
static forced_inline void ppc32_exec_update_cr0(cpu_ppc_t *cpu,m_uint32_t val) |
| 269 |
{ |
| 270 |
m_uint32_t res; |
| 271 |
|
| 272 |
if (val & 0x80000000) |
| 273 |
res = 1 << PPC32_CR_LT_BIT; |
| 274 |
else { |
| 275 |
if (val > 0) |
| 276 |
res = 1 << PPC32_CR_GT_BIT; |
| 277 |
else |
| 278 |
res = 1 << PPC32_CR_EQ_BIT; |
| 279 |
} |
| 280 |
|
| 281 |
if (cpu->xer & PPC32_XER_SO) |
| 282 |
res |= 1 << PPC32_CR_SO_BIT; |
| 283 |
|
| 284 |
cpu->cr_fields[0] = res; |
| 285 |
} |
| 286 |
|
| 287 |
/* |
| 288 |
* Update Overflow bit from a sum result (r = a + b) |
| 289 |
* |
| 290 |
* (a > 0) && (b > 0) => r > 0, otherwise overflow |
| 291 |
* (a < 0) && (a < 0) => r < 0, otherwise overflow. |
| 292 |
*/ |
| 293 |
static forced_inline void ppc32_exec_ov_sum(cpu_ppc_t *cpu,m_uint32_t r, |
| 294 |
m_uint32_t a,m_uint32_t b) |
| 295 |
{ |
| 296 |
register m_uint32_t sc; |
| 297 |
|
| 298 |
sc = (~(a ^ b) & (a ^ r) & 0x80000000); |
| 299 |
if (unlikely(sc)) |
| 300 |
cpu->xer |= PPC32_XER_SO | PPC32_XER_OV; |
| 301 |
else |
| 302 |
cpu->xer &= ~PPC32_XER_OV; |
| 303 |
} |
| 304 |
|
| 305 |
/* |
| 306 |
* Update Overflow bit from a substraction result (r = a - b) |
| 307 |
* |
| 308 |
* (a > 0) && (b < 0) => r > 0, otherwise overflow |
| 309 |
* (a < 0) && (a > 0) => r < 0, otherwise overflow. |
| 310 |
*/ |
| 311 |
static forced_inline void ppc32_exec_ov_sub(cpu_ppc_t *cpu,m_uint32_t r, |
| 312 |
m_uint32_t a,m_uint32_t b) |
| 313 |
{ |
| 314 |
register m_uint32_t sc; |
| 315 |
|
| 316 |
sc = ((a ^ b) & (a ^ r) & 0x80000000); |
| 317 |
if (unlikely(sc)) |
| 318 |
cpu->xer |= PPC32_XER_SO | PPC32_XER_OV; |
| 319 |
else |
| 320 |
cpu->xer &= ~PPC32_XER_OV; |
| 321 |
} |
| 322 |
|
| 323 |
/* |
| 324 |
* Update CA bit from a sum result (r = a + b) |
| 325 |
*/ |
| 326 |
static forced_inline void ppc32_exec_ca_sum(cpu_ppc_t *cpu,m_uint32_t r, |
| 327 |
m_uint32_t a,m_uint32_t b) |
| 328 |
{ |
| 329 |
cpu->xer_ca = (r < a) ? 1 : 0; |
| 330 |
} |
| 331 |
|
| 332 |
/* |
| 333 |
* Update CA bit from a substraction result (r = a - b) |
| 334 |
*/ |
| 335 |
static forced_inline void ppc32_exec_ca_sub(cpu_ppc_t *cpu,m_uint32_t r, |
| 336 |
m_uint32_t a,m_uint32_t b) |
| 337 |
{ |
| 338 |
cpu->xer_ca = (b > a) ? 1 : 0; |
| 339 |
} |
| 340 |
|
| 341 |
/* Check condition code */ |
| 342 |
static forced_inline int ppc32_check_cond(cpu_ppc_t *cpu,m_uint32_t bo, |
| 343 |
m_uint32_t bi) |
| 344 |
{ |
| 345 |
u_int ctr_ok = TRUE; |
| 346 |
u_int cond_ok; |
| 347 |
u_int cr_bit; |
| 348 |
|
| 349 |
if (!(bo & 0x04)) { |
| 350 |
cpu->ctr--; |
| 351 |
ctr_ok = (cpu->ctr != 0) ^ ((bo >> 1) & 0x1); |
| 352 |
} |
| 353 |
|
| 354 |
cr_bit = ppc32_read_cr_bit(cpu,bi); |
| 355 |
cond_ok = (bo >> 4) | ((cr_bit ^ (~bo >> 3)) & 0x1); |
| 356 |
|
| 357 |
return(ctr_ok & cond_ok); |
| 358 |
} |
| 359 |
|
| 360 |
/* MFLR - Move From Link Register */ |
| 361 |
static fastcall int ppc32_exec_MFLR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 362 |
{ |
| 363 |
int rd = bits(insn,21,25); |
| 364 |
|
| 365 |
cpu->gpr[rd] = cpu->lr; |
| 366 |
return(0); |
| 367 |
} |
| 368 |
|
| 369 |
/* MTLR - Move To Link Register */ |
| 370 |
static fastcall int ppc32_exec_MTLR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 371 |
{ |
| 372 |
int rs = bits(insn,21,25); |
| 373 |
|
| 374 |
cpu->lr = cpu->gpr[rs]; |
| 375 |
return(0); |
| 376 |
} |
| 377 |
|
| 378 |
/* MFCTR - Move From Counter Register */ |
| 379 |
static fastcall int ppc32_exec_MFCTR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 380 |
{ |
| 381 |
int rd = bits(insn,21,25); |
| 382 |
|
| 383 |
cpu->gpr[rd] = cpu->ctr; |
| 384 |
return(0); |
| 385 |
} |
| 386 |
|
| 387 |
/* MTCTR - Move To Counter Register */ |
| 388 |
static fastcall int ppc32_exec_MTCTR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 389 |
{ |
| 390 |
int rs = bits(insn,21,25); |
| 391 |
|
| 392 |
cpu->ctr = cpu->gpr[rs]; |
| 393 |
return(0); |
| 394 |
} |
| 395 |
|
| 396 |
/* ADD */ |
| 397 |
static fastcall int ppc32_exec_ADD(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 398 |
{ |
| 399 |
int rd = bits(insn,21,25); |
| 400 |
int ra = bits(insn,16,20); |
| 401 |
int rb = bits(insn,11,15); |
| 402 |
|
| 403 |
cpu->gpr[rd] = cpu->gpr[ra] + cpu->gpr[rb]; |
| 404 |
return(0); |
| 405 |
} |
| 406 |
|
| 407 |
/* ADD. */ |
| 408 |
static fastcall int ppc32_exec_ADD_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 409 |
{ |
| 410 |
int rd = bits(insn,21,25); |
| 411 |
int ra = bits(insn,16,20); |
| 412 |
int rb = bits(insn,11,15); |
| 413 |
register m_uint32_t tmp; |
| 414 |
|
| 415 |
tmp = cpu->gpr[ra] + cpu->gpr[rb]; |
| 416 |
ppc32_exec_update_cr0(cpu,tmp); |
| 417 |
cpu->gpr[rd] = tmp; |
| 418 |
return(0); |
| 419 |
} |
| 420 |
|
| 421 |
/* ADDO - Add with Overflow */ |
| 422 |
static fastcall int ppc32_exec_ADDO(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 423 |
{ |
| 424 |
int rd = bits(insn,21,25); |
| 425 |
int ra = bits(insn,16,20); |
| 426 |
int rb = bits(insn,11,15); |
| 427 |
register m_uint32_t a,b,d; |
| 428 |
|
| 429 |
a = cpu->gpr[ra]; |
| 430 |
b = cpu->gpr[rb]; |
| 431 |
d = a + b; |
| 432 |
|
| 433 |
ppc32_exec_ov_sum(cpu,d,a,b); |
| 434 |
cpu->gpr[rd] = d; |
| 435 |
return(0); |
| 436 |
} |
| 437 |
|
| 438 |
/* ADDO. */ |
| 439 |
static fastcall int ppc32_exec_ADDO_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 440 |
{ |
| 441 |
int rd = bits(insn,21,25); |
| 442 |
int ra = bits(insn,16,20); |
| 443 |
int rb = bits(insn,11,15); |
| 444 |
register m_uint32_t a,b,d; |
| 445 |
|
| 446 |
a = cpu->gpr[ra]; |
| 447 |
b = cpu->gpr[rb]; |
| 448 |
d = a + b; |
| 449 |
|
| 450 |
ppc32_exec_ov_sum(cpu,d,a,b); |
| 451 |
ppc32_exec_update_cr0(cpu,d); |
| 452 |
cpu->gpr[rd] = d; |
| 453 |
return(0); |
| 454 |
} |
| 455 |
|
| 456 |
/* ADDC - Add Carrying */ |
| 457 |
static fastcall int ppc32_exec_ADDC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 458 |
{ |
| 459 |
int rd = bits(insn,21,25); |
| 460 |
int ra = bits(insn,16,20); |
| 461 |
int rb = bits(insn,11,15); |
| 462 |
register m_uint32_t a,b,d; |
| 463 |
|
| 464 |
a = cpu->gpr[ra]; |
| 465 |
b = cpu->gpr[rb]; |
| 466 |
d = a + b; |
| 467 |
|
| 468 |
ppc32_exec_ca_sum(cpu,d,a,b); |
| 469 |
cpu->gpr[rd] = d; |
| 470 |
return(0); |
| 471 |
} |
| 472 |
|
| 473 |
/* ADDC. */ |
| 474 |
static fastcall int ppc32_exec_ADDC_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 475 |
{ |
| 476 |
int rd = bits(insn,21,25); |
| 477 |
int ra = bits(insn,16,20); |
| 478 |
int rb = bits(insn,11,15); |
| 479 |
register m_uint32_t a,b,d; |
| 480 |
|
| 481 |
a = cpu->gpr[ra]; |
| 482 |
b = cpu->gpr[rb]; |
| 483 |
d = a + b; |
| 484 |
|
| 485 |
ppc32_exec_ca_sum(cpu,d,a,b); |
| 486 |
ppc32_exec_update_cr0(cpu,d); |
| 487 |
cpu->gpr[rd] = d; |
| 488 |
return(0); |
| 489 |
} |
| 490 |
|
| 491 |
/* ADDCO - Add Carrying with Overflow */ |
| 492 |
static fastcall int ppc32_exec_ADDCO(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 493 |
{ |
| 494 |
int rd = bits(insn,21,25); |
| 495 |
int ra = bits(insn,16,20); |
| 496 |
int rb = bits(insn,11,15); |
| 497 |
register m_uint32_t a,b,d; |
| 498 |
|
| 499 |
a = cpu->gpr[ra]; |
| 500 |
b = cpu->gpr[rb]; |
| 501 |
d = a + b; |
| 502 |
|
| 503 |
ppc32_exec_ca_sum(cpu,d,a,b); |
| 504 |
ppc32_exec_ov_sum(cpu,d,a,b); |
| 505 |
cpu->gpr[rd] = d; |
| 506 |
return(0); |
| 507 |
} |
| 508 |
|
| 509 |
/* ADDCO. */ |
| 510 |
static fastcall int ppc32_exec_ADDCO_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 511 |
{ |
| 512 |
int rd = bits(insn,21,25); |
| 513 |
int ra = bits(insn,16,20); |
| 514 |
int rb = bits(insn,11,15); |
| 515 |
register m_uint32_t a,b,d; |
| 516 |
|
| 517 |
a = cpu->gpr[ra]; |
| 518 |
b = cpu->gpr[rb]; |
| 519 |
d = a + b; |
| 520 |
|
| 521 |
ppc32_exec_ca_sum(cpu,d,a,b); |
| 522 |
ppc32_exec_ov_sum(cpu,d,a,b); |
| 523 |
ppc32_exec_update_cr0(cpu,d); |
| 524 |
cpu->gpr[rd] = d; |
| 525 |
return(0); |
| 526 |
} |
| 527 |
|
| 528 |
/* ADDE - Add Extended */ |
| 529 |
static fastcall int ppc32_exec_ADDE(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 530 |
{ |
| 531 |
int rd = bits(insn,21,25); |
| 532 |
int ra = bits(insn,16,20); |
| 533 |
int rb = bits(insn,11,15); |
| 534 |
register m_uint32_t a,b,d; |
| 535 |
m_uint32_t carry; |
| 536 |
|
| 537 |
carry = cpu->xer_ca; |
| 538 |
cpu->xer_ca = 0; |
| 539 |
|
| 540 |
a = cpu->gpr[ra]; |
| 541 |
b = cpu->gpr[rb]; |
| 542 |
d = a + b + carry; |
| 543 |
|
| 544 |
if (((b + carry) < b) || (d < a)) |
| 545 |
cpu->xer_ca = 1; |
| 546 |
|
| 547 |
cpu->gpr[rd] = d; |
| 548 |
return(0); |
| 549 |
} |
| 550 |
|
| 551 |
/* ADDE. */ |
| 552 |
static fastcall int ppc32_exec_ADDE_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 553 |
{ |
| 554 |
int rd = bits(insn,21,25); |
| 555 |
int ra = bits(insn,16,20); |
| 556 |
int rb = bits(insn,11,15); |
| 557 |
register m_uint32_t a,b,d; |
| 558 |
m_uint32_t carry; |
| 559 |
|
| 560 |
carry = cpu->xer_ca; |
| 561 |
cpu->xer_ca = 0; |
| 562 |
|
| 563 |
a = cpu->gpr[ra]; |
| 564 |
b = cpu->gpr[rb]; |
| 565 |
d = a + b + carry; |
| 566 |
|
| 567 |
if (((b + carry) < b) || (d < a)) |
| 568 |
cpu->xer_ca = 1; |
| 569 |
|
| 570 |
ppc32_exec_update_cr0(cpu,d); |
| 571 |
cpu->gpr[rd] = d; |
| 572 |
return(0); |
| 573 |
} |
| 574 |
|
| 575 |
/* ADDEO - Add Extended with Overflow */ |
| 576 |
static fastcall int ppc32_exec_ADDEO(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 577 |
{ |
| 578 |
int rd = bits(insn,21,25); |
| 579 |
int ra = bits(insn,16,20); |
| 580 |
int rb = bits(insn,11,15); |
| 581 |
register m_uint32_t a,b,d; |
| 582 |
m_uint32_t carry; |
| 583 |
|
| 584 |
carry = cpu->xer_ca; |
| 585 |
cpu->xer_ca = 0; |
| 586 |
|
| 587 |
a = cpu->gpr[ra]; |
| 588 |
b = cpu->gpr[rb]; |
| 589 |
d = a + b + carry; |
| 590 |
|
| 591 |
if (((b + carry) < b) || (d < a)) |
| 592 |
cpu->xer_ca = 1; |
| 593 |
|
| 594 |
ppc32_exec_ov_sum(cpu,d,a,b); |
| 595 |
cpu->gpr[rd] = d; |
| 596 |
return(0); |
| 597 |
} |
| 598 |
|
| 599 |
/* ADDEO. */ |
| 600 |
static fastcall int ppc32_exec_ADDEO_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 601 |
{ |
| 602 |
int rd = bits(insn,21,25); |
| 603 |
int ra = bits(insn,16,20); |
| 604 |
int rb = bits(insn,11,15); |
| 605 |
register m_uint32_t a,b,d; |
| 606 |
m_uint32_t carry; |
| 607 |
|
| 608 |
carry = cpu->xer_ca; |
| 609 |
cpu->xer_ca = 0; |
| 610 |
|
| 611 |
a = cpu->gpr[ra]; |
| 612 |
b = cpu->gpr[rb]; |
| 613 |
d = a + b + carry; |
| 614 |
|
| 615 |
if (((b + carry) < b) || (d < a)) |
| 616 |
cpu->xer_ca = 1; |
| 617 |
|
| 618 |
ppc32_exec_ov_sum(cpu,d,a,b); |
| 619 |
ppc32_exec_update_cr0(cpu,d); |
| 620 |
cpu->gpr[rd] = d; |
| 621 |
return(0); |
| 622 |
} |
| 623 |
|
| 624 |
/* ADDI - ADD Immediate */ |
| 625 |
static fastcall int ppc32_exec_ADDI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 626 |
{ |
| 627 |
int rd = bits(insn,21,25); |
| 628 |
int ra = bits(insn,16,20); |
| 629 |
int imm = bits(insn,0,15); |
| 630 |
register m_uint32_t tmp; |
| 631 |
|
| 632 |
tmp = sign_extend_32(imm,16); |
| 633 |
|
| 634 |
if (ra != 0) |
| 635 |
tmp += cpu->gpr[ra]; |
| 636 |
|
| 637 |
cpu->gpr[rd] = tmp; |
| 638 |
return(0); |
| 639 |
} |
| 640 |
|
| 641 |
/* ADDIC - ADD Immediate with Carry */ |
| 642 |
static fastcall int ppc32_exec_ADDIC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 643 |
{ |
| 644 |
int rd = bits(insn,21,25); |
| 645 |
int ra = bits(insn,16,20); |
| 646 |
int imm = bits(insn,0,15); |
| 647 |
register m_uint32_t a,d; |
| 648 |
|
| 649 |
a = cpu->gpr[ra]; |
| 650 |
d = a + sign_extend_32(imm,16); |
| 651 |
ppc32_exec_ca_sum(cpu,d,a,0); |
| 652 |
cpu->gpr[rd] = d; |
| 653 |
return(0); |
| 654 |
} |
| 655 |
|
| 656 |
/* ADDIC. */ |
| 657 |
static fastcall int ppc32_exec_ADDIC_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 658 |
{ |
| 659 |
int rd = bits(insn,21,25); |
| 660 |
int ra = bits(insn,16,20); |
| 661 |
int imm = bits(insn,0,15); |
| 662 |
register m_uint32_t a,d; |
| 663 |
|
| 664 |
a = cpu->gpr[ra]; |
| 665 |
d = a + sign_extend_32(imm,16); |
| 666 |
ppc32_exec_ca_sum(cpu,d,a,0); |
| 667 |
ppc32_exec_update_cr0(cpu,d); |
| 668 |
cpu->gpr[rd] = d; |
| 669 |
return(0); |
| 670 |
} |
| 671 |
|
| 672 |
/* ADDIS - ADD Immediate Shifted */ |
| 673 |
static fastcall int ppc32_exec_ADDIS(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 674 |
{ |
| 675 |
int rd = bits(insn,21,25); |
| 676 |
int ra = bits(insn,16,20); |
| 677 |
m_uint32_t imm = bits(insn,0,15); |
| 678 |
register m_uint32_t tmp; |
| 679 |
|
| 680 |
tmp = imm << 16; |
| 681 |
|
| 682 |
if (ra != 0) |
| 683 |
tmp += cpu->gpr[ra]; |
| 684 |
|
| 685 |
cpu->gpr[rd] = tmp; |
| 686 |
return(0); |
| 687 |
} |
| 688 |
|
| 689 |
/* ADDME - Add to Minus One Extended */ |
| 690 |
static fastcall int ppc32_exec_ADDME(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 691 |
{ |
| 692 |
int rd = bits(insn,21,25); |
| 693 |
int ra = bits(insn,16,20); |
| 694 |
register m_uint32_t a,b,d; |
| 695 |
m_uint32_t carry; |
| 696 |
|
| 697 |
carry = cpu->xer_ca; |
| 698 |
cpu->xer_ca = 0; |
| 699 |
|
| 700 |
a = cpu->gpr[ra]; |
| 701 |
b = 0xFFFFFFFF; |
| 702 |
d = a + b + carry; |
| 703 |
|
| 704 |
if (((b + carry) < b) || (d < a)) |
| 705 |
cpu->xer_ca = 1; |
| 706 |
|
| 707 |
cpu->gpr[rd] = d; |
| 708 |
return(0); |
| 709 |
} |
| 710 |
|
| 711 |
/* ADDME. */ |
| 712 |
static fastcall int ppc32_exec_ADDME_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 713 |
{ |
| 714 |
int rd = bits(insn,21,25); |
| 715 |
int ra = bits(insn,16,20); |
| 716 |
register m_uint32_t a,b,d; |
| 717 |
m_uint32_t carry; |
| 718 |
|
| 719 |
carry = cpu->xer_ca; |
| 720 |
cpu->xer_ca = 0; |
| 721 |
|
| 722 |
a = cpu->gpr[ra]; |
| 723 |
b = 0xFFFFFFFF; |
| 724 |
d = a + b + carry; |
| 725 |
|
| 726 |
if (((b + carry) < b) || (d < a)) |
| 727 |
cpu->xer_ca = 1; |
| 728 |
|
| 729 |
ppc32_exec_update_cr0(cpu,d); |
| 730 |
cpu->gpr[rd] = d; |
| 731 |
return(0); |
| 732 |
} |
| 733 |
|
| 734 |
/* ADDZE - Add to Zero Extended */ |
| 735 |
static fastcall int ppc32_exec_ADDZE(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 736 |
{ |
| 737 |
int rd = bits(insn,21,25); |
| 738 |
int ra = bits(insn,16,20); |
| 739 |
register m_uint32_t a,d; |
| 740 |
m_uint32_t carry; |
| 741 |
|
| 742 |
carry = cpu->xer_ca; |
| 743 |
cpu->xer_ca = 0; |
| 744 |
|
| 745 |
a = cpu->gpr[ra]; |
| 746 |
d = a + carry; |
| 747 |
|
| 748 |
if (d < a) |
| 749 |
cpu->xer_ca = 1; |
| 750 |
|
| 751 |
cpu->gpr[rd] = d; |
| 752 |
return(0); |
| 753 |
} |
| 754 |
|
| 755 |
/* ADDZE. */ |
| 756 |
static fastcall int ppc32_exec_ADDZE_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 757 |
{ |
| 758 |
int rd = bits(insn,21,25); |
| 759 |
int ra = bits(insn,16,20); |
| 760 |
register m_uint32_t a,d; |
| 761 |
m_uint32_t carry; |
| 762 |
|
| 763 |
carry = cpu->xer_ca; |
| 764 |
cpu->xer_ca = 0; |
| 765 |
|
| 766 |
a = cpu->gpr[ra]; |
| 767 |
d = a + carry; |
| 768 |
|
| 769 |
if (d < a) |
| 770 |
cpu->xer_ca = 1; |
| 771 |
|
| 772 |
ppc32_exec_update_cr0(cpu,d); |
| 773 |
cpu->gpr[rd] = d; |
| 774 |
return(0); |
| 775 |
} |
| 776 |
|
| 777 |
/* AND */ |
| 778 |
static fastcall int ppc32_exec_AND(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 779 |
{ |
| 780 |
int rs = bits(insn,21,25); |
| 781 |
int ra = bits(insn,16,20); |
| 782 |
int rb = bits(insn,11,15); |
| 783 |
|
| 784 |
cpu->gpr[ra] = cpu->gpr[rs] & cpu->gpr[rb]; |
| 785 |
return(0); |
| 786 |
} |
| 787 |
|
| 788 |
/* AND. */ |
| 789 |
static fastcall int ppc32_exec_AND_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 790 |
{ |
| 791 |
int rs = bits(insn,21,25); |
| 792 |
int ra = bits(insn,16,20); |
| 793 |
int rb = bits(insn,11,15); |
| 794 |
m_uint32_t tmp; |
| 795 |
|
| 796 |
tmp = cpu->gpr[rs] & cpu->gpr[rb]; |
| 797 |
ppc32_exec_update_cr0(cpu,tmp); |
| 798 |
cpu->gpr[ra] = tmp; |
| 799 |
return(0); |
| 800 |
} |
| 801 |
|
| 802 |
/* ANDC - AND with Complement */ |
| 803 |
static fastcall int ppc32_exec_ANDC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 804 |
{ |
| 805 |
int rs = bits(insn,21,25); |
| 806 |
int ra = bits(insn,16,20); |
| 807 |
int rb = bits(insn,11,15); |
| 808 |
|
| 809 |
cpu->gpr[ra] = cpu->gpr[rs] & (~cpu->gpr[rb]); |
| 810 |
return(0); |
| 811 |
} |
| 812 |
|
| 813 |
/* ANDC. - AND with Complement */ |
| 814 |
static fastcall int ppc32_exec_ANDC_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 815 |
{ |
| 816 |
int rs = bits(insn,21,25); |
| 817 |
int ra = bits(insn,16,20); |
| 818 |
int rb = bits(insn,11,15); |
| 819 |
m_uint32_t tmp; |
| 820 |
|
| 821 |
tmp = cpu->gpr[rs] & (~cpu->gpr[rb]); |
| 822 |
ppc32_exec_update_cr0(cpu,tmp); |
| 823 |
cpu->gpr[ra] = tmp; |
| 824 |
return(0); |
| 825 |
} |
| 826 |
|
| 827 |
/* ANDI. - AND Immediate */ |
| 828 |
static fastcall int ppc32_exec_ANDI_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 829 |
{ |
| 830 |
int rs = bits(insn,21,25); |
| 831 |
int ra = bits(insn,16,20); |
| 832 |
m_uint16_t imm = bits(insn,0,15); |
| 833 |
register m_uint32_t tmp; |
| 834 |
|
| 835 |
tmp = cpu->gpr[rs] & imm; |
| 836 |
ppc32_exec_update_cr0(cpu,tmp); |
| 837 |
cpu->gpr[ra] = tmp; |
| 838 |
return(0); |
| 839 |
} |
| 840 |
|
| 841 |
/* ANDIS. - AND Immediate Shifted */ |
| 842 |
static fastcall int ppc32_exec_ANDIS_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 843 |
{ |
| 844 |
int rs = bits(insn,21,25); |
| 845 |
int ra = bits(insn,16,20); |
| 846 |
m_uint32_t imm = bits(insn,0,15); |
| 847 |
register m_uint32_t tmp; |
| 848 |
|
| 849 |
tmp = cpu->gpr[rs] & (imm << 16); |
| 850 |
ppc32_exec_update_cr0(cpu,tmp); |
| 851 |
cpu->gpr[ra] = tmp; |
| 852 |
return(0); |
| 853 |
} |
| 854 |
|
| 855 |
/* B - Branch */ |
| 856 |
static fastcall int ppc32_exec_B(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 857 |
{ |
| 858 |
m_uint32_t offset = bits(insn,2,25); |
| 859 |
|
| 860 |
cpu->ia += sign_extend_32(offset << 2,26); |
| 861 |
return(1); |
| 862 |
} |
| 863 |
|
| 864 |
/* BA - Branch Absolute */ |
| 865 |
static fastcall int ppc32_exec_BA(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 866 |
{ |
| 867 |
m_uint32_t offset = bits(insn,2,25); |
| 868 |
|
| 869 |
cpu->ia = sign_extend_32(offset << 2,26); |
| 870 |
return(1); |
| 871 |
} |
| 872 |
|
| 873 |
/* BL - Branch and Link */ |
| 874 |
static fastcall int ppc32_exec_BL(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 875 |
{ |
| 876 |
m_uint32_t offset = bits(insn,2,25); |
| 877 |
|
| 878 |
cpu->lr = cpu->ia + 4; |
| 879 |
cpu->ia += sign_extend_32(offset << 2,26); |
| 880 |
return(1); |
| 881 |
} |
| 882 |
|
| 883 |
/* BLA - Branch and Link Absolute */ |
| 884 |
static fastcall int ppc32_exec_BLA(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 885 |
{ |
| 886 |
m_uint32_t offset = bits(insn,2,25); |
| 887 |
|
| 888 |
cpu->lr = cpu->ia + 4; |
| 889 |
cpu->ia = sign_extend_32(offset << 2,26); |
| 890 |
return(1); |
| 891 |
} |
| 892 |
|
| 893 |
/* BC - Branch Conditional */ |
| 894 |
static fastcall int ppc32_exec_BC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 895 |
{ |
| 896 |
int bo = bits(insn,21,25); |
| 897 |
int bi = bits(insn,16,20); |
| 898 |
int bd = bits(insn,2,15); |
| 899 |
|
| 900 |
if (ppc32_check_cond(cpu,bo,bi)) { |
| 901 |
cpu->ia += sign_extend_32(bd << 2,16); |
| 902 |
return(1); |
| 903 |
} |
| 904 |
|
| 905 |
return(0); |
| 906 |
} |
| 907 |
|
| 908 |
/* BCA - Branch Conditional (absolute) */ |
| 909 |
static fastcall int ppc32_exec_BCA(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 910 |
{ |
| 911 |
int bo = bits(insn,21,25); |
| 912 |
int bi = bits(insn,16,20); |
| 913 |
int bd = bits(insn,2,15); |
| 914 |
|
| 915 |
if (ppc32_check_cond(cpu,bo,bi)) { |
| 916 |
cpu->ia = sign_extend_32(bd << 2,16); |
| 917 |
return(1); |
| 918 |
} |
| 919 |
|
| 920 |
return(0); |
| 921 |
} |
| 922 |
|
| 923 |
/* BCL - Branch Conditional and Link */ |
| 924 |
static fastcall int ppc32_exec_BCL(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 925 |
{ |
| 926 |
int bo = bits(insn,21,25); |
| 927 |
int bi = bits(insn,16,20); |
| 928 |
int bd = bits(insn,2,15); |
| 929 |
|
| 930 |
cpu->lr = cpu->ia + 4; |
| 931 |
|
| 932 |
if (ppc32_check_cond(cpu,bo,bi)) { |
| 933 |
cpu->ia += sign_extend_32(bd << 2,16); |
| 934 |
return(1); |
| 935 |
} |
| 936 |
|
| 937 |
return(0); |
| 938 |
} |
| 939 |
|
| 940 |
/* BCLA - Branch Conditional and Link (absolute) */ |
| 941 |
static fastcall int ppc32_exec_BCLA(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 942 |
{ |
| 943 |
int bo = bits(insn,21,25); |
| 944 |
int bi = bits(insn,16,20); |
| 945 |
int bd = bits(insn,2,15); |
| 946 |
|
| 947 |
cpu->lr = cpu->ia + 4; |
| 948 |
|
| 949 |
if (ppc32_check_cond(cpu,bo,bi)) { |
| 950 |
cpu->ia = sign_extend_32(bd << 2,16); |
| 951 |
return(1); |
| 952 |
} |
| 953 |
|
| 954 |
return(0); |
| 955 |
} |
| 956 |
|
| 957 |
/* BCLR - Branch Conditional to Link register */ |
| 958 |
static fastcall int ppc32_exec_BCLR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 959 |
{ |
| 960 |
int bo = bits(insn,21,25); |
| 961 |
int bi = bits(insn,16,20); |
| 962 |
|
| 963 |
if (ppc32_check_cond(cpu,bo,bi)) { |
| 964 |
cpu->ia = cpu->lr & ~0x3; |
| 965 |
return(1); |
| 966 |
} |
| 967 |
|
| 968 |
return(0); |
| 969 |
} |
| 970 |
|
| 971 |
/* BCLRL - Branch Conditional to Link register */ |
| 972 |
static fastcall int ppc32_exec_BCLRL(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 973 |
{ |
| 974 |
int bo = bits(insn,21,25); |
| 975 |
int bi = bits(insn,16,20); |
| 976 |
m_uint32_t new_ia; |
| 977 |
|
| 978 |
new_ia = cpu->lr & ~0x03; |
| 979 |
cpu->lr = cpu->ia + 4; |
| 980 |
|
| 981 |
if (ppc32_check_cond(cpu,bo,bi)) { |
| 982 |
cpu->ia = new_ia; |
| 983 |
return(1); |
| 984 |
} |
| 985 |
|
| 986 |
return(0); |
| 987 |
} |
| 988 |
|
| 989 |
/* BCCTR - Branch Conditional to Count register */ |
| 990 |
static fastcall int ppc32_exec_BCCTR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 991 |
{ |
| 992 |
int bo = bits(insn,21,25); |
| 993 |
int bi = bits(insn,16,20); |
| 994 |
|
| 995 |
if (ppc32_check_cond(cpu,bo,bi)) { |
| 996 |
cpu->ia = cpu->ctr & ~0x3; |
| 997 |
return(1); |
| 998 |
} |
| 999 |
|
| 1000 |
return(0); |
| 1001 |
} |
| 1002 |
|
| 1003 |
/* BCCTRL - Branch Conditional to Count register and Link */ |
| 1004 |
static fastcall int ppc32_exec_BCCTRL(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1005 |
{ |
| 1006 |
int bo = bits(insn,21,25); |
| 1007 |
int bi = bits(insn,16,20); |
| 1008 |
|
| 1009 |
cpu->lr = cpu->ia + 4; |
| 1010 |
|
| 1011 |
if (ppc32_check_cond(cpu,bo,bi)) { |
| 1012 |
cpu->ia = cpu->ctr & ~0x3; |
| 1013 |
return(1); |
| 1014 |
} |
| 1015 |
|
| 1016 |
return(0); |
| 1017 |
} |
| 1018 |
|
| 1019 |
/* CMP - Compare */ |
| 1020 |
static fastcall int ppc32_exec_CMP(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1021 |
{ |
| 1022 |
int rd = bits(insn,23,25); |
| 1023 |
int ra = bits(insn,16,20); |
| 1024 |
int rb = bits(insn,11,15); |
| 1025 |
m_uint32_t res; |
| 1026 |
m_int32_t a,b; |
| 1027 |
|
| 1028 |
a = (m_int32_t)cpu->gpr[ra]; |
| 1029 |
b = (m_int32_t)cpu->gpr[rb]; |
| 1030 |
|
| 1031 |
if (a < b) |
| 1032 |
res = 0x08; |
| 1033 |
else { |
| 1034 |
if (a > b) |
| 1035 |
res = 0x04; |
| 1036 |
else |
| 1037 |
res = 0x02; |
| 1038 |
} |
| 1039 |
|
| 1040 |
if (cpu->xer & PPC32_XER_SO) |
| 1041 |
res |= 0x01; |
| 1042 |
|
| 1043 |
cpu->cr_fields[rd] = res; |
| 1044 |
return(0); |
| 1045 |
} |
| 1046 |
|
| 1047 |
/* CMPI - Compare Immediate */ |
| 1048 |
static fastcall int ppc32_exec_CMPI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1049 |
{ |
| 1050 |
int rd = bits(insn,23,25); |
| 1051 |
int ra = bits(insn,16,20); |
| 1052 |
m_uint16_t imm = bits(insn,0,15); |
| 1053 |
m_uint32_t res; |
| 1054 |
m_int32_t a,b; |
| 1055 |
|
| 1056 |
a = (m_int32_t)cpu->gpr[ra]; |
| 1057 |
b = sign_extend_32(imm,16); |
| 1058 |
|
| 1059 |
if (a < b) |
| 1060 |
res = 0x08; |
| 1061 |
else { |
| 1062 |
if (a > b) |
| 1063 |
res = 0x04; |
| 1064 |
else |
| 1065 |
res = 0x02; |
| 1066 |
} |
| 1067 |
|
| 1068 |
if (cpu->xer & PPC32_XER_SO) |
| 1069 |
res |= 0x01; |
| 1070 |
|
| 1071 |
cpu->cr_fields[rd] = res; |
| 1072 |
return(0); |
| 1073 |
} |
| 1074 |
|
| 1075 |
/* CMPL - Compare Logical */ |
| 1076 |
static fastcall int ppc32_exec_CMPL(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1077 |
{ |
| 1078 |
int rd = bits(insn,23,25); |
| 1079 |
int ra = bits(insn,16,20); |
| 1080 |
int rb = bits(insn,11,15); |
| 1081 |
m_uint32_t res,a,b; |
| 1082 |
|
| 1083 |
a = cpu->gpr[ra]; |
| 1084 |
b = cpu->gpr[rb]; |
| 1085 |
|
| 1086 |
if (a < b) |
| 1087 |
res = 0x08; |
| 1088 |
else { |
| 1089 |
if (a > b) |
| 1090 |
res = 0x04; |
| 1091 |
else |
| 1092 |
res = 0x02; |
| 1093 |
} |
| 1094 |
|
| 1095 |
if (cpu->xer & PPC32_XER_SO) |
| 1096 |
res |= 0x01; |
| 1097 |
|
| 1098 |
cpu->cr_fields[rd] = res; |
| 1099 |
return(0); |
| 1100 |
} |
| 1101 |
|
| 1102 |
/* CMPLI - Compare Logical Immediate */ |
| 1103 |
static fastcall int ppc32_exec_CMPLI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1104 |
{ |
| 1105 |
int rd = bits(insn,23,25); |
| 1106 |
int ra = bits(insn,16,20); |
| 1107 |
m_uint32_t imm = bits(insn,0,15); |
| 1108 |
m_uint32_t res,a; |
| 1109 |
|
| 1110 |
a = cpu->gpr[ra]; |
| 1111 |
|
| 1112 |
if (a < imm) |
| 1113 |
res = 0x08; |
| 1114 |
else { |
| 1115 |
if (a > imm) |
| 1116 |
res = 0x04; |
| 1117 |
else |
| 1118 |
res = 0x02; |
| 1119 |
} |
| 1120 |
|
| 1121 |
if (cpu->xer & PPC32_XER_SO) |
| 1122 |
res |= 0x01; |
| 1123 |
|
| 1124 |
cpu->cr_fields[rd] = res; |
| 1125 |
return(0); |
| 1126 |
} |
| 1127 |
|
| 1128 |
/* CNTLZW - Count Leading Zeros Word */ |
| 1129 |
static fastcall int ppc32_exec_CNTLZW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1130 |
{ |
| 1131 |
int rs = bits(insn,21,25); |
| 1132 |
int ra = bits(insn,16,20); |
| 1133 |
m_uint32_t val,mask; |
| 1134 |
int i; |
| 1135 |
|
| 1136 |
val = cpu->gpr[rs]; |
| 1137 |
mask = 0x80000000; |
| 1138 |
|
| 1139 |
for(i=0;i<32;i++) { |
| 1140 |
if (val & mask) |
| 1141 |
break; |
| 1142 |
|
| 1143 |
mask >>= 1; |
| 1144 |
} |
| 1145 |
|
| 1146 |
cpu->gpr[ra] = i; |
| 1147 |
return(0); |
| 1148 |
} |
| 1149 |
|
| 1150 |
/* CRAND - Condition Register AND */ |
| 1151 |
static fastcall int ppc32_exec_CRAND(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1152 |
{ |
| 1153 |
int bd = bits(insn,21,25); |
| 1154 |
int bb = bits(insn,16,20); |
| 1155 |
int ba = bits(insn,11,15); |
| 1156 |
m_uint32_t tmp; |
| 1157 |
|
| 1158 |
tmp = ppc32_read_cr_bit(cpu,ba); |
| 1159 |
tmp &= ppc32_read_cr_bit(cpu,bb); |
| 1160 |
|
| 1161 |
if (tmp & 0x1) |
| 1162 |
ppc32_set_cr_bit(cpu,bd); |
| 1163 |
else |
| 1164 |
ppc32_clear_cr_bit(cpu,bd); |
| 1165 |
|
| 1166 |
return(0); |
| 1167 |
} |
| 1168 |
|
| 1169 |
/* CREQV - Condition Register Equivalent */ |
| 1170 |
static fastcall int ppc32_exec_CREQV(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1171 |
{ |
| 1172 |
int bd = bits(insn,21,25); |
| 1173 |
int bb = bits(insn,16,20); |
| 1174 |
int ba = bits(insn,11,15); |
| 1175 |
m_uint32_t tmp; |
| 1176 |
|
| 1177 |
tmp = ppc32_read_cr_bit(cpu,ba); |
| 1178 |
tmp ^= ppc32_read_cr_bit(cpu,bb); |
| 1179 |
|
| 1180 |
if (!(tmp & 0x1)) |
| 1181 |
ppc32_set_cr_bit(cpu,bd); |
| 1182 |
else |
| 1183 |
ppc32_clear_cr_bit(cpu,bd); |
| 1184 |
|
| 1185 |
return(0); |
| 1186 |
} |
| 1187 |
|
| 1188 |
/* CRANDC - Condition Register AND with Complement */ |
| 1189 |
static fastcall int ppc32_exec_CRANDC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1190 |
{ |
| 1191 |
int bd = bits(insn,21,25); |
| 1192 |
int bb = bits(insn,16,20); |
| 1193 |
int ba = bits(insn,11,15); |
| 1194 |
m_uint32_t tmp; |
| 1195 |
|
| 1196 |
tmp = ppc32_read_cr_bit(cpu,ba); |
| 1197 |
tmp &= ~ppc32_read_cr_bit(cpu,bb); |
| 1198 |
|
| 1199 |
if (tmp & 0x1) |
| 1200 |
ppc32_set_cr_bit(cpu,bd); |
| 1201 |
else |
| 1202 |
ppc32_clear_cr_bit(cpu,bd); |
| 1203 |
|
| 1204 |
return(0); |
| 1205 |
} |
| 1206 |
|
| 1207 |
/* CRNAND - Condition Register NAND */ |
| 1208 |
static fastcall int ppc32_exec_CRNAND(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1209 |
{ |
| 1210 |
int bd = bits(insn,21,25); |
| 1211 |
int bb = bits(insn,16,20); |
| 1212 |
int ba = bits(insn,11,15); |
| 1213 |
m_uint32_t tmp; |
| 1214 |
|
| 1215 |
tmp = ppc32_read_cr_bit(cpu,ba); |
| 1216 |
tmp &= ppc32_read_cr_bit(cpu,bb); |
| 1217 |
|
| 1218 |
if (!(tmp & 0x1)) |
| 1219 |
ppc32_set_cr_bit(cpu,bd); |
| 1220 |
else |
| 1221 |
ppc32_clear_cr_bit(cpu,bd); |
| 1222 |
|
| 1223 |
return(0); |
| 1224 |
} |
| 1225 |
|
| 1226 |
/* CRNOR - Condition Register NOR */ |
| 1227 |
static fastcall int ppc32_exec_CRNOR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1228 |
{ |
| 1229 |
int bd = bits(insn,21,25); |
| 1230 |
int bb = bits(insn,16,20); |
| 1231 |
int ba = bits(insn,11,15); |
| 1232 |
m_uint32_t tmp; |
| 1233 |
|
| 1234 |
tmp = ppc32_read_cr_bit(cpu,ba); |
| 1235 |
tmp |= ppc32_read_cr_bit(cpu,bb); |
| 1236 |
|
| 1237 |
if (!(tmp & 0x1)) |
| 1238 |
ppc32_set_cr_bit(cpu,bd); |
| 1239 |
else |
| 1240 |
ppc32_clear_cr_bit(cpu,bd); |
| 1241 |
|
| 1242 |
return(0); |
| 1243 |
} |
| 1244 |
|
| 1245 |
/* CROR - Condition Register OR */ |
| 1246 |
static fastcall int ppc32_exec_CROR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1247 |
{ |
| 1248 |
int bd = bits(insn,21,25); |
| 1249 |
int bb = bits(insn,16,20); |
| 1250 |
int ba = bits(insn,11,15); |
| 1251 |
m_uint32_t tmp; |
| 1252 |
|
| 1253 |
tmp = ppc32_read_cr_bit(cpu,ba); |
| 1254 |
tmp |= ppc32_read_cr_bit(cpu,bb); |
| 1255 |
|
| 1256 |
if (tmp & 0x1) |
| 1257 |
ppc32_set_cr_bit(cpu,bd); |
| 1258 |
else |
| 1259 |
ppc32_clear_cr_bit(cpu,bd); |
| 1260 |
|
| 1261 |
return(0); |
| 1262 |
} |
| 1263 |
|
| 1264 |
/* CRORC - Condition Register OR with complement */ |
| 1265 |
static fastcall int ppc32_exec_CRORC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1266 |
{ |
| 1267 |
int bd = bits(insn,21,25); |
| 1268 |
int bb = bits(insn,16,20); |
| 1269 |
int ba = bits(insn,11,15); |
| 1270 |
m_uint32_t tmp; |
| 1271 |
|
| 1272 |
tmp = ppc32_read_cr_bit(cpu,ba); |
| 1273 |
tmp |= ~ppc32_read_cr_bit(cpu,bb); |
| 1274 |
|
| 1275 |
if (tmp & 0x1) |
| 1276 |
ppc32_set_cr_bit(cpu,bd); |
| 1277 |
else |
| 1278 |
ppc32_clear_cr_bit(cpu,bd); |
| 1279 |
|
| 1280 |
return(0); |
| 1281 |
} |
| 1282 |
|
| 1283 |
/* CRXOR - Condition Register XOR */ |
| 1284 |
static fastcall int ppc32_exec_CRXOR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1285 |
{ |
| 1286 |
int bd = bits(insn,21,25); |
| 1287 |
int bb = bits(insn,16,20); |
| 1288 |
int ba = bits(insn,11,15); |
| 1289 |
m_uint32_t tmp; |
| 1290 |
|
| 1291 |
tmp = ppc32_read_cr_bit(cpu,ba); |
| 1292 |
tmp ^= ppc32_read_cr_bit(cpu,bb); |
| 1293 |
|
| 1294 |
if (tmp & 0x1) |
| 1295 |
ppc32_set_cr_bit(cpu,bd); |
| 1296 |
else |
| 1297 |
ppc32_clear_cr_bit(cpu,bd); |
| 1298 |
|
| 1299 |
return(0); |
| 1300 |
} |
| 1301 |
|
| 1302 |
/* DCBF - Data Cache Block Flush */ |
| 1303 |
static fastcall int ppc32_exec_DCBF(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1304 |
{ |
| 1305 |
int ra = bits(insn,16,20); |
| 1306 |
int rb = bits(insn,11,15); |
| 1307 |
m_uint32_t vaddr; |
| 1308 |
|
| 1309 |
vaddr = cpu->gpr[rb]; |
| 1310 |
|
| 1311 |
if (ra != 0) |
| 1312 |
vaddr += cpu->gpr[ra]; |
| 1313 |
|
| 1314 |
//printf("PPC32: DBCF: vaddr=0x%8.8x\n",vaddr); |
| 1315 |
return(0); |
| 1316 |
} |
| 1317 |
|
| 1318 |
/* DCBI - Data Cache Block Invalidate */ |
| 1319 |
static fastcall int ppc32_exec_DCBI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1320 |
{ |
| 1321 |
int ra = bits(insn,16,20); |
| 1322 |
int rb = bits(insn,11,15); |
| 1323 |
m_uint32_t vaddr; |
| 1324 |
|
| 1325 |
vaddr = cpu->gpr[rb]; |
| 1326 |
|
| 1327 |
if (ra != 0) |
| 1328 |
vaddr += cpu->gpr[ra]; |
| 1329 |
|
| 1330 |
//printf("PPC32: DBCI: vaddr=0x%8.8x\n",vaddr); |
| 1331 |
return(0); |
| 1332 |
} |
| 1333 |
|
| 1334 |
/* DCBT - Data Cache Block Touch */ |
| 1335 |
static fastcall int ppc32_exec_DCBT(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1336 |
{ |
| 1337 |
int ra = bits(insn,16,20); |
| 1338 |
int rb = bits(insn,11,15); |
| 1339 |
m_uint32_t vaddr; |
| 1340 |
|
| 1341 |
vaddr = cpu->gpr[rb]; |
| 1342 |
|
| 1343 |
if (ra != 0) |
| 1344 |
vaddr += cpu->gpr[ra]; |
| 1345 |
|
| 1346 |
//printf("PPC32: DBCT: vaddr=0x%8.8x\n",vaddr); |
| 1347 |
return(0); |
| 1348 |
} |
| 1349 |
|
| 1350 |
/* DCBST - Data Cache Block Store */ |
| 1351 |
static fastcall int ppc32_exec_DCBST(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1352 |
{ |
| 1353 |
int ra = bits(insn,16,20); |
| 1354 |
int rb = bits(insn,11,15); |
| 1355 |
m_uint32_t vaddr; |
| 1356 |
|
| 1357 |
vaddr = cpu->gpr[rb]; |
| 1358 |
|
| 1359 |
if (ra != 0) |
| 1360 |
vaddr += cpu->gpr[ra]; |
| 1361 |
|
| 1362 |
//printf("PPC32: DBCST: vaddr=0x%8.8x\n",vaddr); |
| 1363 |
return(0); |
| 1364 |
} |
| 1365 |
|
| 1366 |
/* DIVW - Divide Word */ |
| 1367 |
static fastcall int ppc32_exec_DIVW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1368 |
{ |
| 1369 |
int rd = bits(insn,21,25); |
| 1370 |
int ra = bits(insn,16,20); |
| 1371 |
int rb = bits(insn,11,15); |
| 1372 |
register m_uint32_t a,b; |
| 1373 |
|
| 1374 |
a = (m_int32_t)cpu->gpr[ra]; |
| 1375 |
b = (m_int32_t)cpu->gpr[rb]; |
| 1376 |
|
| 1377 |
if (!((b == 0) || ((cpu->gpr[ra] == 0x80000000) && (b == -1)))) |
| 1378 |
cpu->gpr[rd] = a / b; |
| 1379 |
return(0); |
| 1380 |
} |
| 1381 |
|
| 1382 |
/* DIVW. - Divide Word */ |
| 1383 |
static fastcall int ppc32_exec_DIVW_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1384 |
{ |
| 1385 |
int rd = bits(insn,21,25); |
| 1386 |
int ra = bits(insn,16,20); |
| 1387 |
int rb = bits(insn,11,15); |
| 1388 |
register m_int32_t a,b,d; |
| 1389 |
|
| 1390 |
a = (m_int32_t)cpu->gpr[ra]; |
| 1391 |
b = (m_int32_t)cpu->gpr[rb]; |
| 1392 |
d = 0; |
| 1393 |
|
| 1394 |
if (!((b == 0) || ((cpu->gpr[ra] == 0x80000000) && (b == -1)))) |
| 1395 |
d = a / b; |
| 1396 |
|
| 1397 |
ppc32_exec_update_cr0(cpu,d); |
| 1398 |
cpu->gpr[rd] = d; |
| 1399 |
return(0); |
| 1400 |
} |
| 1401 |
|
| 1402 |
/* DIVWU - Divide Word Unsigned */ |
| 1403 |
static fastcall int ppc32_exec_DIVWU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1404 |
{ |
| 1405 |
int rd = bits(insn,21,25); |
| 1406 |
int ra = bits(insn,16,20); |
| 1407 |
int rb = bits(insn,11,15); |
| 1408 |
register m_uint32_t a,b; |
| 1409 |
|
| 1410 |
a = cpu->gpr[ra]; |
| 1411 |
b = cpu->gpr[rb]; |
| 1412 |
|
| 1413 |
if (b != 0) |
| 1414 |
cpu->gpr[rd] = a / b; |
| 1415 |
return(0); |
| 1416 |
} |
| 1417 |
|
| 1418 |
/* DIVWU. - Divide Word Unsigned */ |
| 1419 |
static fastcall int ppc32_exec_DIVWU_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1420 |
{ |
| 1421 |
int rd = bits(insn,21,25); |
| 1422 |
int ra = bits(insn,16,20); |
| 1423 |
int rb = bits(insn,11,15); |
| 1424 |
register m_uint32_t a,b,d; |
| 1425 |
|
| 1426 |
a = cpu->gpr[ra]; |
| 1427 |
b = cpu->gpr[rb]; |
| 1428 |
d = 0; |
| 1429 |
|
| 1430 |
if (b != 0) |
| 1431 |
d = a / b; |
| 1432 |
|
| 1433 |
ppc32_exec_update_cr0(cpu,d); |
| 1434 |
cpu->gpr[rd] = d; |
| 1435 |
return(0); |
| 1436 |
} |
| 1437 |
|
| 1438 |
/* EIEIO - Enforce In-order Execution of I/O */ |
| 1439 |
static fastcall int ppc32_exec_EIEIO(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1440 |
{ |
| 1441 |
return(0); |
| 1442 |
} |
| 1443 |
|
| 1444 |
/* EQV */ |
| 1445 |
static fastcall int ppc32_exec_EQV(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1446 |
{ |
| 1447 |
int rs = bits(insn,21,25); |
| 1448 |
int ra = bits(insn,16,20); |
| 1449 |
int rb = bits(insn,11,15); |
| 1450 |
|
| 1451 |
cpu->gpr[ra] = ~(cpu->gpr[rs] ^ cpu->gpr[rb]); |
| 1452 |
return(0); |
| 1453 |
} |
| 1454 |
|
| 1455 |
/* EXTSB - Extend Sign Byte */ |
| 1456 |
static fastcall int ppc32_exec_EXTSB(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1457 |
{ |
| 1458 |
int rs = bits(insn,21,25); |
| 1459 |
int ra = bits(insn,16,20); |
| 1460 |
|
| 1461 |
cpu->gpr[ra] = sign_extend_32(cpu->gpr[rs],8); |
| 1462 |
return(0); |
| 1463 |
} |
| 1464 |
|
| 1465 |
/* EXTSB. */ |
| 1466 |
static fastcall int ppc32_exec_EXTSB_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1467 |
{ |
| 1468 |
int rs = bits(insn,21,25); |
| 1469 |
int ra = bits(insn,16,20); |
| 1470 |
m_uint32_t tmp; |
| 1471 |
|
| 1472 |
tmp = sign_extend_32(cpu->gpr[rs],8); |
| 1473 |
ppc32_exec_update_cr0(cpu,tmp); |
| 1474 |
cpu->gpr[ra] = tmp; |
| 1475 |
return(0); |
| 1476 |
} |
| 1477 |
|
| 1478 |
/* EXTSH - Extend Sign Word */ |
| 1479 |
static fastcall int ppc32_exec_EXTSH(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1480 |
{ |
| 1481 |
int rs = bits(insn,21,25); |
| 1482 |
int ra = bits(insn,16,20); |
| 1483 |
|
| 1484 |
cpu->gpr[ra] = sign_extend_32(cpu->gpr[rs],16); |
| 1485 |
return(0); |
| 1486 |
} |
| 1487 |
|
| 1488 |
/* EXTSH. */ |
| 1489 |
static fastcall int ppc32_exec_EXTSH_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1490 |
{ |
| 1491 |
int rs = bits(insn,21,25); |
| 1492 |
int ra = bits(insn,16,20); |
| 1493 |
m_uint32_t tmp; |
| 1494 |
|
| 1495 |
tmp = sign_extend_32(cpu->gpr[rs],16); |
| 1496 |
ppc32_exec_update_cr0(cpu,tmp); |
| 1497 |
cpu->gpr[ra] = tmp; |
| 1498 |
return(0); |
| 1499 |
} |
| 1500 |
|
| 1501 |
/* ICBI - Instruction Cache Block Invalidate */ |
| 1502 |
static fastcall int ppc32_exec_ICBI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1503 |
{ |
| 1504 |
int ra = bits(insn,16,20); |
| 1505 |
int rb = bits(insn,11,15); |
| 1506 |
m_uint32_t vaddr; |
| 1507 |
|
| 1508 |
vaddr = cpu->gpr[rb]; |
| 1509 |
|
| 1510 |
if (ra != 0) |
| 1511 |
vaddr += cpu->gpr[ra]; |
| 1512 |
|
| 1513 |
ppc32_exec_memop(cpu,PPC_MEMOP_ICBI,vaddr,0); |
| 1514 |
return(0); |
| 1515 |
} |
| 1516 |
|
| 1517 |
/* ISYNC - Instruction Synchronize */ |
| 1518 |
static fastcall int ppc32_exec_ISYNC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1519 |
{ |
| 1520 |
return(0); |
| 1521 |
} |
| 1522 |
|
| 1523 |
/* LBZ - Load Byte and Zero */ |
| 1524 |
static fastcall int ppc32_exec_LBZ(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1525 |
{ |
| 1526 |
int rd = bits(insn,21,25); |
| 1527 |
int ra = bits(insn,16,20); |
| 1528 |
m_uint16_t imm = bits(insn,0,15); |
| 1529 |
m_uint32_t vaddr; |
| 1530 |
|
| 1531 |
vaddr = sign_extend_32(imm,16); |
| 1532 |
|
| 1533 |
if (ra != 0) |
| 1534 |
vaddr += cpu->gpr[ra]; |
| 1535 |
|
| 1536 |
ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); |
| 1537 |
return(0); |
| 1538 |
} |
| 1539 |
|
| 1540 |
/* LBZU - Load Byte and Zero with Update */ |
| 1541 |
static fastcall int ppc32_exec_LBZU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1542 |
{ |
| 1543 |
int rd = bits(insn,21,25); |
| 1544 |
int ra = bits(insn,16,20); |
| 1545 |
m_uint16_t imm = bits(insn,0,15); |
| 1546 |
m_uint32_t vaddr; |
| 1547 |
|
| 1548 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 1549 |
ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); |
| 1550 |
cpu->gpr[ra] = vaddr; |
| 1551 |
return(0); |
| 1552 |
} |
| 1553 |
|
| 1554 |
/* LBZUX - Load Byte and Zero with Update Indexed */ |
| 1555 |
static fastcall int ppc32_exec_LBZUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1556 |
{ |
| 1557 |
int rd = bits(insn,21,25); |
| 1558 |
int ra = bits(insn,16,20); |
| 1559 |
int rb = bits(insn,11,15); |
| 1560 |
m_uint32_t vaddr; |
| 1561 |
|
| 1562 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 1563 |
ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); |
| 1564 |
cpu->gpr[ra] = vaddr; |
| 1565 |
return(0); |
| 1566 |
} |
| 1567 |
|
| 1568 |
/* LBZX - Load Byte and Zero Indexed */ |
| 1569 |
static fastcall int ppc32_exec_LBZX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1570 |
{ |
| 1571 |
int rd = bits(insn,21,25); |
| 1572 |
int ra = bits(insn,16,20); |
| 1573 |
int rb = bits(insn,11,15); |
| 1574 |
m_uint32_t vaddr; |
| 1575 |
|
| 1576 |
vaddr = cpu->gpr[rb]; |
| 1577 |
|
| 1578 |
if (ra != 0) |
| 1579 |
vaddr += cpu->gpr[ra]; |
| 1580 |
|
| 1581 |
ppc32_exec_memop(cpu,PPC_MEMOP_LBZ,vaddr,rd); |
| 1582 |
return(0); |
| 1583 |
} |
| 1584 |
|
| 1585 |
/* LHA - Load Half-Word Algebraic */ |
| 1586 |
static fastcall int ppc32_exec_LHA(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1587 |
{ |
| 1588 |
int rd = bits(insn,21,25); |
| 1589 |
int ra = bits(insn,16,20); |
| 1590 |
m_uint16_t imm = bits(insn,0,15); |
| 1591 |
m_uint32_t vaddr; |
| 1592 |
|
| 1593 |
vaddr = sign_extend_32(imm,16); |
| 1594 |
|
| 1595 |
if (ra != 0) |
| 1596 |
vaddr += cpu->gpr[ra]; |
| 1597 |
|
| 1598 |
ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); |
| 1599 |
return(0); |
| 1600 |
} |
| 1601 |
|
| 1602 |
/* LHAU - Load Half-Word Algebraic with Update */ |
| 1603 |
static fastcall int ppc32_exec_LHAU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1604 |
{ |
| 1605 |
int rd = bits(insn,21,25); |
| 1606 |
int ra = bits(insn,16,20); |
| 1607 |
m_uint16_t imm = bits(insn,0,15); |
| 1608 |
m_uint32_t vaddr; |
| 1609 |
|
| 1610 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 1611 |
ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); |
| 1612 |
cpu->gpr[ra] = vaddr; |
| 1613 |
return(0); |
| 1614 |
} |
| 1615 |
|
| 1616 |
/* LHAUX - Load Half-Word Algebraic with Update Indexed */ |
| 1617 |
static fastcall int ppc32_exec_LHAUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1618 |
{ |
| 1619 |
int rd = bits(insn,21,25); |
| 1620 |
int ra = bits(insn,16,20); |
| 1621 |
int rb = bits(insn,11,15); |
| 1622 |
m_uint32_t vaddr; |
| 1623 |
|
| 1624 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 1625 |
ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); |
| 1626 |
cpu->gpr[ra] = vaddr; |
| 1627 |
return(0); |
| 1628 |
} |
| 1629 |
|
| 1630 |
/* LHAX - Load Half-Word Algebraic ndexed */ |
| 1631 |
static fastcall int ppc32_exec_LHAX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1632 |
{ |
| 1633 |
int rd = bits(insn,21,25); |
| 1634 |
int ra = bits(insn,16,20); |
| 1635 |
int rb = bits(insn,11,15); |
| 1636 |
m_uint32_t vaddr; |
| 1637 |
|
| 1638 |
vaddr = cpu->gpr[rb]; |
| 1639 |
|
| 1640 |
if (ra != 0) |
| 1641 |
vaddr += cpu->gpr[ra]; |
| 1642 |
|
| 1643 |
ppc32_exec_memop(cpu,PPC_MEMOP_LHA,vaddr,rd); |
| 1644 |
return(0); |
| 1645 |
} |
| 1646 |
|
| 1647 |
/* LHZ - Load Half-Word and Zero */ |
| 1648 |
static fastcall int ppc32_exec_LHZ(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1649 |
{ |
| 1650 |
int rd = bits(insn,21,25); |
| 1651 |
int ra = bits(insn,16,20); |
| 1652 |
m_uint16_t imm = bits(insn,0,15); |
| 1653 |
m_uint32_t vaddr; |
| 1654 |
|
| 1655 |
vaddr = sign_extend_32(imm,16); |
| 1656 |
|
| 1657 |
if (ra != 0) |
| 1658 |
vaddr += cpu->gpr[ra]; |
| 1659 |
|
| 1660 |
ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); |
| 1661 |
return(0); |
| 1662 |
} |
| 1663 |
|
| 1664 |
/* LHZU - Load Half-Word and Zero with Update */ |
| 1665 |
static fastcall int ppc32_exec_LHZU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1666 |
{ |
| 1667 |
int rd = bits(insn,21,25); |
| 1668 |
int ra = bits(insn,16,20); |
| 1669 |
m_uint16_t imm = bits(insn,0,15); |
| 1670 |
m_uint32_t vaddr; |
| 1671 |
|
| 1672 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 1673 |
ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); |
| 1674 |
cpu->gpr[ra] = vaddr; |
| 1675 |
return(0); |
| 1676 |
} |
| 1677 |
|
| 1678 |
/* LHZUX - Load Half-Word and Zero with Update Indexed */ |
| 1679 |
static fastcall int ppc32_exec_LHZUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1680 |
{ |
| 1681 |
int rd = bits(insn,21,25); |
| 1682 |
int ra = bits(insn,16,20); |
| 1683 |
int rb = bits(insn,11,15); |
| 1684 |
m_uint32_t vaddr; |
| 1685 |
|
| 1686 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 1687 |
ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); |
| 1688 |
cpu->gpr[ra] = vaddr; |
| 1689 |
return(0); |
| 1690 |
} |
| 1691 |
|
| 1692 |
/* LHZX - Load Half-Word and Zero Indexed */ |
| 1693 |
static fastcall int ppc32_exec_LHZX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1694 |
{ |
| 1695 |
int rd = bits(insn,21,25); |
| 1696 |
int ra = bits(insn,16,20); |
| 1697 |
int rb = bits(insn,11,15); |
| 1698 |
m_uint32_t vaddr; |
| 1699 |
|
| 1700 |
vaddr = cpu->gpr[rb]; |
| 1701 |
|
| 1702 |
if (ra != 0) |
| 1703 |
vaddr += cpu->gpr[ra]; |
| 1704 |
|
| 1705 |
ppc32_exec_memop(cpu,PPC_MEMOP_LHZ,vaddr,rd); |
| 1706 |
return(0); |
| 1707 |
} |
| 1708 |
|
| 1709 |
/* LMW - Load Multiple Word */ |
| 1710 |
static fastcall int ppc32_exec_LMW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1711 |
{ |
| 1712 |
int rd = bits(insn,21,25); |
| 1713 |
int ra = bits(insn,16,20); |
| 1714 |
m_uint16_t imm = bits(insn,0,15); |
| 1715 |
m_uint32_t vaddr; |
| 1716 |
int r; |
| 1717 |
|
| 1718 |
vaddr = sign_extend_32(imm,16); |
| 1719 |
|
| 1720 |
if (ra != 0) |
| 1721 |
vaddr += cpu->gpr[ra]; |
| 1722 |
|
| 1723 |
for(r=rd;r<=31;r++) { |
| 1724 |
ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,r); |
| 1725 |
vaddr += sizeof(m_uint32_t); |
| 1726 |
} |
| 1727 |
|
| 1728 |
return(0); |
| 1729 |
} |
| 1730 |
|
| 1731 |
/* LWBRX - Load Word Byte-Reverse Indexed */ |
| 1732 |
static fastcall int ppc32_exec_LWBRX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1733 |
{ |
| 1734 |
int rd = bits(insn,21,25); |
| 1735 |
int ra = bits(insn,16,20); |
| 1736 |
int rb = bits(insn,11,15); |
| 1737 |
m_uint32_t vaddr; |
| 1738 |
|
| 1739 |
vaddr = cpu->gpr[rb]; |
| 1740 |
|
| 1741 |
if (ra != 0) |
| 1742 |
vaddr += cpu->gpr[ra]; |
| 1743 |
|
| 1744 |
ppc32_exec_memop(cpu,PPC_MEMOP_LWBR,vaddr,rd); |
| 1745 |
return(0); |
| 1746 |
} |
| 1747 |
|
| 1748 |
/* LWZ - Load Word and Zero */ |
| 1749 |
static fastcall int ppc32_exec_LWZ(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1750 |
{ |
| 1751 |
int rd = bits(insn,21,25); |
| 1752 |
int ra = bits(insn,16,20); |
| 1753 |
m_uint16_t imm = bits(insn,0,15); |
| 1754 |
m_uint32_t vaddr; |
| 1755 |
|
| 1756 |
vaddr = sign_extend_32(imm,16); |
| 1757 |
|
| 1758 |
if (ra != 0) |
| 1759 |
vaddr += cpu->gpr[ra]; |
| 1760 |
|
| 1761 |
ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); |
| 1762 |
return(0); |
| 1763 |
} |
| 1764 |
|
| 1765 |
/* LWZU - Load Word and Zero with Update */ |
| 1766 |
static fastcall int ppc32_exec_LWZU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1767 |
{ |
| 1768 |
int rd = bits(insn,21,25); |
| 1769 |
int ra = bits(insn,16,20); |
| 1770 |
m_uint16_t imm = bits(insn,0,15); |
| 1771 |
m_uint32_t vaddr; |
| 1772 |
|
| 1773 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 1774 |
ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); |
| 1775 |
cpu->gpr[ra] = vaddr; |
| 1776 |
return(0); |
| 1777 |
} |
| 1778 |
|
| 1779 |
/* LWZUX - Load Word and Zero with Update Indexed */ |
| 1780 |
static fastcall int ppc32_exec_LWZUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1781 |
{ |
| 1782 |
int rd = bits(insn,21,25); |
| 1783 |
int ra = bits(insn,16,20); |
| 1784 |
int rb = bits(insn,11,15); |
| 1785 |
m_uint32_t vaddr; |
| 1786 |
|
| 1787 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 1788 |
ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); |
| 1789 |
cpu->gpr[ra] = vaddr; |
| 1790 |
return(0); |
| 1791 |
} |
| 1792 |
|
| 1793 |
/* LWZX - Load Word and Zero Indexed */ |
| 1794 |
static fastcall int ppc32_exec_LWZX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1795 |
{ |
| 1796 |
int rd = bits(insn,21,25); |
| 1797 |
int ra = bits(insn,16,20); |
| 1798 |
int rb = bits(insn,11,15); |
| 1799 |
m_uint32_t vaddr; |
| 1800 |
|
| 1801 |
vaddr = cpu->gpr[rb]; |
| 1802 |
|
| 1803 |
if (ra != 0) |
| 1804 |
vaddr += cpu->gpr[ra]; |
| 1805 |
|
| 1806 |
ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); |
| 1807 |
return(0); |
| 1808 |
} |
| 1809 |
|
| 1810 |
/* LWARX - Load Word and Reserve Indexed */ |
| 1811 |
static fastcall int ppc32_exec_LWARX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1812 |
{ |
| 1813 |
int rd = bits(insn,21,25); |
| 1814 |
int ra = bits(insn,16,20); |
| 1815 |
int rb = bits(insn,11,15); |
| 1816 |
m_uint32_t vaddr; |
| 1817 |
|
| 1818 |
vaddr = cpu->gpr[rb]; |
| 1819 |
|
| 1820 |
if (ra != 0) |
| 1821 |
vaddr += cpu->gpr[ra]; |
| 1822 |
|
| 1823 |
cpu->reserve = 1; |
| 1824 |
ppc32_exec_memop(cpu,PPC_MEMOP_LWZ,vaddr,rd); |
| 1825 |
return(0); |
| 1826 |
} |
| 1827 |
|
| 1828 |
/* LFD - Load Floating-Point Double */ |
| 1829 |
static fastcall int ppc32_exec_LFD(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1830 |
{ |
| 1831 |
int rd = bits(insn,21,25); |
| 1832 |
int ra = bits(insn,16,20); |
| 1833 |
m_uint16_t imm = bits(insn,0,15); |
| 1834 |
m_uint32_t vaddr; |
| 1835 |
|
| 1836 |
vaddr = sign_extend_32(imm,16); |
| 1837 |
|
| 1838 |
if (ra != 0) |
| 1839 |
vaddr += cpu->gpr[ra]; |
| 1840 |
|
| 1841 |
ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); |
| 1842 |
return(0); |
| 1843 |
} |
| 1844 |
|
| 1845 |
/* LFDU - Load Floating-Point Double with Update */ |
| 1846 |
static fastcall int ppc32_exec_LFDU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1847 |
{ |
| 1848 |
int rd = bits(insn,21,25); |
| 1849 |
int ra = bits(insn,16,20); |
| 1850 |
m_uint16_t imm = bits(insn,0,15); |
| 1851 |
m_uint32_t vaddr; |
| 1852 |
|
| 1853 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 1854 |
ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); |
| 1855 |
cpu->gpr[ra] = vaddr; |
| 1856 |
return(0); |
| 1857 |
} |
| 1858 |
|
| 1859 |
/* LFDUX - Load Floating-Point Double with Update Indexed */ |
| 1860 |
static fastcall int ppc32_exec_LFDUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1861 |
{ |
| 1862 |
int rd = bits(insn,21,25); |
| 1863 |
int ra = bits(insn,16,20); |
| 1864 |
int rb = bits(insn,11,15); |
| 1865 |
m_uint32_t vaddr; |
| 1866 |
|
| 1867 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 1868 |
ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); |
| 1869 |
cpu->gpr[ra] = vaddr; |
| 1870 |
return(0); |
| 1871 |
} |
| 1872 |
|
| 1873 |
/* LFDX - Load Floating-Point Double Indexed */ |
| 1874 |
static fastcall int ppc32_exec_LFDX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1875 |
{ |
| 1876 |
int rd = bits(insn,21,25); |
| 1877 |
int ra = bits(insn,16,20); |
| 1878 |
int rb = bits(insn,11,15); |
| 1879 |
m_uint32_t vaddr; |
| 1880 |
|
| 1881 |
vaddr = cpu->gpr[rb]; |
| 1882 |
|
| 1883 |
if (ra != 0) |
| 1884 |
vaddr += cpu->gpr[ra]; |
| 1885 |
|
| 1886 |
ppc32_exec_memop(cpu,PPC_MEMOP_LFD,vaddr,rd); |
| 1887 |
return(0); |
| 1888 |
} |
| 1889 |
|
| 1890 |
/* LSWI - Load String Word Immediate */ |
| 1891 |
static fastcall int ppc32_exec_LSWI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1892 |
{ |
| 1893 |
int rd = bits(insn,21,25); |
| 1894 |
int ra = bits(insn,16,20); |
| 1895 |
int nb = bits(insn,11,15); |
| 1896 |
m_uint32_t vaddr = 0; |
| 1897 |
int r; |
| 1898 |
|
| 1899 |
if (ra != 0) |
| 1900 |
vaddr += cpu->gpr[ra]; |
| 1901 |
|
| 1902 |
if (nb == 0) |
| 1903 |
nb = 32; |
| 1904 |
|
| 1905 |
r = rd - 1; |
| 1906 |
cpu->sw_pos = 0; |
| 1907 |
|
| 1908 |
while(nb > 0) { |
| 1909 |
if (cpu->sw_pos == 0) { |
| 1910 |
r = (r + 1) & 0x1F; |
| 1911 |
cpu->gpr[r] = 0; |
| 1912 |
} |
| 1913 |
|
| 1914 |
ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r); |
| 1915 |
cpu->sw_pos += 8; |
| 1916 |
|
| 1917 |
if (cpu->sw_pos == 32) |
| 1918 |
cpu->sw_pos = 0; |
| 1919 |
|
| 1920 |
vaddr++; |
| 1921 |
nb--; |
| 1922 |
} |
| 1923 |
|
| 1924 |
return(0); |
| 1925 |
} |
| 1926 |
|
| 1927 |
/* LSWX - Load String Word Indexed */ |
| 1928 |
static fastcall int ppc32_exec_LSWX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1929 |
{ |
| 1930 |
int rd = bits(insn,21,25); |
| 1931 |
int ra = bits(insn,16,20); |
| 1932 |
int rb = bits(insn,11,15); |
| 1933 |
m_uint32_t vaddr; |
| 1934 |
int r,nb; |
| 1935 |
|
| 1936 |
vaddr = cpu->gpr[rb]; |
| 1937 |
|
| 1938 |
if (ra != 0) |
| 1939 |
vaddr += cpu->gpr[ra]; |
| 1940 |
|
| 1941 |
nb = cpu->xer & PPC32_XER_BC_MASK; |
| 1942 |
r = rd - 1; |
| 1943 |
cpu->sw_pos = 0; |
| 1944 |
|
| 1945 |
while(nb > 0) { |
| 1946 |
if (cpu->sw_pos == 0) { |
| 1947 |
r = (r + 1) & 0x1F; |
| 1948 |
cpu->gpr[r] = 0; |
| 1949 |
} |
| 1950 |
|
| 1951 |
ppc32_exec_memop(cpu,PPC_MEMOP_LSW,vaddr,r); |
| 1952 |
cpu->sw_pos += 8; |
| 1953 |
|
| 1954 |
if (cpu->sw_pos == 32) |
| 1955 |
cpu->sw_pos = 0; |
| 1956 |
|
| 1957 |
vaddr++; |
| 1958 |
nb--; |
| 1959 |
} |
| 1960 |
|
| 1961 |
return(0); |
| 1962 |
} |
| 1963 |
|
| 1964 |
/* MCRF - Move Condition Register Field */ |
| 1965 |
static fastcall int ppc32_exec_MCRF(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1966 |
{ |
| 1967 |
int rd = bits(insn,23,25); |
| 1968 |
int rs = bits(insn,18,20); |
| 1969 |
|
| 1970 |
cpu->cr_fields[rd] = cpu->cr_fields[rs]; |
| 1971 |
return(0); |
| 1972 |
} |
| 1973 |
|
| 1974 |
/* MFCR - Move from Condition Register */ |
| 1975 |
static fastcall int ppc32_exec_MFCR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1976 |
{ |
| 1977 |
int rd = bits(insn,21,25); |
| 1978 |
|
| 1979 |
cpu->gpr[rd] = ppc32_get_cr(cpu); |
| 1980 |
return(0); |
| 1981 |
} |
| 1982 |
|
| 1983 |
/* MFMSR - Move from Machine State Register */ |
| 1984 |
static fastcall int ppc32_exec_MFMSR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1985 |
{ |
| 1986 |
int rd = bits(insn,21,25); |
| 1987 |
|
| 1988 |
cpu->gpr[rd] = cpu->msr; |
| 1989 |
return(0); |
| 1990 |
} |
| 1991 |
|
| 1992 |
/* MFTBU - Move from Time Base (Up) */ |
| 1993 |
static fastcall int ppc32_exec_MFTBU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 1994 |
{ |
| 1995 |
int rd = bits(insn,21,25); |
| 1996 |
|
| 1997 |
cpu->gpr[rd] = cpu->tb >> 32; |
| 1998 |
return(0); |
| 1999 |
} |
| 2000 |
|
| 2001 |
/* MFTBL - Move from Time Base (Lo) */ |
| 2002 |
static fastcall int ppc32_exec_MFTBL(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2003 |
{ |
| 2004 |
int rd = bits(insn,21,25); |
| 2005 |
|
| 2006 |
cpu->tb += 50; |
| 2007 |
|
| 2008 |
cpu->gpr[rd] = cpu->tb & 0xFFFFFFFF; |
| 2009 |
return(0); |
| 2010 |
} |
| 2011 |
|
| 2012 |
/* MFSPR - Move from Special-Purpose Register */ |
| 2013 |
static fastcall int ppc32_exec_MFSPR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2014 |
{ |
| 2015 |
int rd = bits(insn,21,25); |
| 2016 |
int spr0 = bits(insn,16,20); |
| 2017 |
int spr1 = bits(insn,11,15); |
| 2018 |
u_int spr; |
| 2019 |
|
| 2020 |
spr = (spr1 << 5) | spr0; |
| 2021 |
cpu->gpr[rd] = 0; |
| 2022 |
|
| 2023 |
//cpu_log(cpu->gen,"SPR","reading SPR=%d at cpu->ia=0x%8.8x\n",spr,cpu->ia); |
| 2024 |
|
| 2025 |
if ((spr1 == 0x10) || (spr1 == 0x11)) { |
| 2026 |
cpu->gpr[rd] = ppc32_get_bat_spr(cpu,spr); |
| 2027 |
return(0); |
| 2028 |
} |
| 2029 |
|
| 2030 |
switch(spr) { |
| 2031 |
case PPC32_SPR_XER: |
| 2032 |
cpu->gpr[rd] = cpu->xer | (cpu->xer_ca << PPC32_XER_CA_BIT); |
| 2033 |
break; |
| 2034 |
case PPC32_SPR_DSISR: |
| 2035 |
cpu->gpr[rd] = cpu->dsisr; |
| 2036 |
break; |
| 2037 |
case PPC32_SPR_DAR: |
| 2038 |
cpu->gpr[rd] = cpu->dar; |
| 2039 |
break; |
| 2040 |
case PPC32_SPR_DEC: |
| 2041 |
cpu->gpr[rd] = cpu->dec; |
| 2042 |
break; |
| 2043 |
case PPC32_SPR_SDR1: |
| 2044 |
cpu->gpr[rd] = cpu->sdr1; |
| 2045 |
break; |
| 2046 |
case PPC32_SPR_SRR0: |
| 2047 |
cpu->gpr[rd] = cpu->srr0; |
| 2048 |
break; |
| 2049 |
case PPC32_SPR_SRR1: |
| 2050 |
cpu->gpr[rd] = cpu->srr1; |
| 2051 |
break; |
| 2052 |
case PPC32_SPR_TBL_READ: |
| 2053 |
cpu->gpr[rd] = cpu->tb & 0xFFFFFFFF; |
| 2054 |
break; |
| 2055 |
case PPC32_SPR_TBU_READ: |
| 2056 |
cpu->gpr[rd] = cpu->tb >> 32; |
| 2057 |
break; |
| 2058 |
case PPC32_SPR_SPRG0: |
| 2059 |
cpu->gpr[rd] = cpu->sprg[0]; |
| 2060 |
break; |
| 2061 |
case PPC32_SPR_SPRG1: |
| 2062 |
cpu->gpr[rd] = cpu->sprg[1]; |
| 2063 |
break; |
| 2064 |
case PPC32_SPR_SPRG2: |
| 2065 |
cpu->gpr[rd] = cpu->sprg[2]; |
| 2066 |
break; |
| 2067 |
case PPC32_SPR_SPRG3: |
| 2068 |
cpu->gpr[rd] = cpu->sprg[3]; |
| 2069 |
break; |
| 2070 |
case PPC32_SPR_PVR: |
| 2071 |
cpu->gpr[rd] = cpu->pvr; |
| 2072 |
break; |
| 2073 |
case PPC32_SPR_HID0: |
| 2074 |
cpu->gpr[rd] = cpu->hid0; |
| 2075 |
break; |
| 2076 |
case PPC32_SPR_HID1: |
| 2077 |
cpu->gpr[rd] = cpu->hid1; |
| 2078 |
break; |
| 2079 |
case PPC405_SPR_PID: |
| 2080 |
cpu->gpr[rd] = cpu->ppc405_pid; |
| 2081 |
break; |
| 2082 |
|
| 2083 |
/* MPC860 IMMR */ |
| 2084 |
case 638: |
| 2085 |
cpu->gpr[rd] = cpu->mpc860_immr; |
| 2086 |
break; |
| 2087 |
|
| 2088 |
default: |
| 2089 |
cpu->gpr[rd] = 0x0; |
| 2090 |
//printf("READING SPR = %d\n",spr); |
| 2091 |
} |
| 2092 |
|
| 2093 |
return(0); |
| 2094 |
} |
| 2095 |
|
| 2096 |
/* MFSR - Move From Segment Register */ |
| 2097 |
static fastcall int ppc32_exec_MFSR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2098 |
{ |
| 2099 |
int rd = bits(insn,21,25); |
| 2100 |
int sr = bits(insn,16,19); |
| 2101 |
|
| 2102 |
cpu->gpr[rd] = cpu->sr[sr]; |
| 2103 |
return(0); |
| 2104 |
} |
| 2105 |
|
| 2106 |
/* MFSRIN - Move From Segment Register Indirect */ |
| 2107 |
static fastcall int ppc32_exec_MFSRIN(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2108 |
{ |
| 2109 |
int rd = bits(insn,21,25); |
| 2110 |
int rb = bits(insn,11,15); |
| 2111 |
|
| 2112 |
cpu->gpr[rd] = cpu->sr[cpu->gpr[rb] >> 28]; |
| 2113 |
return(0); |
| 2114 |
} |
| 2115 |
|
| 2116 |
/* MTCRF - Move to Condition Register Fields */ |
| 2117 |
static fastcall int ppc32_exec_MTCRF(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2118 |
{ |
| 2119 |
int rs = bits(insn,21,25); |
| 2120 |
int crm = bits(insn,12,19); |
| 2121 |
int i; |
| 2122 |
|
| 2123 |
for(i=0;i<8;i++) |
| 2124 |
if (crm & (1 << (7 - i))) |
| 2125 |
cpu->cr_fields[i] = (cpu->gpr[rs] >> (28 - (i << 2))) & 0x0F; |
| 2126 |
|
| 2127 |
return(0); |
| 2128 |
} |
| 2129 |
|
| 2130 |
/* MTMSR - Move to Machine State Register */ |
| 2131 |
static fastcall int ppc32_exec_MTMSR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2132 |
{ |
| 2133 |
int rs = bits(insn,21,25); |
| 2134 |
|
| 2135 |
cpu->msr = cpu->gpr[rs]; |
| 2136 |
cpu->irq_check = (cpu->msr & PPC32_MSR_EE) && cpu->irq_pending; |
| 2137 |
|
| 2138 |
//printf("New MSR = 0x%8.8x at cpu->ia=0x%8.8x\n",cpu->msr,cpu->ia); |
| 2139 |
return(0); |
| 2140 |
} |
| 2141 |
|
| 2142 |
/* MTSPR - Move to Special-Purpose Register */ |
| 2143 |
static fastcall int ppc32_exec_MTSPR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2144 |
{ |
| 2145 |
int rd = bits(insn,21,25); |
| 2146 |
int spr0 = bits(insn,16,20); |
| 2147 |
int spr1 = bits(insn,11,15); |
| 2148 |
u_int spr; |
| 2149 |
|
| 2150 |
spr = (spr1 << 5) | spr0; |
| 2151 |
|
| 2152 |
//cpu_log(cpu->gen,"SPR","writing SPR=%d, val=0x%8.8x at cpu->ia=0x%8.8x\n", |
| 2153 |
// spr,cpu->ia,cpu->gpr[rd]); |
| 2154 |
|
| 2155 |
if ((spr1 == 0x10) || (spr1 == 0x11)) { |
| 2156 |
ppc32_set_bat_spr(cpu,spr,cpu->gpr[rd]); |
| 2157 |
return(0); |
| 2158 |
} |
| 2159 |
|
| 2160 |
switch(spr) { |
| 2161 |
case PPC32_SPR_XER: |
| 2162 |
cpu->xer = cpu->gpr[rd] & ~PPC32_XER_CA; |
| 2163 |
cpu->xer_ca = (cpu->gpr[rd] >> PPC32_XER_CA_BIT) & 0x1; |
| 2164 |
break; |
| 2165 |
case PPC32_SPR_DEC: |
| 2166 |
//printf("WRITING DECR 0x%8.8x AT IA=0x%8.8x\n",cpu->gpr[rd],cpu->ia); |
| 2167 |
cpu->dec = cpu->gpr[rd]; |
| 2168 |
cpu->timer_irq_armed = TRUE; |
| 2169 |
break; |
| 2170 |
case PPC32_SPR_SDR1: |
| 2171 |
cpu->sdr1 = cpu->gpr[rd]; |
| 2172 |
ppc32_mem_invalidate_cache(cpu); |
| 2173 |
break; |
| 2174 |
case PPC32_SPR_SRR0: |
| 2175 |
cpu->srr0 = cpu->gpr[rd]; |
| 2176 |
break; |
| 2177 |
case PPC32_SPR_SRR1: |
| 2178 |
cpu->srr1 = cpu->gpr[rd]; |
| 2179 |
break; |
| 2180 |
case PPC32_SPR_SPRG0: |
| 2181 |
cpu->sprg[0] = cpu->gpr[rd]; |
| 2182 |
break; |
| 2183 |
case PPC32_SPR_SPRG1: |
| 2184 |
cpu->sprg[1] = cpu->gpr[rd]; |
| 2185 |
break; |
| 2186 |
case PPC32_SPR_SPRG2: |
| 2187 |
cpu->sprg[2] = cpu->gpr[rd]; |
| 2188 |
break; |
| 2189 |
case PPC32_SPR_SPRG3: |
| 2190 |
cpu->sprg[3] = cpu->gpr[rd]; |
| 2191 |
break; |
| 2192 |
case PPC32_SPR_HID0: |
| 2193 |
cpu->hid0 = cpu->gpr[rd]; |
| 2194 |
break; |
| 2195 |
case PPC32_SPR_HID1: |
| 2196 |
cpu->hid1 = cpu->gpr[rd]; |
| 2197 |
break; |
| 2198 |
case PPC405_SPR_PID: |
| 2199 |
cpu->ppc405_pid = cpu->gpr[rd]; |
| 2200 |
break; |
| 2201 |
#if 0 |
| 2202 |
default: |
| 2203 |
printf("WRITING SPR=%d, data=0x%8.8x\n",spr,cpu->gpr[rd]); |
| 2204 |
#endif |
| 2205 |
} |
| 2206 |
|
| 2207 |
return(0); |
| 2208 |
} |
| 2209 |
|
| 2210 |
/* MTSR - Move To Segment Register */ |
| 2211 |
static fastcall int ppc32_exec_MTSR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2212 |
{ |
| 2213 |
int rs = bits(insn,21,25); |
| 2214 |
int sr = bits(insn,16,19); |
| 2215 |
|
| 2216 |
cpu->sr[sr] = cpu->gpr[rs]; |
| 2217 |
ppc32_mem_invalidate_cache(cpu); |
| 2218 |
return(0); |
| 2219 |
} |
| 2220 |
|
| 2221 |
/* MULHW - Multiply High Word */ |
| 2222 |
static fastcall int ppc32_exec_MULHW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2223 |
{ |
| 2224 |
int rd = bits(insn,21,25); |
| 2225 |
int ra = bits(insn,16,20); |
| 2226 |
int rb = bits(insn,11,15); |
| 2227 |
m_int64_t tmp; |
| 2228 |
m_uint32_t res; |
| 2229 |
|
| 2230 |
tmp = (m_int64_t)(m_int32_t)cpu->gpr[ra]; |
| 2231 |
tmp *= (m_int64_t)(m_int32_t)cpu->gpr[rb]; |
| 2232 |
res = tmp >> 32; |
| 2233 |
|
| 2234 |
cpu->gpr[rd] = res; |
| 2235 |
return(0); |
| 2236 |
} |
| 2237 |
|
| 2238 |
/* MULHW. */ |
| 2239 |
static fastcall int ppc32_exec_MULHW_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2240 |
{ |
| 2241 |
int rd = bits(insn,21,25); |
| 2242 |
int ra = bits(insn,16,20); |
| 2243 |
int rb = bits(insn,11,15); |
| 2244 |
m_int64_t tmp; |
| 2245 |
m_uint32_t res; |
| 2246 |
|
| 2247 |
tmp = (m_int64_t)(m_int32_t)cpu->gpr[ra]; |
| 2248 |
tmp *= (m_int64_t)(m_int32_t)cpu->gpr[rb]; |
| 2249 |
res = tmp >> 32; |
| 2250 |
ppc32_exec_update_cr0(cpu,res); |
| 2251 |
cpu->gpr[rd] = res; |
| 2252 |
return(0); |
| 2253 |
} |
| 2254 |
|
| 2255 |
/* MULHWU - Multiply High Word Unsigned */ |
| 2256 |
static fastcall int ppc32_exec_MULHWU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2257 |
{ |
| 2258 |
int rd = bits(insn,21,25); |
| 2259 |
int ra = bits(insn,16,20); |
| 2260 |
int rb = bits(insn,11,15); |
| 2261 |
m_uint64_t tmp; |
| 2262 |
m_uint32_t res; |
| 2263 |
|
| 2264 |
tmp = (m_uint64_t)cpu->gpr[ra]; |
| 2265 |
tmp *= (m_uint64_t)cpu->gpr[rb]; |
| 2266 |
res = tmp >> 32; |
| 2267 |
|
| 2268 |
cpu->gpr[rd] = res; |
| 2269 |
return(0); |
| 2270 |
} |
| 2271 |
|
| 2272 |
/* MULHWU. */ |
| 2273 |
static fastcall int ppc32_exec_MULHWU_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2274 |
{ |
| 2275 |
int rd = bits(insn,21,25); |
| 2276 |
int ra = bits(insn,16,20); |
| 2277 |
int rb = bits(insn,11,15); |
| 2278 |
m_uint64_t tmp; |
| 2279 |
m_uint32_t res; |
| 2280 |
|
| 2281 |
tmp = (m_uint64_t)cpu->gpr[ra]; |
| 2282 |
tmp *= (m_uint64_t)cpu->gpr[rb]; |
| 2283 |
res = tmp >> 32; |
| 2284 |
ppc32_exec_update_cr0(cpu,res); |
| 2285 |
cpu->gpr[rd] = res; |
| 2286 |
return(0); |
| 2287 |
} |
| 2288 |
|
| 2289 |
/* MULLI - Multiply Low Immediate */ |
| 2290 |
static fastcall int ppc32_exec_MULLI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2291 |
{ |
| 2292 |
int rd = bits(insn,21,25); |
| 2293 |
int ra = bits(insn,16,20); |
| 2294 |
m_uint32_t imm = bits(insn,0,15); |
| 2295 |
|
| 2296 |
cpu->gpr[rd] = (m_int32_t)cpu->gpr[ra] * sign_extend_32(imm,16); |
| 2297 |
return(0); |
| 2298 |
} |
| 2299 |
|
| 2300 |
/* MULLW - Multiply Low Word */ |
| 2301 |
static fastcall int ppc32_exec_MULLW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2302 |
{ |
| 2303 |
int rd = bits(insn,21,25); |
| 2304 |
int ra = bits(insn,16,20); |
| 2305 |
int rb = bits(insn,11,15); |
| 2306 |
m_int64_t tmp; |
| 2307 |
|
| 2308 |
tmp = (m_int64_t)(m_int32_t)cpu->gpr[ra]; |
| 2309 |
tmp *= (m_int64_t)(m_int32_t)cpu->gpr[rb]; |
| 2310 |
cpu->gpr[rd] = (m_uint32_t)tmp; |
| 2311 |
return(0); |
| 2312 |
} |
| 2313 |
|
| 2314 |
/* MULLW. */ |
| 2315 |
static fastcall int ppc32_exec_MULLW_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2316 |
{ |
| 2317 |
int rd = bits(insn,21,25); |
| 2318 |
int ra = bits(insn,16,20); |
| 2319 |
int rb = bits(insn,11,15); |
| 2320 |
register m_uint32_t res; |
| 2321 |
m_int64_t tmp; |
| 2322 |
|
| 2323 |
tmp = (m_int64_t)(m_int32_t)cpu->gpr[ra]; |
| 2324 |
tmp *= (m_int64_t)(m_int32_t)cpu->gpr[rb]; |
| 2325 |
|
| 2326 |
res = (m_uint32_t)tmp; |
| 2327 |
ppc32_exec_update_cr0(cpu,res); |
| 2328 |
cpu->gpr[rd] = res; |
| 2329 |
return(0); |
| 2330 |
} |
| 2331 |
|
| 2332 |
/* MULLWO - Multiply Low Word with Overflow */ |
| 2333 |
static fastcall int ppc32_exec_MULLWO(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2334 |
{ |
| 2335 |
int rd = bits(insn,21,25); |
| 2336 |
int ra = bits(insn,16,20); |
| 2337 |
int rb = bits(insn,11,15); |
| 2338 |
m_int64_t tmp; |
| 2339 |
|
| 2340 |
tmp = (m_int64_t)(m_int32_t)cpu->gpr[ra]; |
| 2341 |
tmp *= (m_int64_t)(m_int32_t)cpu->gpr[rb]; |
| 2342 |
|
| 2343 |
cpu->xer &= ~PPC32_XER_OV; |
| 2344 |
|
| 2345 |
if (unlikely(tmp != (m_int64_t)(m_int32_t)tmp)) |
| 2346 |
cpu->xer |= PPC32_XER_OV|PPC32_XER_SO; |
| 2347 |
|
| 2348 |
cpu->gpr[rd] = (m_uint32_t)tmp; |
| 2349 |
return(0); |
| 2350 |
} |
| 2351 |
|
| 2352 |
/* MULLWO. */ |
| 2353 |
static fastcall int ppc32_exec_MULLWO_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2354 |
{ |
| 2355 |
int rd = bits(insn,21,25); |
| 2356 |
int ra = bits(insn,16,20); |
| 2357 |
int rb = bits(insn,11,15); |
| 2358 |
register m_uint32_t res; |
| 2359 |
m_int64_t tmp; |
| 2360 |
|
| 2361 |
tmp = (m_int64_t)(m_int32_t)cpu->gpr[ra]; |
| 2362 |
tmp *= (m_int64_t)(m_int32_t)cpu->gpr[rb]; |
| 2363 |
|
| 2364 |
cpu->xer &= ~PPC32_XER_OV; |
| 2365 |
|
| 2366 |
if (unlikely(tmp != (m_int64_t)(m_int32_t)tmp)) |
| 2367 |
cpu->xer |= PPC32_XER_OV|PPC32_XER_SO; |
| 2368 |
|
| 2369 |
res = (m_uint32_t)tmp; |
| 2370 |
ppc32_exec_update_cr0(cpu,res); |
| 2371 |
cpu->gpr[rd] = res; |
| 2372 |
return(0); |
| 2373 |
} |
| 2374 |
|
| 2375 |
/* NAND */ |
| 2376 |
static fastcall int ppc32_exec_NAND(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2377 |
{ |
| 2378 |
int rs = bits(insn,21,25); |
| 2379 |
int ra = bits(insn,16,20); |
| 2380 |
int rb = bits(insn,11,15); |
| 2381 |
|
| 2382 |
cpu->gpr[ra] = ~(cpu->gpr[rs] & cpu->gpr[rb]); |
| 2383 |
return(0); |
| 2384 |
} |
| 2385 |
|
| 2386 |
/* NAND. */ |
| 2387 |
static fastcall int ppc32_exec_NAND_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2388 |
{ |
| 2389 |
int rs = bits(insn,21,25); |
| 2390 |
int ra = bits(insn,16,20); |
| 2391 |
int rb = bits(insn,11,15); |
| 2392 |
register m_uint32_t tmp; |
| 2393 |
|
| 2394 |
tmp = ~(cpu->gpr[rs] & cpu->gpr[rb]); |
| 2395 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2396 |
cpu->gpr[ra] = tmp; |
| 2397 |
return(0); |
| 2398 |
} |
| 2399 |
|
| 2400 |
/* NEG - Negate */ |
| 2401 |
static fastcall int ppc32_exec_NEG(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2402 |
{ |
| 2403 |
int rd = bits(insn,21,25); |
| 2404 |
int ra = bits(insn,16,20); |
| 2405 |
|
| 2406 |
cpu->gpr[rd] = ~cpu->gpr[ra] + 1; |
| 2407 |
return(0); |
| 2408 |
} |
| 2409 |
|
| 2410 |
/* NEG. */ |
| 2411 |
static fastcall int ppc32_exec_NEG_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2412 |
{ |
| 2413 |
int rd = bits(insn,21,25); |
| 2414 |
int ra = bits(insn,16,20); |
| 2415 |
register m_uint32_t tmp; |
| 2416 |
|
| 2417 |
tmp = ~cpu->gpr[ra] + 1; |
| 2418 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2419 |
cpu->gpr[rd] = tmp; |
| 2420 |
return(0); |
| 2421 |
} |
| 2422 |
|
| 2423 |
/* NEGO */ |
| 2424 |
static fastcall int ppc32_exec_NEGO(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2425 |
{ |
| 2426 |
int rd = bits(insn,21,25); |
| 2427 |
int ra = bits(insn,16,20); |
| 2428 |
register m_uint32_t tmp; |
| 2429 |
|
| 2430 |
tmp = ~cpu->gpr[ra] + 1; |
| 2431 |
cpu->gpr[rd] = tmp; |
| 2432 |
|
| 2433 |
cpu->xer &= ~PPC32_XER_OV; |
| 2434 |
|
| 2435 |
if (unlikely(tmp == 0x80000000)) |
| 2436 |
cpu->xer |= PPC32_XER_OV|PPC32_XER_SO; |
| 2437 |
|
| 2438 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2439 |
return(0); |
| 2440 |
} |
| 2441 |
|
| 2442 |
/* NEGO. */ |
| 2443 |
static fastcall int ppc32_exec_NEGO_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2444 |
{ |
| 2445 |
int rd = bits(insn,21,25); |
| 2446 |
int ra = bits(insn,16,20); |
| 2447 |
register m_uint32_t tmp; |
| 2448 |
|
| 2449 |
tmp = ~cpu->gpr[ra] + 1; |
| 2450 |
cpu->gpr[rd] = tmp; |
| 2451 |
|
| 2452 |
cpu->xer &= ~PPC32_XER_OV; |
| 2453 |
|
| 2454 |
if (unlikely(tmp == 0x80000000)) |
| 2455 |
cpu->xer |= PPC32_XER_OV|PPC32_XER_SO; |
| 2456 |
|
| 2457 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2458 |
return(0); |
| 2459 |
} |
| 2460 |
|
| 2461 |
/* NOR */ |
| 2462 |
static fastcall int ppc32_exec_NOR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2463 |
{ |
| 2464 |
int rs = bits(insn,21,25); |
| 2465 |
int ra = bits(insn,16,20); |
| 2466 |
int rb = bits(insn,11,15); |
| 2467 |
|
| 2468 |
cpu->gpr[ra] = ~(cpu->gpr[rs] | cpu->gpr[rb]); |
| 2469 |
return(0); |
| 2470 |
} |
| 2471 |
|
| 2472 |
/* NOR. */ |
| 2473 |
static fastcall int ppc32_exec_NOR_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2474 |
{ |
| 2475 |
int rs = bits(insn,21,25); |
| 2476 |
int ra = bits(insn,16,20); |
| 2477 |
int rb = bits(insn,11,15); |
| 2478 |
register m_uint32_t tmp; |
| 2479 |
|
| 2480 |
tmp = ~(cpu->gpr[rs] | cpu->gpr[rb]); |
| 2481 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2482 |
cpu->gpr[ra] = tmp; |
| 2483 |
return(0); |
| 2484 |
} |
| 2485 |
|
| 2486 |
/* OR */ |
| 2487 |
static fastcall int ppc32_exec_OR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2488 |
{ |
| 2489 |
int rs = bits(insn,21,25); |
| 2490 |
int ra = bits(insn,16,20); |
| 2491 |
int rb = bits(insn,11,15); |
| 2492 |
|
| 2493 |
cpu->gpr[ra] = cpu->gpr[rs] | cpu->gpr[rb]; |
| 2494 |
return(0); |
| 2495 |
} |
| 2496 |
|
| 2497 |
/* OR. */ |
| 2498 |
static fastcall int ppc32_exec_OR_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2499 |
{ |
| 2500 |
int rs = bits(insn,21,25); |
| 2501 |
int ra = bits(insn,16,20); |
| 2502 |
int rb = bits(insn,11,15); |
| 2503 |
register m_uint32_t tmp; |
| 2504 |
|
| 2505 |
tmp = cpu->gpr[rs] | cpu->gpr[rb]; |
| 2506 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2507 |
cpu->gpr[ra] = tmp; |
| 2508 |
return(0); |
| 2509 |
} |
| 2510 |
|
| 2511 |
/* ORC - OR with Complement */ |
| 2512 |
static fastcall int ppc32_exec_ORC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2513 |
{ |
| 2514 |
int rs = bits(insn,21,25); |
| 2515 |
int ra = bits(insn,16,20); |
| 2516 |
int rb = bits(insn,11,15); |
| 2517 |
|
| 2518 |
cpu->gpr[ra] = cpu->gpr[rs] | ~cpu->gpr[rb]; |
| 2519 |
return(0); |
| 2520 |
} |
| 2521 |
|
| 2522 |
/* ORC. */ |
| 2523 |
static fastcall int ppc32_exec_ORC_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2524 |
{ |
| 2525 |
int rs = bits(insn,21,25); |
| 2526 |
int ra = bits(insn,16,20); |
| 2527 |
int rb = bits(insn,11,15); |
| 2528 |
register m_uint32_t tmp; |
| 2529 |
|
| 2530 |
tmp = cpu->gpr[rs] | ~cpu->gpr[rb]; |
| 2531 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2532 |
cpu->gpr[ra] = tmp; |
| 2533 |
return(0); |
| 2534 |
} |
| 2535 |
|
| 2536 |
/* ORI - OR Immediate */ |
| 2537 |
static fastcall int ppc32_exec_ORI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2538 |
{ |
| 2539 |
int rs = bits(insn,21,25); |
| 2540 |
int ra = bits(insn,16,20); |
| 2541 |
m_uint16_t imm = bits(insn,0,15); |
| 2542 |
|
| 2543 |
cpu->gpr[ra] = cpu->gpr[rs] | imm; |
| 2544 |
return(0); |
| 2545 |
} |
| 2546 |
|
| 2547 |
/* ORIS - OR Immediate Shifted */ |
| 2548 |
static fastcall int ppc32_exec_ORIS(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2549 |
{ |
| 2550 |
int rs = bits(insn,21,25); |
| 2551 |
int ra = bits(insn,16,20); |
| 2552 |
m_uint32_t imm = bits(insn,0,15); |
| 2553 |
|
| 2554 |
cpu->gpr[ra] = cpu->gpr[rs] | (imm << 16); |
| 2555 |
return(0); |
| 2556 |
} |
| 2557 |
|
| 2558 |
/* RFI - Return From Interrupt */ |
| 2559 |
static fastcall int ppc32_exec_RFI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2560 |
{ |
| 2561 |
//printf("RFI: srr0=0x%8.8x, srr1=0x%8.8x\n",cpu->srr0,cpu->srr1); |
| 2562 |
|
| 2563 |
cpu->msr &= ~PPC32_RFI_MSR_MASK; |
| 2564 |
cpu->msr |= cpu->srr1 & PPC32_RFI_MSR_MASK; |
| 2565 |
|
| 2566 |
cpu->msr &= ~(1 << 13); |
| 2567 |
cpu->ia = cpu->srr0 & ~0x03; |
| 2568 |
|
| 2569 |
cpu->irq_check = (cpu->msr & PPC32_MSR_EE) && cpu->irq_pending; |
| 2570 |
|
| 2571 |
//printf("NEW IA=0x%8.8x, NEW MSR=0x%8.8x\n",cpu->ia,cpu->msr); |
| 2572 |
return(1); |
| 2573 |
} |
| 2574 |
|
| 2575 |
/* RLWIMI - Rotate Left Word Immediate then Mask Insert */ |
| 2576 |
static fastcall int ppc32_exec_RLWIMI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2577 |
{ |
| 2578 |
int rs = bits(insn,21,25); |
| 2579 |
int ra = bits(insn,16,20); |
| 2580 |
int sh = bits(insn,11,15); |
| 2581 |
int mb = bits(insn,6,10); |
| 2582 |
int me = bits(insn,1,5); |
| 2583 |
register m_uint32_t r,mask; |
| 2584 |
|
| 2585 |
r = (cpu->gpr[rs] << sh) | (cpu->gpr[rs] >> (32 - sh)); |
| 2586 |
mask = ppc32_rotate_mask(mb,me); |
| 2587 |
cpu->gpr[ra] = (r & mask) | (cpu->gpr[ra] & ~mask); |
| 2588 |
return(0); |
| 2589 |
} |
| 2590 |
|
| 2591 |
/* RLWIMI. - Rotate Left Word Immediate then Mask Insert */ |
| 2592 |
static fastcall int ppc32_exec_RLWIMI_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2593 |
{ |
| 2594 |
int rs = bits(insn,21,25); |
| 2595 |
int ra = bits(insn,16,20); |
| 2596 |
int sh = bits(insn,11,15); |
| 2597 |
int mb = bits(insn,6,10); |
| 2598 |
int me = bits(insn,1,5); |
| 2599 |
register m_uint32_t r,mask,tmp; |
| 2600 |
|
| 2601 |
r = (cpu->gpr[rs] << sh) | (cpu->gpr[rs] >> (32 - sh)); |
| 2602 |
mask = ppc32_rotate_mask(mb,me); |
| 2603 |
tmp = (r & mask) | (cpu->gpr[ra] & ~mask); |
| 2604 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2605 |
cpu->gpr[ra] = tmp; |
| 2606 |
return(0); |
| 2607 |
} |
| 2608 |
|
| 2609 |
/* RLWINM - Rotate Left Word Immediate AND with Mask */ |
| 2610 |
static fastcall int ppc32_exec_RLWINM(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2611 |
{ |
| 2612 |
int rs = bits(insn,21,25); |
| 2613 |
int ra = bits(insn,16,20); |
| 2614 |
int sh = bits(insn,11,15); |
| 2615 |
int mb = bits(insn,6,10); |
| 2616 |
int me = bits(insn,1,5); |
| 2617 |
register m_uint32_t r,mask; |
| 2618 |
|
| 2619 |
r = (cpu->gpr[rs] << sh) | (cpu->gpr[rs] >> (32 - sh)); |
| 2620 |
mask = ppc32_rotate_mask(mb,me); |
| 2621 |
cpu->gpr[ra] = r & mask; |
| 2622 |
return(0); |
| 2623 |
} |
| 2624 |
|
| 2625 |
/* RLWINM. - Rotate Left Word Immediate AND with Mask */ |
| 2626 |
static fastcall int ppc32_exec_RLWINM_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2627 |
{ |
| 2628 |
int rs = bits(insn,21,25); |
| 2629 |
int ra = bits(insn,16,20); |
| 2630 |
int sh = bits(insn,11,15); |
| 2631 |
int mb = bits(insn,6,10); |
| 2632 |
int me = bits(insn,1,5); |
| 2633 |
register m_uint32_t r,mask,tmp; |
| 2634 |
|
| 2635 |
r = (cpu->gpr[rs] << sh) | (cpu->gpr[rs] >> (32 - sh)); |
| 2636 |
mask = ppc32_rotate_mask(mb,me); |
| 2637 |
tmp = r & mask; |
| 2638 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2639 |
cpu->gpr[ra] = tmp; |
| 2640 |
return(0); |
| 2641 |
} |
| 2642 |
|
| 2643 |
/* RLWNM - Rotate Left Word then Mask Insert */ |
| 2644 |
static fastcall int ppc32_exec_RLWNM(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2645 |
{ |
| 2646 |
int rs = bits(insn,21,25); |
| 2647 |
int ra = bits(insn,16,20); |
| 2648 |
int rb = bits(insn,11,15); |
| 2649 |
int mb = bits(insn,6,10); |
| 2650 |
int me = bits(insn,1,5); |
| 2651 |
register m_uint32_t r,sh,mask; |
| 2652 |
|
| 2653 |
sh = cpu->gpr[rb] & 0x1f; |
| 2654 |
r = (cpu->gpr[rs] << sh) | (cpu->gpr[rs] >> (32 - sh)); |
| 2655 |
mask = ppc32_rotate_mask(mb,me); |
| 2656 |
cpu->gpr[ra] = r & mask; |
| 2657 |
return(0); |
| 2658 |
} |
| 2659 |
|
| 2660 |
/* RLWNM. - Rotate Left Word then Mask Insert */ |
| 2661 |
static fastcall int ppc32_exec_RLWNM_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2662 |
{ |
| 2663 |
int rs = bits(insn,21,25); |
| 2664 |
int ra = bits(insn,16,20); |
| 2665 |
int rb = bits(insn,11,15); |
| 2666 |
int mb = bits(insn,6,10); |
| 2667 |
int me = bits(insn,1,5); |
| 2668 |
register m_uint32_t r,sh,mask,tmp; |
| 2669 |
|
| 2670 |
sh = cpu->gpr[rb] & 0x1f; |
| 2671 |
r = (cpu->gpr[rs] << sh) | (cpu->gpr[rs] >> (32 - sh)); |
| 2672 |
mask = ppc32_rotate_mask(mb,me); |
| 2673 |
tmp = r & mask; |
| 2674 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2675 |
cpu->gpr[ra] = tmp; |
| 2676 |
return(0); |
| 2677 |
} |
| 2678 |
|
| 2679 |
/* SC - System Call */ |
| 2680 |
static fastcall int ppc32_exec_SC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2681 |
{ |
| 2682 |
ppc32_trigger_exception(cpu,PPC32_EXC_SYSCALL); |
| 2683 |
return(1); |
| 2684 |
} |
| 2685 |
|
| 2686 |
/* SLW - Shift Left Word */ |
| 2687 |
static fastcall int ppc32_exec_SLW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2688 |
{ |
| 2689 |
int rs = bits(insn,21,25); |
| 2690 |
int ra = bits(insn,16,20); |
| 2691 |
int rb = bits(insn,11,15); |
| 2692 |
register m_uint32_t s; |
| 2693 |
|
| 2694 |
s = cpu->gpr[rb] & 0x3f; |
| 2695 |
|
| 2696 |
if (likely(!(s & 0x20))) |
| 2697 |
cpu->gpr[ra] = cpu->gpr[rs] << s; |
| 2698 |
else |
| 2699 |
cpu->gpr[ra] = 0; |
| 2700 |
|
| 2701 |
return(0); |
| 2702 |
} |
| 2703 |
|
| 2704 |
/* SLW. */ |
| 2705 |
static fastcall int ppc32_exec_SLW_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2706 |
{ |
| 2707 |
int rs = bits(insn,21,25); |
| 2708 |
int ra = bits(insn,16,20); |
| 2709 |
int rb = bits(insn,11,15); |
| 2710 |
register m_uint32_t s,tmp; |
| 2711 |
|
| 2712 |
s = cpu->gpr[rb] & 0x3f; |
| 2713 |
|
| 2714 |
if (likely(!(s & 0x20))) |
| 2715 |
tmp = cpu->gpr[rs] << s; |
| 2716 |
else |
| 2717 |
tmp = 0; |
| 2718 |
|
| 2719 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2720 |
cpu->gpr[ra] = tmp; |
| 2721 |
return(0); |
| 2722 |
} |
| 2723 |
|
| 2724 |
/* SRAW - Shift Right Algebraic Word */ |
| 2725 |
static fastcall int ppc32_exec_SRAW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2726 |
{ |
| 2727 |
int rs = bits(insn,21,25); |
| 2728 |
int ra = bits(insn,16,20); |
| 2729 |
int rb = bits(insn,11,15); |
| 2730 |
register m_uint32_t s,mask; |
| 2731 |
int sh; |
| 2732 |
|
| 2733 |
cpu->xer_ca = 0; |
| 2734 |
|
| 2735 |
s = cpu->gpr[rs]; |
| 2736 |
sh = cpu->gpr[rb]; |
| 2737 |
|
| 2738 |
if (unlikely(sh & 0x20)) { |
| 2739 |
cpu->gpr[ra] = (m_int32_t)s >> 31; |
| 2740 |
cpu->xer_ca = cpu->gpr[ra] & 0x1; |
| 2741 |
return(0); |
| 2742 |
} |
| 2743 |
|
| 2744 |
cpu->gpr[ra] = (m_int32_t)s >> sh; |
| 2745 |
mask = ~(0xFFFFFFFFU << sh); |
| 2746 |
|
| 2747 |
if ((s & 0x80000000) && ((s & mask) != 0)) |
| 2748 |
cpu->xer_ca = 1; |
| 2749 |
|
| 2750 |
return(0); |
| 2751 |
} |
| 2752 |
|
| 2753 |
/* SRAWI - Shift Right Algebraic Word Immediate */ |
| 2754 |
static fastcall int ppc32_exec_SRAWI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2755 |
{ |
| 2756 |
int rs = bits(insn,21,25); |
| 2757 |
int ra = bits(insn,16,20); |
| 2758 |
int sh = bits(insn,11,15); |
| 2759 |
register m_uint32_t s,mask; |
| 2760 |
|
| 2761 |
cpu->xer_ca = 0; |
| 2762 |
|
| 2763 |
s = cpu->gpr[rs]; |
| 2764 |
cpu->gpr[ra] = (m_int32_t)s >> sh; |
| 2765 |
mask = ~(0xFFFFFFFFU << sh); |
| 2766 |
|
| 2767 |
if ((s & 0x80000000) && ((s & mask) != 0)) |
| 2768 |
cpu->xer_ca = 1; |
| 2769 |
|
| 2770 |
return(0); |
| 2771 |
} |
| 2772 |
|
| 2773 |
/* SRAWI. */ |
| 2774 |
static fastcall int ppc32_exec_SRAWI_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2775 |
{ |
| 2776 |
int rs = bits(insn,21,25); |
| 2777 |
int ra = bits(insn,16,20); |
| 2778 |
int sh = bits(insn,11,15); |
| 2779 |
register m_uint32_t s,r,mask; |
| 2780 |
|
| 2781 |
cpu->xer_ca = 0; |
| 2782 |
|
| 2783 |
s = cpu->gpr[rs]; |
| 2784 |
r = (m_int32_t)s >> sh; |
| 2785 |
mask = ~(0xFFFFFFFFU << sh); |
| 2786 |
|
| 2787 |
if ((s & 0x80000000) && ((s & mask) != 0)) |
| 2788 |
cpu->xer_ca = 1; |
| 2789 |
|
| 2790 |
ppc32_exec_update_cr0(cpu,r); |
| 2791 |
cpu->gpr[ra] = r; |
| 2792 |
return(0); |
| 2793 |
} |
| 2794 |
|
| 2795 |
/* SRW - Shift Right Word */ |
| 2796 |
static fastcall int ppc32_exec_SRW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2797 |
{ |
| 2798 |
int rs = bits(insn,21,25); |
| 2799 |
int ra = bits(insn,16,20); |
| 2800 |
int rb = bits(insn,11,15); |
| 2801 |
register m_uint32_t s; |
| 2802 |
|
| 2803 |
s = cpu->gpr[rb] & 0x3f; |
| 2804 |
|
| 2805 |
if (likely(!(s & 0x20))) |
| 2806 |
cpu->gpr[ra] = cpu->gpr[rs] >> s; |
| 2807 |
else |
| 2808 |
cpu->gpr[ra] = 0; |
| 2809 |
|
| 2810 |
return(0); |
| 2811 |
} |
| 2812 |
|
| 2813 |
/* SRW. */ |
| 2814 |
static fastcall int ppc32_exec_SRW_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2815 |
{ |
| 2816 |
int rs = bits(insn,21,25); |
| 2817 |
int ra = bits(insn,16,20); |
| 2818 |
int rb = bits(insn,11,15); |
| 2819 |
register m_uint32_t s,tmp; |
| 2820 |
|
| 2821 |
s = cpu->gpr[rb] & 0x3f; |
| 2822 |
|
| 2823 |
if (likely(!(s & 0x20))) |
| 2824 |
tmp = cpu->gpr[rs] >> s; |
| 2825 |
else |
| 2826 |
tmp = 0; |
| 2827 |
|
| 2828 |
ppc32_exec_update_cr0(cpu,tmp); |
| 2829 |
cpu->gpr[ra] = tmp; |
| 2830 |
return(0); |
| 2831 |
} |
| 2832 |
|
| 2833 |
/* STB - Store Byte */ |
| 2834 |
static fastcall int ppc32_exec_STB(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2835 |
{ |
| 2836 |
int rs = bits(insn,21,25); |
| 2837 |
int ra = bits(insn,16,20); |
| 2838 |
m_uint16_t imm = bits(insn,0,15); |
| 2839 |
m_uint32_t vaddr; |
| 2840 |
|
| 2841 |
vaddr = sign_extend_32(imm,16); |
| 2842 |
|
| 2843 |
if (ra != 0) |
| 2844 |
vaddr += cpu->gpr[ra]; |
| 2845 |
|
| 2846 |
ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); |
| 2847 |
return(0); |
| 2848 |
} |
| 2849 |
|
| 2850 |
/* STBU - Store Byte with Update */ |
| 2851 |
static fastcall int ppc32_exec_STBU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2852 |
{ |
| 2853 |
int rs = bits(insn,21,25); |
| 2854 |
int ra = bits(insn,16,20); |
| 2855 |
m_uint16_t imm = bits(insn,0,15); |
| 2856 |
m_uint32_t vaddr; |
| 2857 |
|
| 2858 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 2859 |
ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); |
| 2860 |
cpu->gpr[ra] = vaddr; |
| 2861 |
return(0); |
| 2862 |
} |
| 2863 |
|
| 2864 |
/* STBUX - Store Byte with Update Indexed */ |
| 2865 |
static fastcall int ppc32_exec_STBUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2866 |
{ |
| 2867 |
int rs = bits(insn,21,25); |
| 2868 |
int ra = bits(insn,16,20); |
| 2869 |
int rb = bits(insn,11,15); |
| 2870 |
m_uint32_t vaddr; |
| 2871 |
|
| 2872 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 2873 |
ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); |
| 2874 |
cpu->gpr[ra] = vaddr; |
| 2875 |
return(0); |
| 2876 |
} |
| 2877 |
|
| 2878 |
/* STBX - Store Byte Indexed */ |
| 2879 |
static fastcall int ppc32_exec_STBX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2880 |
{ |
| 2881 |
int rs = bits(insn,21,25); |
| 2882 |
int ra = bits(insn,16,20); |
| 2883 |
int rb = bits(insn,11,15); |
| 2884 |
m_uint32_t vaddr; |
| 2885 |
|
| 2886 |
vaddr = cpu->gpr[rb]; |
| 2887 |
|
| 2888 |
if (ra != 0) |
| 2889 |
vaddr += cpu->gpr[ra]; |
| 2890 |
|
| 2891 |
ppc32_exec_memop(cpu,PPC_MEMOP_STB,vaddr,rs); |
| 2892 |
return(0); |
| 2893 |
} |
| 2894 |
|
| 2895 |
/* STH - Store Half-Word */ |
| 2896 |
static fastcall int ppc32_exec_STH(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2897 |
{ |
| 2898 |
int rs = bits(insn,21,25); |
| 2899 |
int ra = bits(insn,16,20); |
| 2900 |
m_uint16_t imm = bits(insn,0,15); |
| 2901 |
m_uint32_t vaddr; |
| 2902 |
|
| 2903 |
vaddr = sign_extend_32(imm,16); |
| 2904 |
|
| 2905 |
if (ra != 0) |
| 2906 |
vaddr += cpu->gpr[ra]; |
| 2907 |
|
| 2908 |
ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); |
| 2909 |
return(0); |
| 2910 |
} |
| 2911 |
|
| 2912 |
/* STHU - Store Half-Word with Update */ |
| 2913 |
static fastcall int ppc32_exec_STHU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2914 |
{ |
| 2915 |
int rs = bits(insn,21,25); |
| 2916 |
int ra = bits(insn,16,20); |
| 2917 |
m_uint16_t imm = bits(insn,0,15); |
| 2918 |
m_uint32_t vaddr; |
| 2919 |
|
| 2920 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 2921 |
ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); |
| 2922 |
cpu->gpr[ra] = vaddr; |
| 2923 |
return(0); |
| 2924 |
} |
| 2925 |
|
| 2926 |
/* STHUX - Store Half-Word with Update Indexed */ |
| 2927 |
static fastcall int ppc32_exec_STHUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2928 |
{ |
| 2929 |
int rs = bits(insn,21,25); |
| 2930 |
int ra = bits(insn,16,20); |
| 2931 |
int rb = bits(insn,11,15); |
| 2932 |
m_uint32_t vaddr; |
| 2933 |
|
| 2934 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 2935 |
ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); |
| 2936 |
cpu->gpr[ra] = vaddr; |
| 2937 |
return(0); |
| 2938 |
} |
| 2939 |
|
| 2940 |
/* STHX - Store Half-Word Indexed */ |
| 2941 |
static fastcall int ppc32_exec_STHX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2942 |
{ |
| 2943 |
int rs = bits(insn,21,25); |
| 2944 |
int ra = bits(insn,16,20); |
| 2945 |
int rb = bits(insn,11,15); |
| 2946 |
m_uint32_t vaddr; |
| 2947 |
|
| 2948 |
vaddr = cpu->gpr[rb]; |
| 2949 |
|
| 2950 |
if (ra != 0) |
| 2951 |
vaddr += cpu->gpr[ra]; |
| 2952 |
|
| 2953 |
ppc32_exec_memop(cpu,PPC_MEMOP_STH,vaddr,rs); |
| 2954 |
return(0); |
| 2955 |
} |
| 2956 |
|
| 2957 |
/* STMW - Store Multiple Word */ |
| 2958 |
static fastcall int ppc32_exec_STMW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2959 |
{ |
| 2960 |
int rs = bits(insn,21,25); |
| 2961 |
int ra = bits(insn,16,20); |
| 2962 |
m_uint16_t imm = bits(insn,0,15); |
| 2963 |
m_uint32_t vaddr; |
| 2964 |
int r; |
| 2965 |
|
| 2966 |
vaddr = sign_extend_32(imm,16); |
| 2967 |
|
| 2968 |
if (ra != 0) |
| 2969 |
vaddr += cpu->gpr[ra]; |
| 2970 |
|
| 2971 |
for(r=rs;r<=31;r++) { |
| 2972 |
ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,r); |
| 2973 |
vaddr += sizeof(m_uint32_t); |
| 2974 |
} |
| 2975 |
|
| 2976 |
return(0); |
| 2977 |
} |
| 2978 |
|
| 2979 |
/* STW - Store Word */ |
| 2980 |
static fastcall int ppc32_exec_STW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2981 |
{ |
| 2982 |
int rs = bits(insn,21,25); |
| 2983 |
int ra = bits(insn,16,20); |
| 2984 |
m_uint16_t imm = bits(insn,0,15); |
| 2985 |
m_uint32_t vaddr; |
| 2986 |
|
| 2987 |
vaddr = sign_extend_32(imm,16); |
| 2988 |
|
| 2989 |
if (ra != 0) |
| 2990 |
vaddr += cpu->gpr[ra]; |
| 2991 |
|
| 2992 |
ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); |
| 2993 |
return(0); |
| 2994 |
} |
| 2995 |
|
| 2996 |
/* STWU - Store Word with Update */ |
| 2997 |
static fastcall int ppc32_exec_STWU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 2998 |
{ |
| 2999 |
int rs = bits(insn,21,25); |
| 3000 |
int ra = bits(insn,16,20); |
| 3001 |
m_uint16_t imm = bits(insn,0,15); |
| 3002 |
m_uint32_t vaddr; |
| 3003 |
|
| 3004 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 3005 |
ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); |
| 3006 |
cpu->gpr[ra] = vaddr; |
| 3007 |
return(0); |
| 3008 |
} |
| 3009 |
|
| 3010 |
/* STWUX - Store Word with Update Indexed */ |
| 3011 |
static fastcall int ppc32_exec_STWUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3012 |
{ |
| 3013 |
int rs = bits(insn,21,25); |
| 3014 |
int ra = bits(insn,16,20); |
| 3015 |
int rb = bits(insn,11,15); |
| 3016 |
m_uint32_t vaddr; |
| 3017 |
|
| 3018 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 3019 |
ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); |
| 3020 |
cpu->gpr[ra] = vaddr; |
| 3021 |
return(0); |
| 3022 |
} |
| 3023 |
|
| 3024 |
/* STWX - Store Word Indexed */ |
| 3025 |
static fastcall int ppc32_exec_STWX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3026 |
{ |
| 3027 |
int rs = bits(insn,21,25); |
| 3028 |
int ra = bits(insn,16,20); |
| 3029 |
int rb = bits(insn,11,15); |
| 3030 |
m_uint32_t vaddr; |
| 3031 |
|
| 3032 |
vaddr = cpu->gpr[rb]; |
| 3033 |
|
| 3034 |
if (ra != 0) |
| 3035 |
vaddr += cpu->gpr[ra]; |
| 3036 |
|
| 3037 |
ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); |
| 3038 |
return(0); |
| 3039 |
} |
| 3040 |
|
| 3041 |
/* STWBRX - Store Word Byte-Reverse Indexed */ |
| 3042 |
static fastcall int ppc32_exec_STWBRX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3043 |
{ |
| 3044 |
int rs = bits(insn,21,25); |
| 3045 |
int ra = bits(insn,16,20); |
| 3046 |
int rb = bits(insn,11,15); |
| 3047 |
m_uint32_t vaddr; |
| 3048 |
|
| 3049 |
vaddr = cpu->gpr[rb]; |
| 3050 |
|
| 3051 |
if (ra != 0) |
| 3052 |
vaddr += cpu->gpr[ra]; |
| 3053 |
|
| 3054 |
ppc32_exec_memop(cpu,PPC_MEMOP_STWBR,vaddr,rs); |
| 3055 |
return(0); |
| 3056 |
} |
| 3057 |
|
| 3058 |
/* STWCX. - Store Word Conditional Indexed */ |
| 3059 |
static fastcall int ppc32_exec_STWCX_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3060 |
{ |
| 3061 |
int rs = bits(insn,21,25); |
| 3062 |
int ra = bits(insn,16,20); |
| 3063 |
int rb = bits(insn,11,15); |
| 3064 |
m_uint32_t vaddr; |
| 3065 |
|
| 3066 |
vaddr = cpu->gpr[rb]; |
| 3067 |
|
| 3068 |
if (ra != 0) |
| 3069 |
vaddr += cpu->gpr[ra]; |
| 3070 |
|
| 3071 |
if (cpu->reserve) { |
| 3072 |
ppc32_exec_memop(cpu,PPC_MEMOP_STW,vaddr,rs); |
| 3073 |
|
| 3074 |
cpu->cr_fields[0] = 1 << PPC32_CR_EQ_BIT; |
| 3075 |
|
| 3076 |
if (cpu->xer & PPC32_XER_SO) |
| 3077 |
cpu->cr_fields[0] |= 1 << PPC32_CR_SO_BIT; |
| 3078 |
|
| 3079 |
cpu->reserve = 0; |
| 3080 |
} else { |
| 3081 |
cpu->cr_fields[0] = 0; |
| 3082 |
|
| 3083 |
if (cpu->xer & PPC32_XER_SO) |
| 3084 |
cpu->cr_fields[0] |= 1 << PPC32_CR_SO_BIT; |
| 3085 |
} |
| 3086 |
|
| 3087 |
return(0); |
| 3088 |
} |
| 3089 |
|
| 3090 |
/* STFD - Store Floating-Point Double */ |
| 3091 |
static fastcall int ppc32_exec_STFD(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3092 |
{ |
| 3093 |
int rs = bits(insn,21,25); |
| 3094 |
int ra = bits(insn,16,20); |
| 3095 |
m_uint16_t imm = bits(insn,0,15); |
| 3096 |
m_uint32_t vaddr; |
| 3097 |
|
| 3098 |
vaddr = sign_extend_32(imm,16); |
| 3099 |
|
| 3100 |
if (ra != 0) |
| 3101 |
vaddr += cpu->gpr[ra]; |
| 3102 |
|
| 3103 |
ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); |
| 3104 |
return(0); |
| 3105 |
} |
| 3106 |
|
| 3107 |
/* STFDU - Store Floating-Point Double with Update */ |
| 3108 |
static fastcall int ppc32_exec_STFDU(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3109 |
{ |
| 3110 |
int rs = bits(insn,21,25); |
| 3111 |
int ra = bits(insn,16,20); |
| 3112 |
m_uint16_t imm = bits(insn,0,15); |
| 3113 |
m_uint32_t vaddr; |
| 3114 |
|
| 3115 |
vaddr = cpu->gpr[ra] + sign_extend_32(imm,16); |
| 3116 |
ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); |
| 3117 |
cpu->gpr[ra] = vaddr; |
| 3118 |
return(0); |
| 3119 |
} |
| 3120 |
|
| 3121 |
/* STFDUX - Store Floating-Point Double with Update Indexed */ |
| 3122 |
static fastcall int ppc32_exec_STFDUX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3123 |
{ |
| 3124 |
int rs = bits(insn,21,25); |
| 3125 |
int ra = bits(insn,16,20); |
| 3126 |
int rb = bits(insn,11,15); |
| 3127 |
m_uint32_t vaddr; |
| 3128 |
|
| 3129 |
vaddr = cpu->gpr[ra] + cpu->gpr[rb]; |
| 3130 |
ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); |
| 3131 |
cpu->gpr[ra] = vaddr; |
| 3132 |
return(0); |
| 3133 |
} |
| 3134 |
|
| 3135 |
/* STFDX - Store Floating-Point Double Indexed */ |
| 3136 |
static fastcall int ppc32_exec_STFDX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3137 |
{ |
| 3138 |
int rs = bits(insn,21,25); |
| 3139 |
int ra = bits(insn,16,20); |
| 3140 |
int rb = bits(insn,11,15); |
| 3141 |
m_uint32_t vaddr; |
| 3142 |
|
| 3143 |
vaddr = cpu->gpr[rb]; |
| 3144 |
|
| 3145 |
if (ra != 0) |
| 3146 |
vaddr += cpu->gpr[ra]; |
| 3147 |
|
| 3148 |
ppc32_exec_memop(cpu,PPC_MEMOP_STFD,vaddr,rs); |
| 3149 |
return(0); |
| 3150 |
} |
| 3151 |
|
| 3152 |
/* STSWI - Store String Word Immediate */ |
| 3153 |
static fastcall int ppc32_exec_STSWI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3154 |
{ |
| 3155 |
int rs = bits(insn,21,25); |
| 3156 |
int ra = bits(insn,16,20); |
| 3157 |
int nb = bits(insn,11,15); |
| 3158 |
m_uint32_t vaddr = 0; |
| 3159 |
int r; |
| 3160 |
|
| 3161 |
if (ra != 0) |
| 3162 |
vaddr += cpu->gpr[ra]; |
| 3163 |
|
| 3164 |
if (nb == 0) |
| 3165 |
nb = 32; |
| 3166 |
|
| 3167 |
r = rs - 1; |
| 3168 |
cpu->sw_pos = 0; |
| 3169 |
|
| 3170 |
while(nb > 0) { |
| 3171 |
if (cpu->sw_pos == 0) |
| 3172 |
r = (r + 1) & 0x1F; |
| 3173 |
|
| 3174 |
ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r); |
| 3175 |
cpu->sw_pos += 8; |
| 3176 |
|
| 3177 |
if (cpu->sw_pos == 32) |
| 3178 |
cpu->sw_pos = 0; |
| 3179 |
|
| 3180 |
vaddr++; |
| 3181 |
nb--; |
| 3182 |
} |
| 3183 |
|
| 3184 |
return(0); |
| 3185 |
} |
| 3186 |
|
| 3187 |
/* STSWX - Store String Word Indexed */ |
| 3188 |
static fastcall int ppc32_exec_STSWX(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3189 |
{ |
| 3190 |
int rs = bits(insn,21,25); |
| 3191 |
int ra = bits(insn,16,20); |
| 3192 |
int rb = bits(insn,11,15); |
| 3193 |
m_uint32_t vaddr; |
| 3194 |
int r,nb; |
| 3195 |
|
| 3196 |
vaddr = cpu->gpr[rb]; |
| 3197 |
|
| 3198 |
if (ra != 0) |
| 3199 |
vaddr += cpu->gpr[ra]; |
| 3200 |
|
| 3201 |
nb = cpu->xer & PPC32_XER_BC_MASK; |
| 3202 |
r = rs - 1; |
| 3203 |
cpu->sw_pos = 0; |
| 3204 |
|
| 3205 |
while(nb > 0) { |
| 3206 |
if (cpu->sw_pos == 0) |
| 3207 |
r = (r + 1) & 0x1F; |
| 3208 |
|
| 3209 |
ppc32_exec_memop(cpu,PPC_MEMOP_STSW,vaddr,r); |
| 3210 |
cpu->sw_pos += 8; |
| 3211 |
|
| 3212 |
if (cpu->sw_pos == 32) |
| 3213 |
cpu->sw_pos = 0; |
| 3214 |
|
| 3215 |
vaddr++; |
| 3216 |
nb--; |
| 3217 |
} |
| 3218 |
|
| 3219 |
return(0); |
| 3220 |
} |
| 3221 |
|
| 3222 |
/* SUBF - Subtract From */ |
| 3223 |
static fastcall int ppc32_exec_SUBF(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3224 |
{ |
| 3225 |
int rd = bits(insn,21,25); |
| 3226 |
int ra = bits(insn,16,20); |
| 3227 |
int rb = bits(insn,11,15); |
| 3228 |
|
| 3229 |
cpu->gpr[rd] = cpu->gpr[rb] - cpu->gpr[ra]; |
| 3230 |
return(0); |
| 3231 |
} |
| 3232 |
|
| 3233 |
/* SUBF. */ |
| 3234 |
static fastcall int ppc32_exec_SUBF_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3235 |
{ |
| 3236 |
int rd = bits(insn,21,25); |
| 3237 |
int ra = bits(insn,16,20); |
| 3238 |
int rb = bits(insn,11,15); |
| 3239 |
register m_uint32_t tmp; |
| 3240 |
|
| 3241 |
tmp = cpu->gpr[rb] - cpu->gpr[ra]; |
| 3242 |
ppc32_exec_update_cr0(cpu,tmp); |
| 3243 |
cpu->gpr[rd] = tmp; |
| 3244 |
return(0); |
| 3245 |
} |
| 3246 |
|
| 3247 |
/* SUBFO - Subtract From with Overflow */ |
| 3248 |
static fastcall int ppc32_exec_SUBFO(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3249 |
{ |
| 3250 |
int rd = bits(insn,21,25); |
| 3251 |
int ra = bits(insn,16,20); |
| 3252 |
int rb = bits(insn,11,15); |
| 3253 |
register m_uint32_t a,b,tmp; |
| 3254 |
|
| 3255 |
a = cpu->gpr[ra]; |
| 3256 |
b = cpu->gpr[rb]; |
| 3257 |
|
| 3258 |
tmp = b - a; |
| 3259 |
ppc32_exec_ov_sub(cpu,tmp,b,a); |
| 3260 |
cpu->gpr[rd] = tmp; |
| 3261 |
return(0); |
| 3262 |
} |
| 3263 |
|
| 3264 |
/* SUBFO. */ |
| 3265 |
static fastcall int ppc32_exec_SUBFO_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3266 |
{ |
| 3267 |
int rd = bits(insn,21,25); |
| 3268 |
int ra = bits(insn,16,20); |
| 3269 |
int rb = bits(insn,11,15); |
| 3270 |
register m_uint32_t a,b,tmp; |
| 3271 |
|
| 3272 |
a = cpu->gpr[ra]; |
| 3273 |
b = cpu->gpr[rb]; |
| 3274 |
|
| 3275 |
tmp = b - a; |
| 3276 |
ppc32_exec_ov_sub(cpu,tmp,b,a); |
| 3277 |
ppc32_exec_update_cr0(cpu,tmp); |
| 3278 |
cpu->gpr[rd] = tmp; |
| 3279 |
return(0); |
| 3280 |
} |
| 3281 |
|
| 3282 |
/* SUBFC - Subtract From Carrying */ |
| 3283 |
static fastcall int ppc32_exec_SUBFC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3284 |
{ |
| 3285 |
int rd = bits(insn,21,25); |
| 3286 |
int ra = bits(insn,16,20); |
| 3287 |
int rb = bits(insn,11,15); |
| 3288 |
register m_uint32_t a,b,r,tmp; |
| 3289 |
|
| 3290 |
a = ~cpu->gpr[ra]; |
| 3291 |
b = cpu->gpr[rb]; |
| 3292 |
|
| 3293 |
tmp = a + 1; |
| 3294 |
r = b + tmp; |
| 3295 |
|
| 3296 |
ppc32_exec_ca_sum(cpu,tmp,a,1); |
| 3297 |
if (r < tmp) |
| 3298 |
cpu->xer_ca = 1; |
| 3299 |
|
| 3300 |
cpu->gpr[rd] = r; |
| 3301 |
return(0); |
| 3302 |
} |
| 3303 |
|
| 3304 |
/* SUBFC. */ |
| 3305 |
static fastcall int ppc32_exec_SUBFC_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3306 |
{ |
| 3307 |
int rd = bits(insn,21,25); |
| 3308 |
int ra = bits(insn,16,20); |
| 3309 |
int rb = bits(insn,11,15); |
| 3310 |
register m_uint32_t a,b,r,tmp; |
| 3311 |
|
| 3312 |
a = ~cpu->gpr[ra]; |
| 3313 |
b = cpu->gpr[rb]; |
| 3314 |
|
| 3315 |
tmp = a + 1; |
| 3316 |
r = b + tmp; |
| 3317 |
|
| 3318 |
ppc32_exec_ca_sum(cpu,tmp,a,1); |
| 3319 |
if (r < tmp) |
| 3320 |
cpu->xer_ca = 1; |
| 3321 |
|
| 3322 |
ppc32_exec_update_cr0(cpu,r); |
| 3323 |
cpu->gpr[rd] = r; |
| 3324 |
return(0); |
| 3325 |
} |
| 3326 |
|
| 3327 |
/* SUBFCO - Subtract From with Overflow */ |
| 3328 |
_Unused static fastcall int ppc32_exec_SUBFCO(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3329 |
{ |
| 3330 |
int rd = bits(insn,21,25); |
| 3331 |
int ra = bits(insn,16,20); |
| 3332 |
int rb = bits(insn,11,15); |
| 3333 |
register m_uint32_t a,b,tmp; |
| 3334 |
|
| 3335 |
a = cpu->gpr[ra]; |
| 3336 |
b = cpu->gpr[rb]; |
| 3337 |
tmp = b - a; |
| 3338 |
|
| 3339 |
ppc32_exec_ca_sub(cpu,tmp,b,a); |
| 3340 |
ppc32_exec_ov_sub(cpu,tmp,b,a); |
| 3341 |
cpu->gpr[rd] = tmp; |
| 3342 |
return(0); |
| 3343 |
} |
| 3344 |
|
| 3345 |
/* SUBFCO. */ |
| 3346 |
_Unused static fastcall int ppc32_exec_SUBFCO_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3347 |
{ |
| 3348 |
int rd = bits(insn,21,25); |
| 3349 |
int ra = bits(insn,16,20); |
| 3350 |
int rb = bits(insn,11,15); |
| 3351 |
register m_uint32_t a,b,tmp; |
| 3352 |
|
| 3353 |
a = cpu->gpr[ra]; |
| 3354 |
b = cpu->gpr[rb]; |
| 3355 |
tmp = b - a; |
| 3356 |
|
| 3357 |
ppc32_exec_ca_sub(cpu,tmp,b,a); |
| 3358 |
ppc32_exec_ov_sub(cpu,tmp,b,a); |
| 3359 |
ppc32_exec_update_cr0(cpu,tmp); |
| 3360 |
cpu->gpr[rd] = tmp; |
| 3361 |
return(0); |
| 3362 |
} |
| 3363 |
|
| 3364 |
/* SUBFE - Subtract From Carrying */ |
| 3365 |
static fastcall int ppc32_exec_SUBFE(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3366 |
{ |
| 3367 |
int rd = bits(insn,21,25); |
| 3368 |
int ra = bits(insn,16,20); |
| 3369 |
int rb = bits(insn,11,15); |
| 3370 |
register m_uint32_t a,b,r,tmp; |
| 3371 |
m_uint32_t carry; |
| 3372 |
|
| 3373 |
carry = cpu->xer_ca; |
| 3374 |
|
| 3375 |
a = ~cpu->gpr[ra]; |
| 3376 |
b = cpu->gpr[rb]; |
| 3377 |
tmp = a + carry; |
| 3378 |
r = b + tmp; |
| 3379 |
|
| 3380 |
ppc32_exec_ca_sum(cpu,tmp,a,carry); |
| 3381 |
if (r < tmp) |
| 3382 |
cpu->xer_ca = 1; |
| 3383 |
|
| 3384 |
cpu->gpr[rd] = r; |
| 3385 |
return(0); |
| 3386 |
} |
| 3387 |
|
| 3388 |
/* SUBFIC - Subtract From Immediate Carrying */ |
| 3389 |
static fastcall int ppc32_exec_SUBFIC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3390 |
{ |
| 3391 |
int rd = bits(insn,21,25); |
| 3392 |
int ra = bits(insn,16,20); |
| 3393 |
m_uint16_t imm = bits(insn,0,15); |
| 3394 |
register m_uint32_t a,b,r,tmp; |
| 3395 |
|
| 3396 |
a = ~cpu->gpr[ra]; |
| 3397 |
b = sign_extend_32(imm,16); |
| 3398 |
|
| 3399 |
tmp = a + 1; |
| 3400 |
r = b + tmp; |
| 3401 |
|
| 3402 |
ppc32_exec_ca_sum(cpu,tmp,a,1); |
| 3403 |
if (r < tmp) |
| 3404 |
cpu->xer_ca = 1; |
| 3405 |
|
| 3406 |
cpu->gpr[rd] = r; |
| 3407 |
return(0); |
| 3408 |
} |
| 3409 |
|
| 3410 |
/* SUBFZE - Subtract From Zero extended */ |
| 3411 |
static fastcall int ppc32_exec_SUBFZE(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3412 |
{ |
| 3413 |
int rd = bits(insn,21,25); |
| 3414 |
int ra = bits(insn,16,20); |
| 3415 |
register m_uint32_t a,r; |
| 3416 |
m_uint32_t carry; |
| 3417 |
|
| 3418 |
carry = cpu->xer_ca; |
| 3419 |
|
| 3420 |
a = ~cpu->gpr[ra]; |
| 3421 |
r = a + carry; |
| 3422 |
|
| 3423 |
if (r < a) |
| 3424 |
cpu->xer_ca = 1; |
| 3425 |
|
| 3426 |
cpu->gpr[rd] = r; |
| 3427 |
return(0); |
| 3428 |
} |
| 3429 |
|
| 3430 |
/* SUBFZE. */ |
| 3431 |
static fastcall int ppc32_exec_SUBFZE_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3432 |
{ |
| 3433 |
int rd = bits(insn,21,25); |
| 3434 |
int ra = bits(insn,16,20); |
| 3435 |
register m_uint32_t a,r; |
| 3436 |
m_uint32_t carry; |
| 3437 |
|
| 3438 |
carry = cpu->xer_ca; |
| 3439 |
|
| 3440 |
a = ~cpu->gpr[ra]; |
| 3441 |
r = a + carry; |
| 3442 |
|
| 3443 |
if (r < a) |
| 3444 |
cpu->xer_ca = 1; |
| 3445 |
|
| 3446 |
ppc32_exec_update_cr0(cpu,r); |
| 3447 |
cpu->gpr[rd] = r; |
| 3448 |
return(0); |
| 3449 |
} |
| 3450 |
|
| 3451 |
/* SYNC - Synchronize */ |
| 3452 |
static fastcall int ppc32_exec_SYNC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3453 |
{ |
| 3454 |
return(0); |
| 3455 |
} |
| 3456 |
|
| 3457 |
/* TLBIA - TLB Invalidate All */ |
| 3458 |
static fastcall int ppc32_exec_TLBIA(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3459 |
{ |
| 3460 |
ppc32_mem_invalidate_cache(cpu); |
| 3461 |
return(0); |
| 3462 |
} |
| 3463 |
|
| 3464 |
/* TLBIE - TLB Invalidate Entry */ |
| 3465 |
static fastcall int ppc32_exec_TLBIE(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3466 |
{ |
| 3467 |
ppc32_mem_invalidate_cache(cpu); |
| 3468 |
return(0); |
| 3469 |
} |
| 3470 |
|
| 3471 |
/* TLBSYNC - TLB Synchronize */ |
| 3472 |
static fastcall int ppc32_exec_TLBSYNC(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3473 |
{ |
| 3474 |
return(0); |
| 3475 |
} |
| 3476 |
|
| 3477 |
/* TW - Trap Word */ |
| 3478 |
static fastcall int ppc32_exec_TW(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3479 |
{ |
| 3480 |
int to = bits(insn,21,25); |
| 3481 |
int ra = bits(insn,16,20); |
| 3482 |
int rb = bits(insn,11,15); |
| 3483 |
m_int32_t a,b; |
| 3484 |
|
| 3485 |
a = cpu->gpr[ra]; |
| 3486 |
b = cpu->gpr[rb]; |
| 3487 |
|
| 3488 |
if (((a < b) && (to & 0x10)) || |
| 3489 |
((a > b) && (to & 0x08)) || |
| 3490 |
((a == b) && (to & 0x04)) || |
| 3491 |
(((m_uint32_t)a < (m_uint32_t)b) && (to & 0x02)) || |
| 3492 |
(((m_uint32_t)a > (m_uint32_t)b) && (to & 0x01))) |
| 3493 |
{ |
| 3494 |
ppc32_trigger_exception(cpu,PPC32_EXC_PROG); |
| 3495 |
cpu->srr1 |= 1 << 17; |
| 3496 |
return(1); |
| 3497 |
} |
| 3498 |
|
| 3499 |
return(0); |
| 3500 |
} |
| 3501 |
|
| 3502 |
/* TWI - Trap Word Immediate */ |
| 3503 |
static fastcall int ppc32_exec_TWI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3504 |
{ |
| 3505 |
int to = bits(insn,21,25); |
| 3506 |
int ra = bits(insn,16,20); |
| 3507 |
m_uint16_t imm = bits(insn,0,15); |
| 3508 |
m_int32_t a,b; |
| 3509 |
|
| 3510 |
a = cpu->gpr[ra]; |
| 3511 |
b = sign_extend(imm,16); |
| 3512 |
|
| 3513 |
if (((a < b) && (to & 0x10)) || |
| 3514 |
((a > b) && (to & 0x08)) || |
| 3515 |
((a == b) && (to & 0x04)) || |
| 3516 |
(((m_uint32_t)a < (m_uint32_t)b) && (to & 0x02)) || |
| 3517 |
(((m_uint32_t)a > (m_uint32_t)b) && (to & 0x01))) |
| 3518 |
{ |
| 3519 |
ppc32_trigger_exception(cpu,PPC32_EXC_PROG); |
| 3520 |
cpu->srr1 |= 1 << 17; |
| 3521 |
return(1); |
| 3522 |
} |
| 3523 |
|
| 3524 |
return(0); |
| 3525 |
} |
| 3526 |
|
| 3527 |
/* XOR */ |
| 3528 |
static fastcall int ppc32_exec_XOR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3529 |
{ |
| 3530 |
int rs = bits(insn,21,25); |
| 3531 |
int ra = bits(insn,16,20); |
| 3532 |
int rb = bits(insn,11,15); |
| 3533 |
|
| 3534 |
cpu->gpr[ra] = cpu->gpr[rs] ^ cpu->gpr[rb]; |
| 3535 |
return(0); |
| 3536 |
} |
| 3537 |
|
| 3538 |
/* XOR. */ |
| 3539 |
static fastcall int ppc32_exec_XOR_dot(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3540 |
{ |
| 3541 |
int rs = bits(insn,21,25); |
| 3542 |
int ra = bits(insn,16,20); |
| 3543 |
int rb = bits(insn,11,15); |
| 3544 |
m_uint32_t tmp; |
| 3545 |
|
| 3546 |
tmp = cpu->gpr[rs] ^ cpu->gpr[rb]; |
| 3547 |
ppc32_exec_update_cr0(cpu,tmp); |
| 3548 |
cpu->gpr[ra] = tmp; |
| 3549 |
return(0); |
| 3550 |
} |
| 3551 |
|
| 3552 |
/* XORI - XOR Immediate */ |
| 3553 |
static fastcall int ppc32_exec_XORI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3554 |
{ |
| 3555 |
int rs = bits(insn,21,25); |
| 3556 |
int ra = bits(insn,16,20); |
| 3557 |
m_uint16_t imm = bits(insn,0,15); |
| 3558 |
|
| 3559 |
cpu->gpr[ra] = cpu->gpr[rs] ^ imm; |
| 3560 |
return(0); |
| 3561 |
} |
| 3562 |
|
| 3563 |
/* XORIS - XOR Immediate Shifted */ |
| 3564 |
static fastcall int ppc32_exec_XORIS(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3565 |
{ |
| 3566 |
int rs = bits(insn,21,25); |
| 3567 |
int ra = bits(insn,16,20); |
| 3568 |
m_uint32_t imm = bits(insn,0,15); |
| 3569 |
|
| 3570 |
cpu->gpr[ra] = cpu->gpr[rs] ^ (imm << 16); |
| 3571 |
return(0); |
| 3572 |
} |
| 3573 |
|
| 3574 |
/* DCCCI - Data Cache Congruence Class Invalidate (PowerPC 405) */ |
| 3575 |
static fastcall int ppc32_exec_DCCCI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3576 |
{ |
| 3577 |
int ra = bits(insn,16,20); |
| 3578 |
int rb = bits(insn,11,15); |
| 3579 |
m_uint32_t vaddr; |
| 3580 |
|
| 3581 |
vaddr = cpu->gpr[rb]; |
| 3582 |
|
| 3583 |
if (ra != 0) |
| 3584 |
vaddr += cpu->gpr[ra]; |
| 3585 |
|
| 3586 |
return(0); |
| 3587 |
} |
| 3588 |
|
| 3589 |
/* ICCCI - Instruction Cache Congruence Class Invalidate (PowerPC 405) */ |
| 3590 |
static fastcall int ppc32_exec_ICCCI(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3591 |
{ |
| 3592 |
int ra = bits(insn,16,20); |
| 3593 |
int rb = bits(insn,11,15); |
| 3594 |
m_uint32_t vaddr; |
| 3595 |
|
| 3596 |
vaddr = cpu->gpr[rb]; |
| 3597 |
|
| 3598 |
if (ra != 0) |
| 3599 |
vaddr += cpu->gpr[ra]; |
| 3600 |
|
| 3601 |
return(0); |
| 3602 |
} |
| 3603 |
|
| 3604 |
/* MFDCR - Move From Device Control Register (PowerPC 405) */ |
| 3605 |
static fastcall int ppc32_exec_MFDCR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3606 |
{ |
| 3607 |
int UNUSED(rt) = bits(insn,21,25); |
| 3608 |
return(0); |
| 3609 |
} |
| 3610 |
|
| 3611 |
/* MTDCR - Move To Device Control Register (PowerPC 405) */ |
| 3612 |
static fastcall int ppc32_exec_MTDCR(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3613 |
{ |
| 3614 |
int UNUSED(rt) = bits(insn,21,25); |
| 3615 |
return(0); |
| 3616 |
} |
| 3617 |
|
| 3618 |
/* TLBRE - TLB Read Entry (PowerPC 405) */ |
| 3619 |
static fastcall int ppc32_exec_TLBRE(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3620 |
{ |
| 3621 |
int rt = bits(insn,21,25); |
| 3622 |
int ra = bits(insn,16,20); |
| 3623 |
int ws = bits(insn,11,15); |
| 3624 |
m_uint32_t index; |
| 3625 |
|
| 3626 |
index = cpu->gpr[ra] & 0x3F; |
| 3627 |
|
| 3628 |
if (ws == 1) { |
| 3629 |
cpu->gpr[rt] = cpu->ppc405_tlb[index].tlb_lo; |
| 3630 |
} else { |
| 3631 |
cpu->gpr[rt] = cpu->ppc405_tlb[index].tlb_hi; |
| 3632 |
cpu->ppc405_pid = cpu->ppc405_tlb[index].tid; |
| 3633 |
} |
| 3634 |
|
| 3635 |
return(0); |
| 3636 |
} |
| 3637 |
|
| 3638 |
/* TLBWE - TLB Write Entry (PowerPC 405) */ |
| 3639 |
static fastcall int ppc32_exec_TLBWE(cpu_ppc_t *cpu,ppc_insn_t insn) |
| 3640 |
{ |
| 3641 |
int rs = bits(insn,21,25); |
| 3642 |
int ra = bits(insn,16,20); |
| 3643 |
int ws = bits(insn,11,15); |
| 3644 |
m_uint32_t index; |
| 3645 |
|
| 3646 |
index = cpu->gpr[ra] & 0x3F; |
| 3647 |
|
| 3648 |
if (ws == 1) { |
| 3649 |
cpu->ppc405_tlb[index].tlb_lo = cpu->gpr[rs]; |
| 3650 |
} else { |
| 3651 |
cpu->ppc405_tlb[index].tlb_hi = cpu->gpr[rs]; |
| 3652 |
cpu->ppc405_tlb[index].tid = cpu->ppc405_pid; |
| 3653 |
} |
| 3654 |
|
| 3655 |
return(0); |
| 3656 |
} |
| 3657 |
|
| 3658 |
/* PowerPC instruction array */ |
| 3659 |
static struct ppc32_insn_exec_tag ppc32_exec_tags[] = { |
| 3660 |
{ "mflr" , ppc32_exec_MFLR , 0xfc1fffff , 0x7c0802a6, 0 }, |
| 3661 |
{ "mtlr" , ppc32_exec_MTLR , 0xfc1fffff , 0x7c0803a6, 0 }, |
| 3662 |
{ "mfctr" , ppc32_exec_MFCTR , 0xfc1fffff , 0x7c0902a6, 0 }, |
| 3663 |
{ "mtctr" , ppc32_exec_MTCTR , 0xfc1fffff , 0x7c0903a6, 0 }, |
| 3664 |
{ "add" , ppc32_exec_ADD , 0xfc0007ff , 0x7c000214, 0 }, |
| 3665 |
{ "add." , ppc32_exec_ADD_dot , 0xfc0007ff , 0x7c000215, 0 }, |
| 3666 |
{ "addo" , ppc32_exec_ADDO , 0xfc0007ff , 0x7c000614, 0 }, |
| 3667 |
{ "addo." , ppc32_exec_ADDO_dot , 0xfc0007ff , 0x7c000615, 0 }, |
| 3668 |
{ "addc" , ppc32_exec_ADDC , 0xfc0007ff , 0x7c000014, 0 }, |
| 3669 |
{ "addc." , ppc32_exec_ADDC_dot , 0xfc0007ff , 0x7c000015, 0 }, |
| 3670 |
{ "addco" , ppc32_exec_ADDCO , 0xfc0007ff , 0x7c000414, 0 }, |
| 3671 |
{ "addco." , ppc32_exec_ADDCO_dot , 0xfc0007ff , 0x7c000415, 0 }, |
| 3672 |
{ "adde" , ppc32_exec_ADDE , 0xfc0007ff , 0x7c000114, 0 }, |
| 3673 |
{ "adde." , ppc32_exec_ADDE_dot , 0xfc0007ff , 0x7c000115, 0 }, |
| 3674 |
{ "addeo" , ppc32_exec_ADDEO , 0xfc0007ff , 0x7c000514, 0 }, |
| 3675 |
{ "addeo." , ppc32_exec_ADDEO_dot , 0xfc0007ff , 0x7c000515, 0 }, |
| 3676 |
{ "addi" , ppc32_exec_ADDI , 0xfc000000 , 0x38000000, 0 }, |
| 3677 |
{ "addic" , ppc32_exec_ADDIC , 0xfc000000 , 0x30000000, 0 }, |
| 3678 |
{ "addic." , ppc32_exec_ADDIC_dot , 0xfc000000 , 0x34000000, 0 }, |
| 3679 |
{ "addis" , ppc32_exec_ADDIS , 0xfc000000 , 0x3c000000, 0 }, |
| 3680 |
{ "addme" , ppc32_exec_ADDME , 0xfc00ffff , 0x7c0001d4, 0 }, |
| 3681 |
{ "addme." , ppc32_exec_ADDME_dot , 0xfc00ffff , 0x7c0001d5, 0 }, |
| 3682 |
{ "addze" , ppc32_exec_ADDZE , 0xfc00ffff , 0x7c000194, 0 }, |
| 3683 |
{ "addze." , ppc32_exec_ADDZE_dot , 0xfc00ffff , 0x7c000195, 0 }, |
| 3684 |
{ "and" , ppc32_exec_AND , 0xfc0007ff , 0x7c000038, 0 }, |
| 3685 |
{ "and." , ppc32_exec_AND_dot , 0xfc0007ff , 0x7c000039, 0 }, |
| 3686 |
{ "andc" , ppc32_exec_ANDC , 0xfc0007ff , 0x7c000078, 0 }, |
| 3687 |
{ "andc." , ppc32_exec_ANDC_dot , 0xfc0007ff , 0x7c000079, 0 }, |
| 3688 |
{ "andi." , ppc32_exec_ANDI_dot , 0xfc000000 , 0x70000000, 0 }, |
| 3689 |
{ "andis." , ppc32_exec_ANDIS_dot , 0xfc000000 , 0x74000000, 0 }, |
| 3690 |
{ "b" , ppc32_exec_B , 0xfc000003 , 0x48000000, 0 }, |
| 3691 |
{ "ba" , ppc32_exec_BA , 0xfc000003 , 0x48000002, 0 }, |
| 3692 |
{ "bl" , ppc32_exec_BL , 0xfc000003 , 0x48000001, 0 }, |
| 3693 |
{ "bla" , ppc32_exec_BLA , 0xfc000003 , 0x48000003, 0 }, |
| 3694 |
{ "bc" , ppc32_exec_BC , 0xfc000003 , 0x40000000, 0 }, |
| 3695 |
{ "bca" , ppc32_exec_BCA , 0xfc000003 , 0x40000002, 0 }, |
| 3696 |
{ "bcl" , ppc32_exec_BCL , 0xfc000003 , 0x40000001, 0 }, |
| 3697 |
{ "bcla" , ppc32_exec_BCLA , 0xfc000003 , 0x40000003, 0 }, |
| 3698 |
{ "bclr" , ppc32_exec_BCLR , 0xfc00ffff , 0x4c000020, 0 }, |
| 3699 |
{ "bclrl" , ppc32_exec_BCLRL , 0xfc00ffff , 0x4c000021, 0 }, |
| 3700 |
{ "bcctr" , ppc32_exec_BCCTR , 0xfc00ffff , 0x4c000420, 0 }, |
| 3701 |
{ "bcctrl" , ppc32_exec_BCCTRL , 0xfc00ffff , 0x4c000421, 0 }, |
| 3702 |
{ "cmp" , ppc32_exec_CMP , 0xfc6007ff , 0x7c000000, 0 }, |
| 3703 |
{ "cmpi" , ppc32_exec_CMPI , 0xfc600000 , 0x2c000000, 0 }, |
| 3704 |
{ "cmpl" , ppc32_exec_CMPL , 0xfc6007ff , 0x7c000040, 0 }, |
| 3705 |
{ "cmpli" , ppc32_exec_CMPLI , 0xfc600000 , 0x28000000, 0 }, |
| 3706 |
{ "cntlzw" , ppc32_exec_CNTLZW , 0xfc00ffff , 0x7c000034, 0 }, |
| 3707 |
{ "crand" , ppc32_exec_CRAND , 0xfc0007ff , 0x4c000202, 0 }, |
| 3708 |
{ "crandc" , ppc32_exec_CRANDC , 0xfc0007ff , 0x4c000102, 0 }, |
| 3709 |
{ "creqv" , ppc32_exec_CREQV , 0xfc0007ff , 0x4c000242, 0 }, |
| 3710 |
{ "crnand" , ppc32_exec_CRNAND , 0xfc0007ff , 0x4c0001c2, 0 }, |
| 3711 |
{ "crnor" , ppc32_exec_CRNOR , 0xfc0007ff , 0x4c000042, 0 }, |
| 3712 |
{ "cror" , ppc32_exec_CROR , 0xfc0007ff , 0x4c000382, 0 }, |
| 3713 |
{ "crorc" , ppc32_exec_CRORC , 0xfc0007ff , 0x4c000342, 0 }, |
| 3714 |
{ "crxor" , ppc32_exec_CRXOR , 0xfc0007ff , 0x4c000182, 0 }, |
| 3715 |
{ "dcbf" , ppc32_exec_DCBF , 0xffe007ff , 0x7c0000ac, 0 }, |
| 3716 |
{ "dcbi" , ppc32_exec_DCBI , 0xffe007ff , 0x7c0003ac, 0 }, |
| 3717 |
{ "dcbt" , ppc32_exec_DCBT , 0xffe007ff , 0x7c00022c, 0 }, |
| 3718 |
{ "dcbst" , ppc32_exec_DCBST , 0xffe007ff , 0x7c00006c, 0 }, |
| 3719 |
{ "divw" , ppc32_exec_DIVW , 0xfc0007ff , 0x7c0003d6, 0 }, |
| 3720 |
{ "divw." , ppc32_exec_DIVW_dot , 0xfc0007ff , 0x7c0003d7, 0 }, |
| 3721 |
{ "divwu" , ppc32_exec_DIVWU , 0xfc0007ff , 0x7c000396, 0 }, |
| 3722 |
{ "divwu." , ppc32_exec_DIVWU_dot , 0xfc0007ff , 0x7c000397, 0 }, |
| 3723 |
{ "eieio" , ppc32_exec_EIEIO , 0xffffffff , 0x7c0006ac, 0 }, |
| 3724 |
{ "eqv" , ppc32_exec_EQV , 0xfc0007ff , 0x7c000238, 0 }, |
| 3725 |
{ "extsb" , ppc32_exec_EXTSB , 0xfc00ffff , 0x7c000774, 0 }, |
| 3726 |
{ "extsb." , ppc32_exec_EXTSB_dot , 0xfc00ffff , 0x7c000775, 0 }, |
| 3727 |
{ "extsh" , ppc32_exec_EXTSH , 0xfc00ffff , 0x7c000734, 0 }, |
| 3728 |
{ "extsh." , ppc32_exec_EXTSH_dot , 0xfc00ffff , 0x7c000735, 0 }, |
| 3729 |
{ "icbi" , ppc32_exec_ICBI , 0xffe007ff , 0x7c0007ac, 0 }, |
| 3730 |
{ "isync" , ppc32_exec_ISYNC , 0xffffffff , 0x4c00012c, 0 }, |
| 3731 |
{ "lbz" , ppc32_exec_LBZ , 0xfc000000 , 0x88000000, 0 }, |
| 3732 |
{ "lbzu" , ppc32_exec_LBZU , 0xfc000000 , 0x8c000000, 0 }, |
| 3733 |
{ "lbzux" , ppc32_exec_LBZUX , 0xfc0007ff , 0x7c0000ee, 0 }, |
| 3734 |
{ "lbzx" , ppc32_exec_LBZX , 0xfc0007ff , 0x7c0000ae, 0 }, |
| 3735 |
{ "lha" , ppc32_exec_LHA , 0xfc000000 , 0xa8000000, 0 }, |
| 3736 |
{ "lhau" , ppc32_exec_LHAU , 0xfc000000 , 0xac000000, 0 }, |
| 3737 |
{ "lhaux" , ppc32_exec_LHAUX , 0xfc0007ff , 0x7c0002ee, 0 }, |
| 3738 |
{ "lhax" , ppc32_exec_LHAX , 0xfc0007ff , 0x7c0002ae, 0 }, |
| 3739 |
{ "lhz" , ppc32_exec_LHZ , 0xfc000000 , 0xa0000000, 0 }, |
| 3740 |
{ "lhzu" , ppc32_exec_LHZU , 0xfc000000 , 0xa4000000, 0 }, |
| 3741 |
{ "lhzux" , ppc32_exec_LHZUX , 0xfc0007ff , 0x7c00026e, 0 }, |
| 3742 |
{ "lhzx" , ppc32_exec_LHZX , 0xfc0007ff , 0x7c00022e, 0 }, |
| 3743 |
{ "lmw" , ppc32_exec_LMW , 0xfc000000 , 0xb8000000, 0 }, |
| 3744 |
{ "lwbrx" , ppc32_exec_LWBRX , 0xfc0007ff , 0x7c00042c, 0 }, |
| 3745 |
{ "lwz" , ppc32_exec_LWZ , 0xfc000000 , 0x80000000, 0 }, |
| 3746 |
{ "lwzu" , ppc32_exec_LWZU , 0xfc000000 , 0x84000000, 0 }, |
| 3747 |
{ "lwzux" , ppc32_exec_LWZUX , 0xfc0007ff , 0x7c00006e, 0 }, |
| 3748 |
{ "lwzx" , ppc32_exec_LWZX , 0xfc0007ff , 0x7c00002e, 0 }, |
| 3749 |
{ "lwarx" , ppc32_exec_LWARX , 0xfc0007ff , 0x7c000028, 0 }, |
| 3750 |
{ "lfd" , ppc32_exec_LFD , 0xfc000000 , 0xc8000000, 0 }, |
| 3751 |
{ "lfdu" , ppc32_exec_LFDU , 0xfc000000 , 0xcc000000, 0 }, |
| 3752 |
{ "lfdux" , ppc32_exec_LFDUX , 0xfc0007ff , 0x7c0004ee, 0 }, |
| 3753 |
{ "lfdx" , ppc32_exec_LFDX , 0xfc0007ff , 0x7c0004ae, 0 }, |
| 3754 |
{ "lswi" , ppc32_exec_LSWI , 0xfc0007ff , 0x7c0004aa, 0 }, |
| 3755 |
{ "lswx" , ppc32_exec_LSWX , 0xfc0007ff , 0x7c00042a, 0 }, |
| 3756 |
{ "mcrf" , ppc32_exec_MCRF , 0xfc63ffff , 0x4c000000, 0 }, |
| 3757 |
{ "mfcr" , ppc32_exec_MFCR , 0xfc1fffff , 0x7c000026, 0 }, |
| 3758 |
{ "mfmsr" , ppc32_exec_MFMSR , 0xfc1fffff , 0x7c0000a6, 0 }, |
| 3759 |
{ "mfspr" , ppc32_exec_MFSPR , 0xfc0007ff , 0x7c0002a6, 0 }, |
| 3760 |
{ "mfsr" , ppc32_exec_MFSR , 0xfc10ffff , 0x7c0004a6, 0 }, |
| 3761 |
{ "mfsrin" , ppc32_exec_MFSRIN , 0xfc1f07ff , 0x7c000526, 0 }, |
| 3762 |
{ "mftbl" , ppc32_exec_MFTBL , 0xfc1ff7ff , 0x7c0c42e6, 0 }, |
| 3763 |
{ "mftbu" , ppc32_exec_MFTBU , 0xfc1ff7ff , 0x7c0d42e6, 0 }, |
| 3764 |
{ "mtcrf" , ppc32_exec_MTCRF , 0xfc100fff , 0x7c000120, 0 }, |
| 3765 |
{ "mtmsr" , ppc32_exec_MTMSR , 0xfc1fffff , 0x7c000124, 0 }, |
| 3766 |
{ "mtspr" , ppc32_exec_MTSPR , 0xfc0007ff , 0x7c0003a6, 0 }, |
| 3767 |
{ "mtsr" , ppc32_exec_MTSR , 0xfc10ffff , 0x7c0001a4, 0 }, |
| 3768 |
{ "mulhw" , ppc32_exec_MULHW , 0xfc0007ff , 0x7c000096, 0 }, |
| 3769 |
{ "mulhw." , ppc32_exec_MULHW_dot , 0xfc0007ff , 0x7c000097, 0 }, |
| 3770 |
{ "mulhwu" , ppc32_exec_MULHWU , 0xfc0007ff , 0x7c000016, 0 }, |
| 3771 |
{ "mulhwu." , ppc32_exec_MULHWU_dot , 0xfc0007ff , 0x7c000017, 0 }, |
| 3772 |
{ "mulli" , ppc32_exec_MULLI , 0xfc000000 , 0x1c000000, 0 }, |
| 3773 |
{ "mullw" , ppc32_exec_MULLW , 0xfc0007ff , 0x7c0001d6, 0 }, |
| 3774 |
{ "mullw." , ppc32_exec_MULLW_dot , 0xfc0007ff , 0x7c0001d7, 0 }, |
| 3775 |
{ "mullwo" , ppc32_exec_MULLWO , 0xfc0007ff , 0x7c0005d6, 0 }, |
| 3776 |
{ "mullwo." , ppc32_exec_MULLWO_dot , 0xfc0007ff , 0x7c0005d7, 0 }, |
| 3777 |
{ "nand" , ppc32_exec_NAND , 0xfc0007ff , 0x7c0003b8, 0 }, |
| 3778 |
{ "nand." , ppc32_exec_NAND_dot , 0xfc0007ff , 0x7c0003b9, 0 }, |
| 3779 |
{ "neg" , ppc32_exec_NEG , 0xfc00ffff , 0x7c0000d0, 0 }, |
| 3780 |
{ "neg." , ppc32_exec_NEG_dot , 0xfc00ffff , 0x7c0000d1, 0 }, |
| 3781 |
{ "nego" , ppc32_exec_NEGO , 0xfc00ffff , 0x7c0004d0, 0 }, |
| 3782 |
{ "nego." , ppc32_exec_NEGO_dot , 0xfc00ffff , 0x7c0004d1, 0 }, |
| 3783 |
{ "nor" , ppc32_exec_NOR , 0xfc0007ff , 0x7c0000f8, 0 }, |
| 3784 |
{ "nor." , ppc32_exec_NOR_dot , 0xfc0007ff , 0x7c0000f9, 0 }, |
| 3785 |
{ "or" , ppc32_exec_OR , 0xfc0007ff , 0x7c000378, 0 }, |
| 3786 |
{ "or." , ppc32_exec_OR_dot , 0xfc0007ff , 0x7c000379, 0 }, |
| 3787 |
{ "orc" , ppc32_exec_ORC , 0xfc0007ff , 0x7c000338, 0 }, |
| 3788 |
{ "orc." , ppc32_exec_ORC_dot , 0xfc0007ff , 0x7c000339, 0 }, |
| 3789 |
{ "ori" , ppc32_exec_ORI , 0xfc000000 , 0x60000000, 0 }, |
| 3790 |
{ "oris" , ppc32_exec_ORIS , 0xfc000000 , 0x64000000, 0 }, |
| 3791 |
{ "rfi" , ppc32_exec_RFI , 0xffffffff , 0x4c000064, 0 }, |
| 3792 |
{ "rlwimi" , ppc32_exec_RLWIMI , 0xfc000001 , 0x50000000, 0 }, |
| 3793 |
{ "rlwimi." , ppc32_exec_RLWIMI_dot , 0xfc000001 , 0x50000001, 0 }, |
| 3794 |
{ "rlwinm" , ppc32_exec_RLWINM , 0xfc000001 , 0x54000000, 0 }, |
| 3795 |
{ "rlwinm." , ppc32_exec_RLWINM_dot , 0xfc000001 , 0x54000001, 0 }, |
| 3796 |
{ "rlwnm" , ppc32_exec_RLWNM , 0xfc000001 , 0x5c000000, 0 }, |
| 3797 |
{ "rlwnm." , ppc32_exec_RLWNM_dot , 0xfc000001 , 0x5c000001, 0 }, |
| 3798 |
{ "sc" , ppc32_exec_SC , 0xffffffff , 0x44000002, 0 }, |
| 3799 |
{ "slw" , ppc32_exec_SLW , 0xfc0007ff , 0x7c000030, 0 }, |
| 3800 |
{ "slw." , ppc32_exec_SLW_dot , 0xfc0007ff , 0x7c000031, 0 }, |
| 3801 |
{ "sraw" , ppc32_exec_SRAW , 0xfc0007ff , 0x7c000630, 0 }, |
| 3802 |
{ "srawi" , ppc32_exec_SRAWI , 0xfc0007ff , 0x7c000670, 0 }, |
| 3803 |
{ "srawi." , ppc32_exec_SRAWI_dot , 0xfc0007ff , 0x7c000671, 0 }, |
| 3804 |
{ "srw" , ppc32_exec_SRW , 0xfc0007ff , 0x7c000430, 0 }, |
| 3805 |
{ "srw." , ppc32_exec_SRW_dot , 0xfc0007ff , 0x7c000431, 0 }, |
| 3806 |
{ "stb" , ppc32_exec_STB , 0xfc000000 , 0x98000000, 0 }, |
| 3807 |
{ "stbu" , ppc32_exec_STBU , 0xfc000000 , 0x9c000000, 0 }, |
| 3808 |
{ "stbux" , ppc32_exec_STBUX , 0xfc0007ff , 0x7c0001ee, 0 }, |
| 3809 |
{ "stbx" , ppc32_exec_STBX , 0xfc0007ff , 0x7c0001ae, 0 }, |
| 3810 |
{ "sth" , ppc32_exec_STH , 0xfc000000 , 0xb0000000, 0 }, |
| 3811 |
{ "sthu" , ppc32_exec_STHU , 0xfc000000 , 0xb4000000, 0 }, |
| 3812 |
{ "sthux" , ppc32_exec_STHUX , 0xfc0007ff , 0x7c00036e, 0 }, |
| 3813 |
{ "sthx" , ppc32_exec_STHX , 0xfc0007ff , 0x7c00032e, 0 }, |
| 3814 |
{ "stmw" , ppc32_exec_STMW , 0xfc000000 , 0xbc000000, 0 }, |
| 3815 |
{ "stw" , ppc32_exec_STW , 0xfc000000 , 0x90000000, 0 }, |
| 3816 |
{ "stwu" , ppc32_exec_STWU , 0xfc000000 , 0x94000000, 0 }, |
| 3817 |
{ "stwux" , ppc32_exec_STWUX , 0xfc0007ff , 0x7c00016e, 0 }, |
| 3818 |
{ "stwx" , ppc32_exec_STWX , 0xfc0007ff , 0x7c00012e, 0 }, |
| 3819 |
{ "stwbrx" , ppc32_exec_STWBRX , 0xfc0007ff , 0x7c00052c, 0 }, |
| 3820 |
{ "stwcx." , ppc32_exec_STWCX_dot , 0xfc0007ff , 0x7c00012d, 0 }, |
| 3821 |
{ "stfd" , ppc32_exec_STFD , 0xfc000000 , 0xd8000000, 0 }, |
| 3822 |
{ "stfdu" , ppc32_exec_STFDU , 0xfc000000 , 0xdc000000, 0 }, |
| 3823 |
{ "stfdux" , ppc32_exec_STFDUX , 0xfc0007ff , 0x7c0005ee, 0 }, |
| 3824 |
{ "stfdx" , ppc32_exec_STFDX , 0xfc0007ff , 0x7c0005ae, 0 }, |
| 3825 |
{ "stswi" , ppc32_exec_STSWI , 0xfc0007ff , 0x7c0005aa, 0 }, |
| 3826 |
{ "stswx" , ppc32_exec_STSWX , 0xfc0007ff , 0x7c00052a, 0 }, |
| 3827 |
{ "subf" , ppc32_exec_SUBF , 0xfc0007ff , 0x7c000050, 0 }, |
| 3828 |
{ "subf." , ppc32_exec_SUBF_dot , 0xfc0007ff , 0x7c000051, 0 }, |
| 3829 |
{ "subfo" , ppc32_exec_SUBFO , 0xfc0007ff , 0x7c000450, 0 }, |
| 3830 |
{ "subfo." , ppc32_exec_SUBFO_dot , 0xfc0007ff , 0x7c000451, 0 }, |
| 3831 |
{ "subfc" , ppc32_exec_SUBFC , 0xfc0007ff , 0x7c000010, 0 }, |
| 3832 |
{ "subfc." , ppc32_exec_SUBFC_dot , 0xfc0007ff , 0x7c000011, 0 }, |
| 3833 |
//{ "subfco" , ppc32_exec_SUBFCO , 0xfc0007ff , 0x7c000410, 0 }, |
| 3834 |
//{ "subfco." , ppc32_exec_SUBFCO_dot , 0xfc0007ff , 0x7c000411, 0 }, |
| 3835 |
{ "subfe" , ppc32_exec_SUBFE , 0xfc0007ff , 0x7c000110, 0 }, |
| 3836 |
{ "subfic" , ppc32_exec_SUBFIC , 0xfc000000 , 0x20000000, 0 }, |
| 3837 |
{ "subfze" , ppc32_exec_SUBFZE , 0xfc00ffff , 0x7c000190, 0 }, |
| 3838 |
{ "subfze." , ppc32_exec_SUBFZE_dot , 0xfc00ffff , 0x7c000191, 0 }, |
| 3839 |
{ "sync" , ppc32_exec_SYNC , 0xffffffff , 0x7c0004ac, 0 }, |
| 3840 |
{ "tlbia" , ppc32_exec_TLBIA , 0xffffffff , 0x7c0002e4, 0 }, |
| 3841 |
{ "tlbie" , ppc32_exec_TLBIE , 0xffff07ff , 0x7c000264, 0 }, |
| 3842 |
{ "tlbsync" , ppc32_exec_TLBSYNC , 0xffffffff , 0x7c00046c, 0 }, |
| 3843 |
{ "tw" , ppc32_exec_TW , 0xfc0007ff , 0x7c000008, 0 }, |
| 3844 |
{ "twi" , ppc32_exec_TWI , 0xfc000000 , 0x0c000000, 0 }, |
| 3845 |
{ "xor" , ppc32_exec_XOR , 0xfc0007ff , 0x7c000278, 0 }, |
| 3846 |
{ "xor." , ppc32_exec_XOR_dot , 0xfc0007ff , 0x7c000279, 0 }, |
| 3847 |
{ "xori" , ppc32_exec_XORI , 0xfc000000 , 0x68000000, 0 }, |
| 3848 |
{ "xoris" , ppc32_exec_XORIS , 0xfc000000 , 0x6c000000, 0 }, |
| 3849 |
|
| 3850 |
/* PowerPC 405 specific instructions */ |
| 3851 |
{ "dccci" , ppc32_exec_DCCCI , 0xfc0007ff , 0x7c00038c, 0 }, |
| 3852 |
{ "iccci" , ppc32_exec_ICCCI , 0xfc0007ff , 0x7c00078c, 0 }, |
| 3853 |
{ "mfdcr" , ppc32_exec_MFDCR , 0xfc0007ff , 0x7c000286, 0 }, |
| 3854 |
{ "mtdcr" , ppc32_exec_MTDCR , 0xfc0007ff , 0x7c000386, 0 }, |
| 3855 |
{ "tlbre" , ppc32_exec_TLBRE , 0xfc0007ff , 0x7c000764, 0 }, |
| 3856 |
{ "tlbwe" , ppc32_exec_TLBWE , 0xfc0007ff , 0x7c0007a4, 0 }, |
| 3857 |
|
| 3858 |
/* Unknown opcode fallback */ |
| 3859 |
{ "unknown" , ppc32_exec_unknown , 0x00000000 , 0x00000000, 0 }, |
| 3860 |
|
| 3861 |
{ NULL , NULL, 0, 0, 0 }, |
| 3862 |
}; |