aboutsummaryrefslogtreecommitdiff
path: root/py/emitbc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-09-12 12:19:49 +1000
committerDamien George <damien.p.george@gmail.com>2019-09-26 15:27:11 +1000
commit870e900d02937918187a4e4ef75a1e38880bae62 (patch)
treece453ef717bb097e68cd5c8346eb70e6abb5b81e /py/emitbc.c
parent1f7202d122a478b0c8cedcf7cf252849b2d3d881 (diff)
py: Introduce and use constants for multi-opcode sizes.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r--py/emitbc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/py/emitbc.c b/py/emitbc.c
index ef0d20a10..83fcbae41 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -539,8 +539,10 @@ void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
}
void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg) {
- if (-16 <= arg && arg <= 47) {
- emit_write_bytecode_byte(emit, 1, MP_BC_LOAD_CONST_SMALL_INT_MULTI + 16 + arg);
+ if (-MP_BC_LOAD_CONST_SMALL_INT_MULTI_EXCESS <= arg
+ && arg < MP_BC_LOAD_CONST_SMALL_INT_MULTI_NUM - MP_BC_LOAD_CONST_SMALL_INT_MULTI_EXCESS) {
+ emit_write_bytecode_byte(emit, 1,
+ MP_BC_LOAD_CONST_SMALL_INT_MULTI + MP_BC_LOAD_CONST_SMALL_INT_MULTI_EXCESS + arg);
} else {
emit_write_bytecode_byte_int(emit, 1, MP_BC_LOAD_CONST_SMALL_INT, arg);
}