X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2FCyclone%2FMain.cpp;h=5647fb1d3accc1a6e756856f1bef87983a46aa97;hb=2270612aa7ee7d04549e95c2ab4d72f6aa67fa8d;hp=80bbfd8e5671dad414281da639c8171d03484bbb;hpb=cfb3dfa0f2a36569a6b090e87568b1a1c423f75c;p=picodrive.git diff --git a/cpu/Cyclone/Main.cpp b/cpu/Cyclone/Main.cpp index 80bbfd8..5647fb1 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); @@ -98,9 +102,10 @@ static void PrintException(int ints) ot("no_sp_swap%i%s\n",ints,ms?"":":"); ot(" ldr r10,[r7,#0x60] ;@ Get Memory base\n"); - ot(" mov r1,r4,lsl #8\n"); - ot(" sub r1,r1,r10,lsl #8 ;@ r1 = Old PC\n"); - ot(" mov r1,r1,asr #8 ;@ push sign extended\n"); +// ot(" mov r1,r4,lsl #8\n"); +// ot(" sub r1,r1,r10,lsl #8 ;@ r1 = Old PC\n"); +// ot(" mov r1,r1,asr #8 ;@ push sign extended\n"); + ot(" sub r1,r4,r10 ;@ r1 = Old PC\n"); OpPush32(); OpPushSr(1); ot(" mov r0,r11\n"); @@ -273,6 +278,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 +293,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 +312,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 +420,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 +451,7 @@ int MemHandler(int type,int size,int addrreg) static void PrintOpcodes() { int op=0; - + printf("Creating Opcodes: ["); ot(";@ ---------------------------- Opcodes ---------------------------\n"); @@ -469,6 +479,7 @@ static void PrintOpcodes() ot(" mov r0,#0x10\n"); ot(" bl Exception\n"); #endif + ot("\n"); Cycles=34; OpEnd(); @@ -495,6 +506,7 @@ static void PrintOpcodes() ot(" mov r0,#0x28\n"); ot(" bl Exception\n"); #endif + ot("\n"); Cycles=4; OpEnd(); @@ -520,6 +532,7 @@ static void PrintOpcodes() ot(" mov r0,#0x2c\n"); ot(" bl Exception\n"); #endif + ot("\n"); Cycles=4; OpEnd(); @@ -622,12 +635,11 @@ static void PrintJumpTable() } if(ip&1) ott("0x%.4x", 0, "\n",0,ip++,1); if(ip&7) fseek(AsmFile, -1, SEEK_CUR); // remove last comma - ot("\n"); if(ip&7) { for(i = 8-(ip&7); i > 0; i--) ot(",0x0000"); - ot("\n"); } + ot("\n"); if(ms) { for(i = (0x2000-ip/2)/8+1; i > 0; i--) ot(" dcd 0,0,0,0,0,0,0,0\n"); @@ -675,7 +687,7 @@ static int CycloneMake() ot("\n;@ Dave's Cyclone 68000 Emulator v%x.%.3x - Assembler Output\n\n",CycloneVer>>12,CycloneVer&0xfff); ot(";@ (c) Copyright 2003 Dave, All rights reserved.\n"); - ot(";@ some code (c) Copyright 2005-2006 notaz, All rights reserved.\n"); + ot(";@ some code (c) Copyright 2005-2007 notaz, All rights reserved.\n"); ot(";@ Cyclone 68000 is free for non-commercial use.\n\n"); ot(";@ For commercial use, separate licencing terms must be obtained.\n\n"); @@ -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");