330 |
|
uint32 saved_ctr= ctr(); |
331 |
|
|
332 |
|
// Create MacOS stack frame |
333 |
+ |
// FIXME: make sure MacOS doesn't expect PPC registers to live on top |
334 |
|
uint32 sp = gpr(1); |
335 |
< |
gpr(1) -= 56 + 19*4 + 18*8; |
335 |
> |
gpr(1) -= 56; |
336 |
|
WriteMacInt32(gpr(1), sp); |
337 |
|
|
338 |
|
// Save PowerPC registers |
339 |
< |
for (int i = 13; i < 32; i++) |
340 |
< |
WriteMacInt32(gpr(1) + 56 + i*4, gpr(i)); |
339 |
> |
uint32 saved_GPRs[19]; |
340 |
> |
memcpy(&saved_GPRs[0], &gpr(13), sizeof(uint32)*(32-13)); |
341 |
|
#if SAVE_FP_EXEC_68K |
342 |
< |
memcpy(Mac2HostAddr(gpr(1)+56+19*4), &fpr(14), sizeof(double)*(32-14)); |
342 |
> |
double saved_FPRs[18]; |
343 |
> |
memcpy(&saved_FPRs[0], &fpr(14), sizeof(double)*(32-14)); |
344 |
|
#endif |
345 |
|
|
346 |
|
// Setup registers for 68k emulator |
387 |
|
r->a[i] = gpr(16 + i); |
388 |
|
|
389 |
|
// Restore PowerPC registers |
390 |
< |
for (int i = 13; i < 32; i++) |
389 |
< |
gpr(i) = ReadMacInt32(gpr(1) + 56 + i*4); |
390 |
> |
memcpy(&gpr(13), &saved_GPRs[0], sizeof(uint32)*(32-13)); |
391 |
|
#if SAVE_FP_EXEC_68K |
392 |
< |
memcpy(&fpr(14), Mac2HostAddr(gpr(1)+56+19*4), sizeof(double)*(32-14)); |
392 |
> |
memcpy(&fpr(14), &saved_FPRs[0], sizeof(double)*(32-14)); |
393 |
|
#endif |
394 |
|
|
395 |
|
// Cleanup stack |
396 |
< |
gpr(1) += 56 + 19*4 + 18*8; |
396 |
> |
gpr(1) += 56; |
397 |
|
|
398 |
|
// Restore program counters and branch registers |
399 |
|
pc() = saved_pc; |
450 |
|
{ |
451 |
|
// Save branch registers |
452 |
|
uint32 saved_lr = lr(); |
452 |
– |
uint32 saved_ctr= ctr(); |
453 |
|
|
454 |
|
const uint32 trampoline[] = { htonl(POWERPC_EMUL_OP | 1) }; |
455 |
– |
|
455 |
|
lr() = (uint32)trampoline; |
456 |
< |
ctr()= entry; |
456 |
> |
|
457 |
|
execute(entry); |
458 |
|
|
459 |
|
// Restore branch registers |
460 |
|
lr() = saved_lr; |
462 |
– |
ctr()= saved_ctr; |
461 |
|
} |
462 |
|
|
463 |
|
// Resource Manager thunk |