Fix corner cases of ADCS and SBFM

This commit is contained in:
gdkchan 2018-02-26 15:56:34 -03:00
parent f6dc86c6a0
commit 708761963e
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);