Shop OBEX P1 Docs P2 Docs Learn Events
Table in assembly — Parallax Forums

Table in assembly

LafetLafet Posts: 23
edited 2007-10-03 21:17 in Propeller 1
Hello,

I need copy values from tables in COG memory to the HUB memory.

...
VAR

  Byte State
                  
OBJ

  debug  : "FullDuplexSerialPlus"
  
PUB Main  

Debug.start(31, 30, 0, 57600)
coginit(6,@entry, @State)

Debug.bin(State,6)

repeat

DAT
                
entry     mov     ptr, #2        ' for an example, get third value
            call      #look           
:stop     jmp     #:stop       

look      mov     data, ptr      ' ptr is a table index (0 to n-1)
            add      data, #table 'pointer to Table + offset   
            mov     :inline, data  
            nop                         'pause for pipelining
:inline   mov      data,0-0      ' get byte value from table
            wrbyte  data, par     'save table values to HUB memory -> State 
look_ret  ret

table   byte  %100110
          byte  %010110
          byte  %010011
          byte  %001011
          byte  %001101
          byte  %100101

data      res     1
ptr        res     1




When I start this code with "ptr from 0 to 5", State contains next values:

ptr  State

0    001010
1    001011
2    001100
3    001101
4    001110
5    001111




Where I make error please?

Thanks Lafet

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-10-03 21:16
    Just a typo: use MOVS rather than MOV. You only want to modify the last 9 bits in the instruction.

    Edit: BTW, you need not intermediately store the table value; you can directly write from the table, in that case use MOVD
                movd     :inline, data  
                nop                         'pause for pipelining
    :inline   wrbyte  0-0, par     'save table values to HUB memory -> State
    



    Further Edit: To explain your read values: As you force a NOP with your MOV, they are just the addresses of the table entries, formerly contained in DATA, as TABLE starts at cell 10 =%1010.

    For some unclear reasons the COG has loaded fast enough... I should have thought Ariba were right with his second remark.....

    Post Edited (deSilva) : 10/3/2007 9:35:06 PM GMT
  • AribaAriba Posts: 2,685
    edited 2007-10-03 21:17
    The worst error is the 'mov :inline,data' instruction. This overwrites the whole instruction at :inline, but you will only write the source address in the :inline instruction. Use 'movs :inline,data' instead.

    An other problem is that you don't wait after coginit until the Assembly cog is startet and has written the State value before you do the 'Debug.bin(State,6)'. You can add a waitcnt-Delay or wait for a value <>0 in State.

    You can use PASD for debugging such problems:
    http://forums.parallax.com/showpost.php?p=0

    Andy
Sign In or Register to comment.