Trouble with INDEX instruction

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LuNo_297436
Level 3
Level 3
First solution authored 10 replies posted 10 questions asked

Hello everyone.

   

I´m having troubles accessing a table with INDEX instruction.

   

The device i´m using is CY8C29466.

   

The table is 128 entries long and is feeding a 16 bit timer.

   

Previously i had a precomputed table divided in MSB and LSB working just fine. Then i decided  trying a table computed at compile  time,

   

like this:

   

ProcFreq:
    mov    A,[RecByte]
    asl    A
    push    A
    index    Number
    mov    [period],A
    pop    A
    index    (Number+1)
    ;period+1 already in A
    move    X,[period]
    lcall    Timer16_1_WritePeriod
    ret

   

Number:

   

DW (Main_Freq/256)/x
DW (Main_Freq/256)/x
DW (Main_Freq/256)/x
DW (Main_Freq/256)/x
....
....
....
DW (Main_Freq/256)/x     ;128 times

   

The code above is working partially, when i reach a value of 93 or 0x5D in the table it jumps to nowhere and never get back!

   

I have some cuestions on this:

   

1. What is wrong in the code above, of course.

   

2. Why in the life i need to put "asl   A"  to acces the table? If i don´t use ASL i get messed values.

   

Thanks in advance

0 Likes
1 Reply
LuNo_297436
Level 3
Level 3
First solution authored 10 replies posted 10 questions asked

Hello again

   

I´m really sorry!!

   

I´ve found that a very fast interrupt was the reason the  program never got back.

   

The table is reading correctly

   

Should I remove the thread?

   

Thanks a lot

0 Likes