diff options
| author | Damien George <damien@micropython.org> | 2020-09-04 16:12:09 +1000 | 
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2020-09-09 00:11:51 +1000 | 
| commit | 4f2fe346239b6b3f720708021c868a88d97bb16d (patch) | |
| tree | 2c69afd61f6a12053ccb183cd1293847c65fd815 | |
| parent | 5f50568b1f7ab4f917b8d782d643ac55612910dd (diff) | |
tools/mpy-tool.py: Fix merge of multiple mpy files to POP_TOP correctly.
MP_BC_CALL_FUNCTION will leave the result on the Python stack, so that
result must be discarded by MP_BC_POP_TOP.
Signed-off-by: Damien George <damien@micropython.org>
| -rwxr-xr-x | tools/mpy-tool.py | 4 | 
1 files changed, 2 insertions, 2 deletions
| diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 1ac6c93d7..de7cfe5d6 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -938,7 +938,7 @@ def merge_mpy(raw_codes, output_file):          merged_mpy.extend(header)          bytecode = bytearray() -        bytecode_len = 6 + len(raw_codes) * 4 + 2 +        bytecode_len = 6 + len(raw_codes) * 5 + 2          bytecode.append(bytecode_len << 2)  # kind and length          bytecode.append(0b00000000)  # signature prelude          bytecode.append(0b00001000)  # size prelude @@ -947,7 +947,7 @@ def merge_mpy(raw_codes, output_file):          for idx in range(len(raw_codes)):              bytecode.append(0x32)  # MP_BC_MAKE_FUNCTION              bytecode.append(idx)  # index raw code -            bytecode.extend(b"\x34\x00")  # MP_BC_CALL_FUNCTION, 0 args +            bytecode.extend(b"\x34\x00\x59")  # MP_BC_CALL_FUNCTION, 0 args, MP_BC_POP_TOP          bytecode.extend(b"\x51\x63")  # MP_BC_LOAD_NONE, MP_BC_RETURN_VALUE          bytecode.append(0)  # n_obj | 
