diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-19 15:47:59 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-19 15:53:41 +0200 |
commit | 047cd40313e39b662650bbf6c8059ab0910e5986 (patch) | |
tree | d883b3da1a95adba26be031b6a462847539f39b9 /py/showbc.c | |
parent | 0f96ec826811e3cec3703141684445bea639e2bc (diff) | |
download | micropython-047cd40313e39b662650bbf6c8059ab0910e5986.tar.gz micropython-047cd40313e39b662650bbf6c8059ab0910e5986.zip |
Bytecode int varlen encoding: support arbitrary values for signed ints too.
Diffstat (limited to 'py/showbc.c')
-rw-r--r-- | py/showbc.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/py/showbc.c b/py/showbc.c index e3387dbe27..837ee7611f 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -57,11 +57,18 @@ void mp_byte_code_print(const byte *ip, int len) { printf("LOAD_CONST_ELLIPSIS"); break; - case MP_BC_LOAD_CONST_SMALL_INT: - unum = (ip[0] | (ip[1] << 8) | (ip[2] << 16)) - 0x800000; - ip += 3; - printf("LOAD_CONST_SMALL_INT %d", (int)unum); - break; + case MP_BC_LOAD_CONST_SMALL_INT: { + int num = 0; + if ((ip[0] & 0x40) != 0) { + // Number is negative + num--; + } + do { + num = (num << 7) | (*ip & 0x7f); + } while ((*ip++ & 0x80) != 0); + printf("LOAD_CONST_SMALL_INT %d", num); + break; + } case MP_BC_LOAD_CONST_INT: DECODE_QSTR; |