[a64] Protect address-generation from imm-overflow

This commit is contained in:
Wunkolo 2024-05-09 07:35:54 -07:00
parent c495fe726f
commit 31b2ccd3bb
2 changed files with 5 additions and 3 deletions

View File

@ -78,7 +78,8 @@ XReg ComputeMemoryAddress(A64Emitter& e, const T& guest,
// displacement it would be sign extended and mess things up.
uint32_t address = static_cast<uint32_t>(guest.constant());
if (address < 0x80000000) {
e.ADD(address_register.toX(), e.GetMembaseReg(), address);
e.MOV(W0, address);
e.ADD(address_register.toX(), e.GetMembaseReg(), X0);
return address_register.toX();
} else {
if (address >= 0xE0000000 &&

View File

@ -1187,13 +1187,14 @@ void EmitAddCarryXX(A64Emitter& e, const ARGS& i) {
// TODO(benvanik): faster setting? we could probably do some fun math tricks
// here to get the carry flag set.
if (i.src3.is_constant) {
e.MOV(W0, WZR);
if (i.src3.constant()) {
// Set carry
// This is implicitly "SUBS 0 - 0"
e.CMP(WZR.toW(), 0);
e.CMP(W0, 0);
} else {
// Clear carry
e.CMN(WZR.toW(), 0);
e.CMN(W0, 0);
}
} else {
// If src3 is non-zero, set the carry flag