Skip to content

Commit

Permalink
py/asmxtensa: Use proper calculation for const table offset.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpgeorge committed Oct 1, 2018
1 parent 5b19916 commit 4fc437f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion py/asmxtensa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4fc437f

Please sign in to comment.