#endif\r
ot("\n");\r
\r
+ // --------------\r
+ ot("CycloneReset%s\n", ms?"":":");\r
+ ot(" stmfd sp!,{r7,lr}\n");\r
+ ot(" mov r7,r0\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(" mov r1,#0x27 ;@ Supervisor mode\n");\r
+ ot(" strb r1,[r7,#0x44] ;@ set SR high\n");\r
+ ot(" strb r0,[r7,#0x47] ;@ IRQ\n");\r
+ MemHandler(0,2);\r
+ ot(" str r0,[r7,#0x3c] ;@ Stack pointer\n");\r
+ ot(" mov r0,#0\n");\r
+ ot(" str r0,[r7,#0x60] ;@ Membase\n");\r
+ ot(" mov r0,#4\n");\r
+ MemHandler(0,2);\r
+#ifdef MEMHANDLERS_DIRECT_PREFIX\r
+ ot(" bl %scheckpc ;@ Call checkpc()\n", MEMHANDLERS_DIRECT_PREFIX);\r
+#else\r
+ ot(" mov lr,pc\n");\r
+ ot(" ldr pc,[r7,#0x64] ;@ Call checkpc()\n");\r
+#endif\r
+ ot(" str r0,[r7,#0x40] ;@ PC + base\n");\r
+ ot(" ldmfd sp!,{r7,pc}\n");\r
+ ot("\n");\r
+\r
// --------------\r
// 68k: XNZVC, ARM: NZCV\r
ot("CycloneSetSr%s\n", ms?"":":");\r
\r
// --------------\r
ot("CycloneUnpack%s\n", ms?"":":");\r
- ot(" stmfd sp!,{r4,r5,lr}\n");\r
- ot(" mov r4,r0\n");\r
- ot(" mov r5,r1\n");\r
+ ot(" stmfd sp!,{r5,r7,lr}\n");\r
+ ot(" mov r7,r0\n");\r
+ ot(" movs r5,r1\n");\r
+ ot(" beq c_unpack_do_pc\n");\r
ot(" mov r3,#16\n");\r
ot(";@ 0x00-0x3f: DA registers\n");\r
ot("c_unpack_loop%s\n",ms?"":":");\r
ot(" bne c_unpack_loop\n");\r
ot(";@ 0x40: PC\n");\r
ot(" ldr r0,[r5],#4 ;@ PC\n");\r
-#if USE_CHECKPC_CALLBACK\r
- ot(" mov r1,#0\n");\r
- ot(" str r1,[r4,#0x60] ;@ Memory base\n");\r
- ot(" mov lr,pc\n");\r
- ot(" ldr pc,[r4,#0x64] ;@ Call checkpc()\n");\r
-#else\r
- ot(" ldr r1,[r4,#0x60] ;@ Memory base\n");\r
- ot(" add r0,r0,r1 ;@ r0 = Memory Base + New PC\n");\r
-#endif\r
- ot(" str r0,[r4,#0x40] ;@ PC + Memory Base\n");\r
+ ot(" str r0,[r7,#0x40] ;@ handle later\n");\r
ot(";@ 0x44: SR\n");\r
ot(" ldrh r1,[r5],#2\n");\r
- ot(" mov r0,r4\n");\r
+ ot(" mov r0,r7\n");\r
ot(" bl CycloneSetSr\n");\r
ot(";@ 0x46: IRQ level\n");\r
ot(" ldrb r0,[r5],#2\n");\r
- ot(" strb r0,[r4,#0x47]\n");\r
+ ot(" strb r0,[r7,#0x47]\n");\r
ot(";@ 0x48: other SP\n");\r
ot(" ldr r0,[r5],#4\n");\r
- ot(" str r0,[r4,#0x48]\n");\r
+ ot(" str r0,[r7,#0x48]\n");\r
ot(";@ 0x4c: CPU state flags\n");\r
ot(" ldr r0,[r5],#4\n");\r
- ot(" str r0,[r4,#0x58]\n");\r
- ot(" ldmfd sp!,{r4,r5,pc}\n");\r
+ ot(" str r0,[r7,#0x58]\n");\r
+ ot("c_unpack_do_pc%s\n",ms?"":":");\r
+ ot(" ldr r0,[r7,#0x40] ;@ unbased PC\n");\r
+#if USE_CHECKPC_CALLBACK\r
+ ot(" mov r1,#0\n");\r
+ ot(" str r1,[r7,#0x60] ;@ Memory base\n");\r
+ #ifdef MEMHANDLERS_DIRECT_PREFIX\r
+ ot(" bl %scheckpc ;@ Call checkpc()\n", MEMHANDLERS_DIRECT_PREFIX);\r
+ #else\r
+ ot(" mov lr,pc\n");\r
+ ot(" ldr pc,[r7,#0x64] ;@ Call checkpc()\n");\r
+ #endif\r
+#else\r
+ ot(" ldr r1,[r7,#0x60] ;@ Memory base\n");\r
+ ot(" add r0,r0,r1 ;@ r0 = Memory Base + New PC\n");\r
+#endif\r
+ ot(" str r0,[r7,#0x40] ;@ PC + Memory Base\n");\r
+ ot(" ldmfd sp!,{r5,r7,pc}\n");\r
ot("\n");\r
\r
// --------------\r
MemHandler(0,2,0,0);\r
ot(" tst r0,r0 ;@ uninitialized int vector?\n");\r
ot(" moveq r0,#0x3c\n");\r
+ #ifdef MEMHANDLERS_DIRECT_PREFIX\r
+ ot(" bleq %sread32 ;@ Call read32(r0) handler\n", MEMHANDLERS_DIRECT_PREFIX);\r
+ #else\r
ot(" moveq lr,pc\n");\r
ot(" ldreq pc,[r7,#0x70] ;@ Call read32(r0) handler\n");\r
+ #endif\r
#if USE_CHECKPC_CALLBACK\r
ot(" add lr,pc,#4\n");\r
ot(" add r0,r0,r11 ;@ r0 = Memory Base + New PC\n");\r
+ #ifdef MEMHANDLERS_DIRECT_PREFIX\r
+ ot(" bl %scheckpc ;@ Call checkpc()\n", MEMHANDLERS_DIRECT_PREFIX);\r
+ #else\r
ot(" ldr pc,[r7,#0x64] ;@ Call checkpc()\n");\r
+ #endif\r
#if EMULATE_ADDRESS_ERRORS_JUMP\r
ot(" mov r4,r0\n");\r
#else\r
#if USE_CHECKPC_CALLBACK\r
ot(" add lr,pc,#4\n");\r
ot(" add r0,r0,r3 ;@ r0 = Memory Base + New PC\n");\r
+ #ifdef MEMHANDLERS_DIRECT_PREFIX\r
+ ot(" bl %scheckpc ;@ Call checkpc()\n", MEMHANDLERS_DIRECT_PREFIX);\r
+ #else\r
ot(" ldr pc,[r7,#0x64] ;@ Call checkpc()\n");\r
+ #endif\r
#if EMULATE_ADDRESS_ERRORS_JUMP\r
ot(" mov r4,r0\n");\r
#else\r
#if USE_CHECKPC_CALLBACK\r
ot(" add lr,pc,#4\n");\r
ot(" add r0,r0,r3 ;@ r0 = Memory Base + New PC\n");\r
+ #ifdef MEMHANDLERS_DIRECT_PREFIX\r
+ ot(" bl %scheckpc ;@ Call checkpc()\n", MEMHANDLERS_DIRECT_PREFIX);\r
+ #else\r
ot(" ldr pc,[r7,#0x64] ;@ Call checkpc()\n");\r
+ #endif\r
ot(" mov r4,r0\n");\r
#else\r
ot(" add r4,r0,r3 ;@ r4 = Memory Base + New PC\n");\r
// Trashes r0-r3,r12,lr\r
int MemHandler(int type,int size,int addrreg,int need_addrerr_check)\r
{\r
- int func=0;\r
- func=0x68+type*0xc+(size<<2); // Find correct offset\r
+ int func=0x68+type*0xc+(size<<2); // Find correct offset\r
+ char what[32];\r
\r
#if MEMHANDLERS_NEED_FLAGS\r
ot(" mov r3,r10,lsr #28\n");\r
}\r
else\r
#endif\r
+\r
+ sprintf(what, "%s%d", type==0 ? "read" : (type==1 ? "write" : "fetch"), 8<<size);\r
+#ifdef MEMHANDLERS_DIRECT_PREFIX\r
+ if (addrreg != 0)\r
+ ot(" mov r0,r%i\n", addrreg);\r
+ ot(" bl %s%s ;@ Call ", MEMHANDLERS_DIRECT_PREFIX, what);\r
+ (void)func; // avoid warning\r
+#else\r
if (addrreg != 0)\r
{\r
ot(" add lr,pc,#4\n");\r
else\r
ot(" mov lr,pc\n");\r
ot(" ldr pc,[r7,#0x%x] ;@ Call ",func);\r
+#endif\r
\r
// Document what we are calling:\r
- if (type==0) ot("read");\r
- if (type==1) ot("write");\r
- if (type==2) ot("fetch");\r
-\r
- if (type==1) ot("%d(r0,r1)",8<<size);\r
- else ot("%d(r0)", 8<<size);\r
+ if (type==1) ot("%s(r0,r1)",what);\r
+ else ot("%s(r0)", what);\r
ot(" handler\n");\r
\r
#if MEMHANDLERS_CHANGE_FLAGS\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 CycloneRun\n",globl);\r
ot(" %s CycloneSetSr\n",globl);\r
ot(" %s CycloneGetSr\n",globl);\r