OpcodeDispatcher: simplify AAD

noticed in the area.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig 2024-03-25 17:02:45 -04:00
parent 2bf880c43a
commit 86b5a2f352

View File

@ -3286,17 +3286,15 @@ void OpDispatchBuilder::AAMOp(OpcodeArgs) {
void OpDispatchBuilder::AADOp(OpcodeArgs) {
InvalidateDeferredFlags();
auto AL = LoadGPRRegister(X86State::REG_RAX, 1);
auto AH = _Lshr(OpSize::i32Bit, LoadGPRRegister(X86State::REG_RAX, 2), _Constant(8));
auto A = LoadGPRRegister(X86State::REG_RAX);
auto AH = _Lshr(OpSize::i32Bit, A, _Constant(8));
auto Imm8 = _Constant(Op->Src[0].Data.Literal.Value & 0xFF);
auto NewAL = _Add(OpSize::i64Bit, AL, _Mul(OpSize::i64Bit, AH, Imm8));
auto NewAL = _Add(OpSize::i64Bit, A, _Mul(OpSize::i64Bit, AH, Imm8));
auto Result = _And(OpSize::i64Bit, NewAL, _Constant(0xFF));
StoreGPRRegister(X86State::REG_RAX, Result, 2);
// Update Flags
AL = LoadGPRRegister(X86State::REG_RAX, 1);
SetNZ_ZeroCV(1, AL);
CalculatePF(AL);
SetNZ_ZeroCV(1, Result);
CalculatePF(Result);
_InvalidateFlags(1u << X86State::RFLAG_AF_RAW_LOC);
}