Shop OBEX P1 Docs P2 Docs Learn Events
problem grabbing Values in array over 14 elements in asm — Parallax Forums

problem grabbing Values in array over 14 elements in asm

Rick_HRick_H Posts: 116
edited 2010-09-23 19:02 in Propeller 1
I am having a problem grabbing Values in array over 13 elements in asm.

this is my code, any thing over the 13th element is = to 0 in asm but shows up in terminal debug as the correct value.
VAR
    long stack[100]
pri inittest
stack[2] := 20      '8
stack[3] := 30      '12
stack[4] := 40      '16
stack[5] := 50      '20
stack[6] := 60      '24

stack[7] := 80      '28
stack[8] := 2300      '32
stack[9] := 240      '36
stack[10] := 80    '40
    
stack[11] := 160      '44
stack[12] := 100      '48
stack[13] := 50      '52
stack[14] := 25    '56
Dat
Init1                  add     Temp1,    par
                          add     Temp1,    #28
                          rdlong  T1span1,   Temp1
                          add     temp1,    #4
                          rdlong  T2Span1,   temp1
                          add     temp1,    #4
                          rdlong  span1,    temp1
                          add     temp1,    #4
                          rdlong  bias1,    temp1
Init1_ret              ret

Init2                  mov     Temp1,    par
                          add     Temp1,    #44
                          rdlong  T1span2,   Temp1
                          add     temp1,    #4
                          rdlong  T2Span2,   temp1
                          add     temp1,    #4
                          rdlong  span2,    temp1
                          add     temp1,    #4
                          rdlong  bias2,    temp1
Init2_ret              ret
T1span1      long          10            '28 - 7
T2span1      long          10            '32 - 8
span1       long          242             '36 - 9
Bias1       long          90               '40 - 10

T1span2      long          100          '44 - 11
T2span2      long          100         '48 - 12
span2       long          242            '52 - 13
Bias2       long          90               '56 - 14

temp1       long          0
if I change Init2 to use the same values as init1 I get the same output, if I then change span2 and bias2 to 44 and 48 I get 160 from each, but then when I try 52 or 56 I get 0 in both. their is no code that accesses the stack except this and the debuger.
am I missing something?

Comments

  • Rick_HRick_H Posts: 116
    edited 2010-09-23 10:07
    ya, keep messing with it and I still can't pull any data from element 13 and up into asm.
    I have tried using init1 to grab it and still get 0 so its not the asm code over writing it somewhere.
    I have tried elements 13 to 30 and get 0 no matter what init I use.

    The values are actually their, in spin I can write them to the terminal and its all correct.

    any debugging suggestions or is their some limitation to rdlong I don't understand?
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-09-23 10:42
    Somehow this does not look like it's being the whole code. It's always the best to attach the whole code. Maybe there is something wrong in how you call the PASM.

    As both Init1 and Init2 have a RET I wonder how it's used. If you really call Init1 or Init2 from SPIN with cognew( @Init1, @stack) and/or cognew( @Init2, @stack ) you in fact have a problem.
    Init1 will work, Init2 won't, because it does not find the PASM variables where you expect em.

    But that's guesswork and one can't guess what others can do wrong in programming ... you have to see it! ;o)
  • Rick_HRick_H Posts: 116
    edited 2010-09-23 16:22
    MagIO2 wrote: »
    As both Init1 and Init2 have a RET I wonder how it's used. If you really call Init1 or Init2 from SPIN with cognew( @Init1, @stack) and/or cognew( @Init2, @stack ) you in fact have a problem.
    Init1 will work, Init2 won't, because it does not find the PASM variables where you expect em.

    they are just initialization sub routines, not loaded in separate cogs.
  • Rick_HRick_H Posts: 116
    edited 2010-09-23 17:39
    still can't find the problem, made this change to see if it would help but its the same.
    InitLfos                  call    #InitLFO1
                              call    #InitLFO2
                  
                  ...more code hear
    
    InitLFO1                  mov     Temp1,    par
                              add     Temp1,    #28
                              rdlong  T1span1,   Temp1
                              add     temp1,    #4
                              rdlong  T2Span1,   temp1
                              add     temp1,    #4
                              rdlong  span1,    temp1
                              add     temp1,    #4
                              rdlong  bias1,    temp1
                              add     temp1,    #4
                              rdlong  state1,    temp1
                              rdlong  Amp1,     lfoOut1
    InitLFO1_ret              ret
    
    InitLFO2                  'mov     Temp2,    par
                              add     Temp1,    #4
                              rdlong  T1span2,   Temp1
                              add     temp1,    #4
                              rdlong  T2Span2,   temp1
                              add     temp1,    #4
                              rdlong  span2,    temp1
                              add     temp1,    #4
                              rdlong  bias2,    temp1
                              add     temp1,    #4
                              rdlong  state2,    temp1
                              rdlong  Amp2,     lfoOut2
    InitLFO2_ret              ret
    
  • Rick_HRick_H Posts: 116
    edited 2010-09-23 18:13
    duh, helps to set the data before starting the cog, not sure how it got the first set like that but it works now.
  • JonnyMacJonnyMac Posts: 9,209
    edited 2010-09-23 18:43
    Out of curiousity, could you create a generic routine like this?:
    rdarray		mov	addr, idx			' idx holds element index
    		shl	addr, #2			' x4 for longs
    		add	addr, par			' par holds base of array
    		rdlong	value, addr
    
  • Rick_HRick_H Posts: 116
    edited 2010-09-23 19:02
    ya, i'm sure I will get to that at some point, I am currently learning asm so I am taking it a step at a time and will rewrite the whole thing for optimization when it all works or when my code is longer than my time for counter. I'm just slowly trying to model what I did in spin, that's a new language for me also but wasn't much a leap from pbasic. the big thing for me is gona be writing an asm routine for the i2c bus and integrating it into my code if i can get it all into one cog.

    Honestly the time to init the data is not critical but I will need subs that are as fast as possible for user changes real time if I do it that way.
Sign In or Register to comment.