From 212ff2be4e050398f9f25c9cc32d5b2f13679add Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Sat, 22 May 2021 21:52:40 +0000 Subject: [PATCH] Improved disassembled output when setting register values. --- bemani/format/afp/decompile.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bemani/format/afp/decompile.py b/bemani/format/afp/decompile.py index 7569660..5cb510b 100644 --- a/bemani/format/afp/decompile.py +++ b/bemani/format/afp/decompile.py @@ -2483,7 +2483,13 @@ class ByteCodeDecompiler(VerboseOutput): # multiple statements. set_value = stack.pop() if action.preserve_stack: - stack.append(set_value) + # If we are only initializing one register, put the register back + # on the stack instead of the value, to make decompiled output + # better. This helps a lot when we initialize to a function call return. + if len(action.registers) == 1: + stack.append(action.registers[0]) + else: + stack.append(set_value) store_actions: List[StoreRegisterStatement] = []