X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2FCyclone%2FMain.cpp;h=3bb129dcf4b5e1dddf9de09760ffb71658d182dc;hb=00bd648e6308fbcfe759a56dc24c11435d358ec4;hp=2f92c5cfd67672e084b9980fc6960730881cceb8;hpb=cc68a136aa179a5f32fe40208371eb9c2b0aadae;p=picodrive.git diff --git a/cpu/Cyclone/Main.cpp b/cpu/Cyclone/Main.cpp index 2f92c5c..3bb129d 100644 --- a/cpu/Cyclone/Main.cpp +++ b/cpu/Cyclone/Main.cpp @@ -86,14 +86,13 @@ static void PrintException(int ints) void CheckInterrupt(int op) { ot(";@ CheckInterrupt:\n"); - ot(" ldr r0,[r7,#0x44]\n"); // same as ldrb r0,[r7,#0x47] - ot(" movs r0,r0,lsr #24 ;@ Get IRQ level (loading word is faster)\n"); + ot(" ldr r1,[r7,#0x44] ;@ Get SR high T_S__III and irq level\n"); + ot(" movs r0,r1,lsr #24 ;@ Get IRQ level\n"); // same as ldrb r0,[r7,#0x47] ot(" beq NoInts%x\n",op); ot(" cmp r0,#6 ;@ irq>6 ?\n"); - ot(" ldrleb r1,[r7,#0x44] ;@ Get SR high: T_S__III\n"); ot(" andle r1,r1,#7 ;@ Get interrupt mask\n"); ot(" cmple r0,r1 ;@ irq<=6: Is irq<=mask ?\n"); - ot(" blgt DoInterrupt\n"); + ot(" blgt CycloneDoInterrupt\n"); ot("NoInts%x%s\n", op,ms?"":":"); ot("\n"); } @@ -109,22 +108,21 @@ static void PrintFramework() ot(" mov r7,r0 ;@ r7 = Pointer to Cpu Context\n"); ot(" ;@ r0-3 = Temporary registers\n"); ot(" ldrb r9,[r7,#0x46] ;@ r9 = Flags (NZCV)\n"); - ot(" ldr r6,=JumpTab ;@ r6 = Opcode Jump table\n"); + ot(" ldr r6,=CycloneJumpTab ;@ r6 = Opcode Jump table\n"); ot(" ldr r5,[r7,#0x5c] ;@ r5 = Cycles\n"); ot(" ldr r4,[r7,#0x40] ;@ r4 = Current PC + Memory Base\n"); ot(" ;@ r8 = Current Opcode\n"); - ot(" ldr r0,[r7,#0x44]\n"); + ot(" ldr r1,[r7,#0x44] ;@ Get SR high T_S__III and irq level\n"); ot(" mov r9,r9,lsl #28 ;@ r9 = Flags 0xf0000000, cpsr format\n"); ot(" ;@ r10 = Source value / Memory Base\n"); ot("\n"); ot(";@ CheckInterrupt:\n"); - ot(" movs r0,r0,lsr #24 ;@ Get IRQ level\n"); // same as ldrb r0,[r7,#0x47] + ot(" movs r0,r1,lsr #24 ;@ Get IRQ level\n"); // same as ldrb r0,[r7,#0x47] ot(" beq NoInts0\n"); ot(" cmp r0,#6 ;@ irq>6 ?\n"); - ot(" ldrleb r1,[r7,#0x44] ;@ Get SR high: T_S__III\n"); ot(" andle r1,r1,#7 ;@ Get interrupt mask\n"); ot(" cmple r0,r1 ;@ irq<=6: Is irq<=mask ?\n"); - ot(" blgt DoInterrupt\n"); + ot(" blgt CycloneDoInterrupt\n"); ot(";@ Check if interrupt used up all the cycles:\n"); ot(" subs r5,r5,#0\n"); ot(" blt CycloneEndNoBack\n"); @@ -143,7 +141,14 @@ static void PrintFramework() ot("CycloneEnd%s\n", ms?"":":"); ot(" sub r4,r4,#2\n"); ot("CycloneEndNoBack%s\n", ms?"":":"); +#ifdef CYCLONE_FOR_PICODRIVE + ot(" ldr r1,[r7,#0x54]\n"); ot(" mov r9,r9,lsr #28\n"); + ot(" tst r1,r1\n"); + ot(" bxne r1 ;@ jump to alternative CycloneEnd\n"); +#else + ot(" mov r9,r9,lsr #28\n"); +#endif ot(" str r4,[r7,#0x40] ;@ Save Current PC + Memory Base\n"); ot(" str r5,[r7,#0x5c] ;@ Save Cycles\n"); ot(" strb r9,[r7,#0x46] ;@ Save Flags (NZCV)\n"); @@ -161,7 +166,7 @@ static void PrintFramework() ot(";@ uncompress jump table\n"); if (ms) ot("CycloneInit\n"); else ot("CycloneInit:\n"); - ot(" ldr r12,=JumpTab\n"); + ot(" ldr r12,=CycloneJumpTab\n"); ot(" add r0,r12,#0xe000*4 ;@ ctrl code pointer\n"); ot(" ldr r1,[r0,#-4]\n"); ot(" tst r1,r1\n"); @@ -187,7 +192,7 @@ static void PrintFramework() ot(" bgt unc_loop_in\n"); ot(" b unc_loop\n"); ot("unc_finish%s\n", ms?"":":"); - ot(" ldr r12,=JumpTab\n"); + ot(" ldr r12,=CycloneJumpTab\n"); ot(" ;@ set a-line and f-line handlers\n"); ot(" add r0,r12,#0xa000*4\n"); ot(" ldr r1,[r0,#4] ;@ a-line handler\n"); @@ -255,7 +260,7 @@ static void PrintFramework() ot("\n"); ot(";@ DoInterrupt - r0=IRQ number\n"); - ot("DoInterrupt%s\n", ms?"":":"); + ot("CycloneDoInterrupt%s\n", ms?"":":"); ot(" stmdb sp!,{lr} ;@ Push ARM return address\n"); ot(";@ Get IRQ Vector address:\n"); @@ -475,7 +480,7 @@ static void PrintJumpTable() // space for decompressed table ot(ms?" area |.data|, data\n":" .data\n .align 4\n\n"); - ot("JumpTab%s\n", ms?"":":"); + ot("CycloneJumpTab%s\n", ms?"":":"); if(ms) { for(i = 0; i < 0xa000/8; i++) ot(" dcd 0,0,0,0,0,0,0,0\n"); @@ -548,7 +553,7 @@ static void PrintJumpTable() ot("\n"); free(indexes); #else - ot("JumpTab%s\n", ms?"":":"); + ot("CycloneJumpTab%s\n", ms?"":":"); len=0xfffe; // Hmmm, armasm 2.50.8684 messes up with a 0x10000 long jump table // notaz: same thing with GNU as 2.9-psion-98r2 (reloc overflow) // this is due to COFF objects using only 2 bytes for reloc count @@ -613,6 +618,10 @@ static int CycloneMake() ot(" .global CycloneSetSr\n"); ot(" .global CycloneGetSr\n"); ot(" .global CycloneVer\n"); +#ifdef CYCLONE_FOR_PICODRIVE + ot(" .global CycloneDoInterrupt\n"); + ot(" .global CycloneJumpTab\n"); +#endif ot("CycloneVer: .long 0x%.4x\n",CycloneVer); } ot("\n"); @@ -623,6 +632,8 @@ static int CycloneMake() if (ms) ot(" END\n"); + ot("\n\n;@ vim:filetype=armasm\n"); + fclose(AsmFile); AsmFile=NULL; #if 0