X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2FCyclone%2FMain.cpp;h=96de268c12c3d027b9ed0f58c50c9fff2abbc882;hb=85a36a57a816ac643ee5f982d774532a0ca4d58b;hp=80bbfd8e5671dad414281da639c8171d03484bbb;hpb=cfb3dfa0f2a36569a6b090e87568b1a1c423f75c;p=picodrive.git diff --git a/cpu/Cyclone/Main.cpp b/cpu/Cyclone/Main.cpp index 80bbfd8..96de268 100644 --- a/cpu/Cyclone/Main.cpp +++ b/cpu/Cyclone/Main.cpp @@ -10,6 +10,7 @@ char *Narm[4]={ "b", "h","",""}; // Normal ARM Extensions for operand sizes 0,1, char *Sarm[4]={"sb","sh","",""}; // Sign-extend ARM Extensions for operand sizes 0,1,2 int Cycles; // Current cycles for opcode int pc_dirty; // something changed PC during processing +static int arm_op_count; void ot(const char *format, ...) @@ -22,6 +23,9 @@ void ot(const char *format, ...) for(i=0, len=strlen(format); i < len && format[i] != '\n'; i++); if(i < len-1 && format[len-1] != '\n') printf("\nWARNING: possible improper newline placement:\n%s\n", format); + if (format[0] == ' ' && format[1] == ' ' && format[2] != ' ' && format[2] != '.') + arm_op_count++; + va_start(valist,format); if (AsmFile) vfprintf(AsmFile,format,valist); va_end(valist); @@ -273,6 +277,7 @@ static void PrintFramework() ot(" bx lr\n"); ot("\n"); #endif + // 68k: XNZVC, ARM: NZCV if (ms) ot("CycloneSetSr\n"); else ot("CycloneSetSr:\n"); ot(" mov r2,r1,lsr #8\n"); @@ -287,8 +292,8 @@ static void PrintFramework() ot(" str r3,[r0,#0x3C]\n"); ot(" str r2,[r0,#0x48]\n"); ot("setsr_noswap%s\n",ms?"":":"); - ot(" mov r2,r1,lsr #3\n"); - ot(" strb r2,[r0,#0x45] ;@ the X flag\n"); + ot(" mov r2,r1,lsl #25\n"); + ot(" str r2,[r0,#0x4c] ;@ the X flag\n"); ot(" bic r2,r1,#0xf3\n"); ot(" tst r1,#1\n"); ot(" orrne r2,r2,#2\n"); @@ -306,8 +311,8 @@ static void PrintFramework() ot(" orrne r2,r2,#2\n"); ot(" tst r1,#2\n"); ot(" orrne r2,r2,#1\n"); - ot(" ldrb r1,[r0,#0x45] ;@ the X flag\n"); - ot(" tst r1,#2\n"); + ot(" ldr r1,[r0,#0x4c] ;@ the X flag\n"); + ot(" tst r1,#0x20000000\n"); ot(" orrne r2,r2,#0x10\n"); ot(" ldrb r1,[r0,#0x44] ;@ the SR high\n"); ot(" orr r0,r2,r1,lsl #8\n"); @@ -414,8 +419,12 @@ int MemHandler(int type,int size,int addrreg) addrreg=0; #endif if (addrreg != 0) + { + ot(" add lr,pc,#4\n"); // helps to prevent interlocks ot(" mov r0,r%i\n", addrreg); - ot(" mov lr,pc\n"); + } + else + ot(" mov lr,pc\n"); ot(" ldr pc,[r7,#0x%x] ;@ Call ",func); // Document what we are calling: @@ -441,7 +450,7 @@ int MemHandler(int type,int size,int addrreg) static void PrintOpcodes() { int op=0; - + printf("Creating Opcodes: ["); ot(";@ ---------------------------- Opcodes ---------------------------\n"); @@ -469,6 +478,7 @@ static void PrintOpcodes() ot(" mov r0,#0x10\n"); ot(" bl Exception\n"); #endif + ot("\n"); Cycles=34; OpEnd(); @@ -495,6 +505,7 @@ static void PrintOpcodes() ot(" mov r0,#0x28\n"); ot(" bl Exception\n"); #endif + ot("\n"); Cycles=4; OpEnd(); @@ -520,6 +531,7 @@ static void PrintOpcodes() ot(" mov r0,#0x2c\n"); ot(" bl Exception\n"); #endif + ot("\n"); Cycles=4; OpEnd(); @@ -713,7 +725,9 @@ static int CycloneMake() ot("\n"); PrintFramework(); + arm_op_count = 0; PrintOpcodes(); + printf("~%i ARM instructions used for opcode handlers\n", arm_op_count); PrintJumpTable(); if (ms) ot(" END\n");