From 3504ce942735ae4283cd47ca6defaae87b550c57 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 9 Sep 2013 02:55:17 +0300 Subject: [PATCH] avoid using mrs it's even worse on newer ARMs only partially converted.. --- Ea.cpp | 45 +++++++++++++++++++++++++++++++-------------- OpAny.cpp | 6 ++++++ OpArith.cpp | 51 ++++++++++++++++++++++++--------------------------- OpLogic.cpp | 33 ++++++++++++++------------------- OpMove.cpp | 7 +++---- app.h | 5 +++-- 6 files changed, 81 insertions(+), 66 deletions(-) diff --git a/Ea.cpp b/Ea.cpp index 234d469..a67f675 100644 --- a/Ea.cpp +++ b/Ea.cpp @@ -305,11 +305,15 @@ int EaCalc(int a,int mask,int ea,int size,int top,int sign_extend) // If top is 0 and sign_extend is not, then ARM register v is sign extended, // e.g. 0xc000 -> 0xffffc000 (else it may or may not be sign extended) -int EaRead(int a,int v,int ea,int size,int mask,int top,int sign_extend) +int EaRead(int a,int v,int ea,int size,int mask,int top,int sign_extend,int set_nz) { char text[32]=""; + const char *s=""; + int flags_set=0; int shift=0; + if (set_nz) s="s"; + shift=32-(8<=8) Cycles+=10; EaCalc (11,0x003f,ea,0,1); - EaRead (11, 1,ea,0,0x003f,1); + EaRead (11, 1,ea,0,0x003f,1,0,1); - ot(" adds r1,r1,#0 ;@ Defines NZ, clears CV\n"); - OpGetFlags(0,0); + OpGetFlagsNZ(1); ot("\n"); #if CYCLONE_FOR_GENESIS diff --git a/OpMove.cpp b/OpMove.cpp index 1e24566..82c589c 100644 --- a/OpMove.cpp +++ b/OpMove.cpp @@ -133,9 +133,8 @@ int OpMove(int op) if (movea==0) { - EaCalcRead(-1,0,sea,size,0x003f); - ot(" adds r1,r0,#0 ;@ Defines NZ, clears CV\n"); - ot(" mrs r10,cpsr ;@ r10=NZCV flags\n"); + EaCalcRead(-1,1,sea,size,0x003f,1,1); + OpGetFlagsNZ(1); ot("\n"); } else @@ -530,7 +529,7 @@ int OpMoveq(int op) ot(" movs r0,r8,asl #24\n"); ot(" and r1,r8,#0x0e00\n"); ot(" mov r0,r0,asr #24 ;@ Sign extended Quick value\n"); - ot(" mrs r10,cpsr ;@ r10=NZ flags\n"); + OpGetFlagsNZ(0); ot(" str r0,[r7,r1,lsr #7] ;@ Store into Dn\n"); ot("\n"); diff --git a/app.h b/app.h index 4a23630..f041dff 100644 --- a/app.h +++ b/app.h @@ -33,8 +33,8 @@ extern int g_pea_cycle_table[]; extern int g_movem_cycle_table[]; int Ea_add_ns(int *tab, int ea); // add nonstandard EA cycles int EaCalc(int a,int mask,int ea,int size,int top=0,int sign_extend=1); // 6 -int EaRead(int a,int v,int ea,int size,int mask,int top=0,int sign_extend=1); // 7 -int EaCalcRead(int r_ea,int r,int ea,int size,int mask,int sign_extend=1); // 6 +int EaRead(int a,int v,int ea,int size,int mask,int top=0,int sign_extend=1,int set_nz=0); // 8 +int EaCalcRead(int r_ea,int r,int ea,int size,int mask,int sign_extend=1,int set_nz=0); // 7 int EaCalcReadNoSE(int r_ea,int r,int ea,int size,int mask); int EaCanRead(int ea,int size); int EaWrite(int a,int v,int ea,int size,int mask,int top=0,int sign_extend_ea=1); @@ -58,6 +58,7 @@ void FlushPC(void); extern int g_op; extern int opend_op_changes_cycles, opend_check_interrupt, opend_check_trace; int OpGetFlags(int subtract,int xbit,int sprecialz=0); +void OpGetFlagsNZ(int rd); void OpUse(int op,int use); void OpStart(int op,int sea=0,int tea=0,int op_changes_cycles=0,int supervisor_check=0); void OpEnd(int sea=0,int tea=0); -- 2.39.5