Fix corner cases of ADCS and SBFM

This commit is contained in:
gdkchan 2018-02-26 15:56:34 -03:00
parent 0371553a27
commit 1cb0bbe585
3 changed files with 26 additions and 10 deletions

View file

@ -39,7 +39,7 @@ namespace ChocolArm64.Instruction
{ {
Context.EmitZNFlagCheck(); Context.EmitZNFlagCheck();
EmitAddsCCheck(Context); EmitAdcsCCheck(Context);
EmitAddsVCheck(Context); EmitAddsVCheck(Context);
} }

View file

@ -7,6 +7,31 @@ namespace ChocolArm64.Instruction
{ {
static class AInstEmitAluHelper static class AInstEmitAluHelper
{ {
public static void EmitAdcsCCheck(AILEmitterCtx Context)
{
//C = (Rd == Rn && CIn) || Rd < Rn
Context.EmitSttmp();
Context.EmitLdtmp();
Context.EmitLdtmp();
EmitDataLoadRn(Context);
Context.Emit(OpCodes.Ceq);
Context.EmitLdflg((int)APState.CBit);
Context.Emit(OpCodes.And);
Context.EmitLdtmp();
EmitDataLoadRn(Context);
Context.Emit(OpCodes.Clt_Un);
Context.Emit(OpCodes.Or);
Context.EmitStflg((int)APState.CBit);
}
public static void EmitAddsCCheck(AILEmitterCtx Context) public static void EmitAddsCCheck(AILEmitterCtx Context)
{ {
//C = Rd < Rn //C = Rd < Rn

View file

@ -54,15 +54,6 @@ namespace ChocolArm64.Instruction
{ {
EmitSbfmCast(Context, OpCodes.Conv_I4); EmitSbfmCast(Context, OpCodes.Conv_I4);
} }
else if (Op.Shift == 0)
{
Context.EmitLdintzr(Op.Rn);
Context.EmitLsl(BitsCount - 1 - Op.Pos);
Context.EmitAsr(BitsCount - 1);
Context.EmitStintzr(Op.Rd);
}
else else
{ {
EmitBfmLoadRn(Context); EmitBfmLoadRn(Context);