mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-11-23 02:06:55 +01:00
36b9ab0e48
* Remove ARM32 interpreter and add ARM32 support on the translator * Nits. * Rename Cond -> Condition * Align code again * Rename Data to Alu * Enable ARM32 support and handle undefined instructions * Use the IsThumb method to check if its a thumb opcode * Remove another 32-bits check
123 lines
No EOL
3 KiB
C#
123 lines
No EOL
3 KiB
C#
using ChocolArm64.Decoders;
|
|
using ChocolArm64.State;
|
|
using ChocolArm64.Translation;
|
|
using System.Reflection.Emit;
|
|
|
|
using static ChocolArm64.Instructions.InstEmit32Helper;
|
|
using static ChocolArm64.Instructions.InstEmitAluHelper;
|
|
|
|
namespace ChocolArm64.Instructions
|
|
{
|
|
static partial class InstEmit32
|
|
{
|
|
public static void Add(ILEmitterCtx context)
|
|
{
|
|
IOpCodeAlu32 op = (IOpCodeAlu32)context.CurrOp;
|
|
|
|
EmitAluLoadOpers(context, setCarry: false);
|
|
|
|
context.Emit(OpCodes.Add);
|
|
|
|
if (op.SetFlags)
|
|
{
|
|
context.EmitZnFlagCheck();
|
|
|
|
EmitAddsCCheck(context);
|
|
EmitAddsVCheck(context);
|
|
}
|
|
|
|
EmitAluStore(context);
|
|
}
|
|
|
|
public static void Mov(ILEmitterCtx context)
|
|
{
|
|
IOpCodeAlu32 op = (IOpCodeAlu32)context.CurrOp;
|
|
|
|
EmitAluLoadOper2(context);
|
|
|
|
if (op.SetFlags)
|
|
{
|
|
context.EmitZnFlagCheck();
|
|
}
|
|
|
|
EmitAluStore(context);
|
|
}
|
|
|
|
public static void Sub(ILEmitterCtx context)
|
|
{
|
|
IOpCodeAlu32 op = (IOpCodeAlu32)context.CurrOp;
|
|
|
|
EmitAluLoadOpers(context, setCarry: false);
|
|
|
|
context.Emit(OpCodes.Sub);
|
|
|
|
if (op.SetFlags)
|
|
{
|
|
context.EmitZnFlagCheck();
|
|
|
|
EmitSubsCCheck(context);
|
|
EmitSubsVCheck(context);
|
|
}
|
|
|
|
EmitAluStore(context);
|
|
}
|
|
|
|
private static void EmitAluStore(ILEmitterCtx context)
|
|
{
|
|
IOpCodeAlu32 op = (IOpCodeAlu32)context.CurrOp;
|
|
|
|
if (op.Rd == RegisterAlias.Aarch32Pc)
|
|
{
|
|
if (op.SetFlags)
|
|
{
|
|
//TODO: Load SPSR etc.
|
|
|
|
context.EmitLdflg((int)PState.TBit);
|
|
|
|
ILLabel lblThumb = new ILLabel();
|
|
ILLabel lblEnd = new ILLabel();
|
|
|
|
context.Emit(OpCodes.Brtrue_S, lblThumb);
|
|
|
|
context.EmitLdc_I4(~3);
|
|
|
|
context.Emit(OpCodes.Br_S, lblEnd);
|
|
|
|
context.MarkLabel(lblThumb);
|
|
|
|
context.EmitLdc_I4(~1);
|
|
|
|
context.MarkLabel(lblEnd);
|
|
|
|
context.Emit(OpCodes.And);
|
|
context.Emit(OpCodes.Conv_U8);
|
|
context.Emit(OpCodes.Ret);
|
|
}
|
|
else
|
|
{
|
|
EmitAluWritePc(context);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
context.EmitStint(GetRegisterAlias(context.Mode, op.Rd));
|
|
}
|
|
}
|
|
|
|
private static void EmitAluWritePc(ILEmitterCtx context)
|
|
{
|
|
if (IsThumb(context.CurrOp))
|
|
{
|
|
context.EmitLdc_I4(~1);
|
|
|
|
context.Emit(OpCodes.And);
|
|
context.Emit(OpCodes.Conv_U8);
|
|
context.Emit(OpCodes.Ret);
|
|
}
|
|
else
|
|
{
|
|
EmitBxWritePc(context);
|
|
}
|
|
}
|
|
}
|
|
} |