}\r
#endif\r
\r
-static void LoadCycloneJumpTab(int reg, int tmp)\r
-{\r
- ot(" adr r%d,CycloneOT_JT\n", tmp);\r
- ot(" ldr r%d,[r%d] ;@ CycloneJumpTab-CycloneOT_JT\n", reg, tmp);\r
- ot(" add r%d,r%d,r%d ;@ =CycloneJumpTab\n", reg, reg, tmp);\r
-}\r
-\r
#if EMULATE_ADDRESS_ERRORS_JUMP || EMULATE_ADDRESS_ERRORS_IO\r
static void AddressErrorWrapper(char rw, const char *dataprg, int iw)\r
{\r
ot("\n");\r
ot("\n");\r
\r
- ot("CycloneInit%s\n", ms?"":":");\r
+ ot("CycloneInitJT%s\n", ms?"":":");\r
#if COMPRESS_JUMPTABLE\r
ot(";@ decompress jump table\n");\r
- LoadCycloneJumpTab(12, 1);\r
+ ot(" mov r12,r0 ;@ jump table\n");\r
ot(" add r0,r12,#0xe000*4 ;@ ctrl code pointer\n");\r
ot(" ldr r1,[r0,#-4]\n");\r
ot(" tst r1,r1\n");\r
ot(" movne pc,lr ;@ already uncompressed\n");\r
+ ot(" stmfd sp!,{r7,lr}\n");\r
+ ot(" mov r7,r12 ;@ jump table\n");\r
ot(" add r3,r12,#0xa000*4 ;@ handler table pointer, r12=dest\n");\r
ot("unc_loop%s\n", ms?"":":");\r
ot(" ldrh r1,[r0],#2\n");\r
ot(" bgt unc_loop_in\n");\r
ot(" b unc_loop\n");\r
ot("unc_finish%s\n", ms?"":":");\r
- LoadCycloneJumpTab(12, 1);\r
ot(" ;@ set a-line and f-line handlers\n");\r
- ot(" add r0,r12,#0xa000*4\n");\r
+ ot(" add r0,r7,#0xa000*4\n");\r
ot(" ldr r1,[r0,#4] ;@ a-line handler\n");\r
ot(" ldr r3,[r0,#8] ;@ f-line handler\n");\r
ot(" mov r2,#0x1000\n");\r
ot(" subs r2,r2,#1\n");\r
ot(" str r1,[r0],#4\n");\r
ot(" bgt unc_fill3\n");\r
- ot(" add r0,r12,#0xf000*4\n");\r
+ ot(" add r0,r7,#0xf000*4\n");\r
ot(" mov r2,#0x1000\n");\r
ot("unc_fill4%s\n", ms?"":":");\r
ot(" subs r2,r2,#1\n");\r
ot(" str r3,[r0],#4\n");\r
ot(" bgt unc_fill4\n");\r
- ot(" bx lr\n");\r
+ ot(" ldmfd sp!,{r7,pc}\n");\r
ltorg();\r
#else\r
ot(";@ fix final jumptable entries\n");\r
- LoadCycloneJumpTab(12, 0);\r
- ot(" add r12,r12,#0x10000*4\n");\r
- ot(" ldr r0,[r12,#-3*4]\n");\r
- ot(" str r0,[r12,#-2*4]\n");\r
- ot(" str r0,[r12,#-1*4]\n");\r
+ ot(" add r0,r0,#0x10000*4\n");\r
+ ot(" ldr r1,[r0,#-3*4]\n");\r
+ ot(" str r1,[r0,#-2*4]\n");\r
+ ot(" str r1,[r0,#-1*4]\n");\r
ot(" bx lr\n");\r
#endif\r
ot("\n");\r
\r
// --------------\r
- ot("CycloneReset%s\n", ms?"":":");\r
+ ot("CycloneResetJT%s\n", ms?"":":");\r
ot(" stmfd sp!,{r7,lr}\n");\r
- LoadCycloneJumpTab(12, 1);\r
ot(" mov r7,r0\n");\r
- ot(" str r12,[r7,#0x54] ;@ save CycloneJumpTab avoid literal pools\n");\r
+ ot(" str r1,[r7,#0x54] ;@ save CycloneJumpTab avoid literal pools\n");\r
ot(" mov r0,#0\n");\r
ot(" str r0,[r7,#0x58] ;@ state_flags\n");\r
ot(" str r0,[r7,#0x48] ;@ OSP\n");\r
ot("\n");\r
\r
// --------------\r
- ot("CycloneSetRealTAS%s\n", ms?"":":");\r
+ ot("CycloneSetRealTAS_JT%s\n", ms?"":":");\r
#if (CYCLONE_FOR_GENESIS == 2)\r
- LoadCycloneJumpTab(12, 1);\r
ot(" tst r0,r0\n");\r
- ot(" add r12,r12,#0x4a00*4\n");\r
+ ot(" add r12,r1,#0x4a00*4\n");\r
ot(" add r12,r12,#0x00d0*4\n");\r
ot(" adr r2,CycloneOT_TAS_\n");\r
ot(" addeq r2,r2,#%lu*4\n", sizeof(tas_ops) / sizeof(tas_ops[0]));\r
\r
// --------------\r
// offset table to avoid .text relocations (forbidden by Android and iOS)\r
- ot("CycloneOT_JT%s\n", ms?"":":");\r
- ot(" %s %s-CycloneOT_JT\n", ms?"dcd":".long", "CycloneJumpTab");\r
#if (CYCLONE_FOR_GENESIS == 2)\r
ot("CycloneOT_TAS_%s\n", ms?"":":"); // working TAS (no MD bug)\r
for (size_t i = 0; i < sizeof(tas_ops) / sizeof(tas_ops[0]); i++)\r
for(i=0xf000; i<0x10000; i++) CyJump[i] = -3; // f-line emulation\r
\r
ot(ms?" area |.text|, code\n":" .text\n .align 4\n\n");\r
- ot(" %s CycloneInit\n",globl);\r
- ot(" %s CycloneReset\n",globl);\r
+ ot(" %s CycloneInitJT\n",globl);\r
+ ot(" %s CycloneResetJT\n",globl);\r
ot(" %s CycloneRun\n",globl);\r
ot(" %s CycloneSetSr\n",globl);\r
ot(" %s CycloneGetSr\n",globl);\r
ot(" %s CycloneUnpack\n",globl);\r
ot(" %s CycloneVer\n",globl);\r
#if (CYCLONE_FOR_GENESIS == 2)\r
- ot(" %s CycloneSetRealTAS\n",globl);\r
+ ot(" %s CycloneSetRealTAS_JT\n",globl);\r
ot(" %s CycloneDoInterrupt\n",globl);\r
ot(" %s CycloneDoTrace\n",globl);\r
ot(" %s CycloneJumpTab\n",globl);\r
.data
.align 2
+idle_data:
have_patches:
.word 0
+ .word Op____
+ .word Op6002
+ .word Op6602
+ .word Op6702
.equ patch_desc_table_size, 10
+@ to from
patch_desc_table:
.word (0x71fa<<16) | 0x66fa, idle_detector_bcc8, idle_bne, Op6602 @ bne.s
.word (0x71f8<<16) | 0x66f8, idle_detector_bcc8, idle_bne, Op6602 @ bne.s
.align 2
-.global CycloneInitIdle
+.global CycloneInitIdleJT @ jt
-CycloneInitIdle:
+CycloneInitIdleJT:
adr r12,offset_table
- ldr r3, [r12, #2*4] @ =CycloneJumpTab-ot
ldr r2, [r12, #1*4] @ =patch_desc_table-ot
- add r3, r3, r12
+ mov r3, r0 @ =CycloneJumpTab
add r2, r2, r12
mov r12,#patch_desc_table_size
bgt cii_loop
adr r12,offset_table
- ldr r0, [r12, #0*4] @ =have_patches-ot
+ ldr r0, [r12, #0*4] @ =idle_data-ot
mov r1, #1
- str r1, [r0, r12]
+ str r1, [r0, r12] @ have_patches
bx lr
-.global CycloneFinishIdle
+.global CycloneFinishIdleJT @ jt
-CycloneFinishIdle:
+CycloneFinishIdleJT:
adr r12,offset_table
- ldr r3, [r12, #0*4] @ =have_patches-ot
- ldr r0, [r3, r12]!
- tst r0, r0
+ ldr r3, [r12, #0*4] @ =idle_data-ot
+ ldr r1, [r3, r12]! @ have_patches
+ tst r1, r1
bxeq lr
stmfd sp!, {r4,r5}
mov r5, r3
ldr r2, [r12, #1*4] @ =patch_desc_table-ot
- ldr r3, [r12, #2*4] @ =CycloneJumpTab-ot
- ldr r4, [r12, #3*4] @ =Op____-ot
- add r2, r2, r12
- add r3, r3, r12
- add r4, r4, r12
+ mov r3, r0 @ =CycloneJumpTab
+ ldr r4, [r5, #1*4] @ =Op____
+ add r2, r2, r12 @ =patch_desc_table
mov r12,#patch_desc_table_size
cfi_loop:
@ remove detector from Cyclone
adr r12,offset_table
+ ldr r1, [r12] @ =idle_data-ot
mov r0, r8, lsr #8
cmp r0, #0x66
- ldrlt r1, [r12, #4*4] @ =Op6002-ot
- ldreq r1, [r12, #4*5] @ =Op6602-ot
- ldrgt r1, [r12, #4*6] @ =Op6702-ot
- add r1, r1, r12
+ add r1, r1, r12 @ =idle_data
+ ldrlt r1, [r1, #4*2] @ =Op6002-ot
+ ldreq r1, [r1, #4*3] @ =Op6602-ot
+ ldrgt r1, [r1, #4*4] @ =Op6702-ot
str r1, [r6, r8, lsl #2]
bx r1
b Op6702
offset_table:
- .word have_patches - offset_table
+ .word idle_data - offset_table
.word patch_desc_table - offset_table
- .word CycloneJumpTab - offset_table
- .word Op____ - offset_table
- .word Op6002 - offset_table
- .word Op6602 - offset_table @ 5
- .word Op6702 - offset_table