[a64] Protect address-generation from imm-overflow
This commit is contained in:
parent
c495fe726f
commit
31b2ccd3bb
|
@ -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 &&
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue