From 8892eb08e6aec63219146090382c478c8cea4017 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Sat, 5 Nov 2022 21:52:27 +0530 Subject: [PATCH] Fix `MoveRegister` to clear when value is 0 The register wouldn't be cleared with a `MOVZ` when a value was zero due to the condition for writing an instruction requiring the `offsetValue` to be non-zero. --- app/src/main/cpp/skyline/nce/instructions.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/cpp/skyline/nce/instructions.h b/app/src/main/cpp/skyline/nce/instructions.h index a116fb85..165c0c50 100644 --- a/app/src/main/cpp/skyline/nce/instructions.h +++ b/app/src/main/cpp/skyline/nce/instructions.h @@ -257,13 +257,11 @@ namespace skyline::nce { for (auto &instruction : instructions) { auto offsetValue{*(valuePointer + offset)}; - if (offsetValue) { - if (zeroed) { - instruction = instructions::Movk(destination, offsetValue, offset).raw; - } else { - instruction = instructions::Movz(destination, offsetValue, offset).raw; - zeroed = true; - } + if (!zeroed) { + instruction = instructions::Movz(destination, offsetValue, offset).raw; + zeroed = true; + } else if (offsetValue && zeroed) { + instruction = instructions::Movk(destination, offsetValue, offset).raw; } else { instruction = 0; }