summaryrefslogtreecommitdiff
path: root/py/asmxtensa.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-10-01 12:34:58 +1000
committerDamien George <damien.p.george@gmail.com>2018-10-01 12:34:58 +1000
commit4fc437f1ef3264ead2409b7ea648bbb27ecc9366 (patch)
treecf64607363d890ba921c7330a81cff076cc5b2fa /py/asmxtensa.c
parent5b19916d6e953b5c5a6eb03afaf7f8e59e35baee (diff)
py/asmxtensa: Use proper calculation for const table offset.
Instead of hard-coding it to 4 bytes. This allows for there to be other data stored at the very start of the emitted native code.
Diffstat (limited to 'py/asmxtensa.c')
-rw-r--r--py/asmxtensa.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/py/asmxtensa.c b/py/asmxtensa.c
index c10d2d88d..6a3a874f1 100644
--- a/py/asmxtensa.c
+++ b/py/asmxtensa.c
@@ -161,7 +161,8 @@ void asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32) {
asm_xtensa_op_movi(as, reg_dest, i32);
} else {
// load the constant
- asm_xtensa_op_l32r(as, reg_dest, as->base.code_offset, 4 + as->cur_const * WORD_SIZE);
+ uint32_t const_table_offset = (uint8_t*)as->const_table - as->base.code_base;
+ asm_xtensa_op_l32r(as, reg_dest, as->base.code_offset, const_table_offset + as->cur_const * WORD_SIZE);
// store the constant in the table
if (as->const_table != NULL) {
as->const_table[as->cur_const] = i32;