Shop OBEX P1 Docs P2 Docs Learn Events
Ways to read data tables in asm — Parallax Forums

Ways to read data tables in asm

tonyp12tonyp12 Posts: 1,951
edited 2011-02-18 15:55 in Propeller 1
Self modifying code is a must as prop does not have registers.

This is something I put togheter quickly,
the good part is you can add to the data list
without counting how much data there is.
It loops through the table forever.


What is your prefered way to do it?
              movd      :loop,datapnt               'change d-field below at location :loop
              add       datapnt,#1                  'add one long for next time
              cmp       datapnt,#datapnt wz         'did it reach the end?
        if_z  mov       datapnt,#data               'if soo, reset data pointer
                
:loop         test      0-0,asm_bit wz              '0-0 is were selfmod code goes.
              ...
              ...

data          long      %00000000_10100000_10101000_00101010
              long      %00000000_10101000_10101000_10101010
              long      %00000000_10101000_10001000_10101010
              long      %00000000_10101000_00000000_10101010
datapnt       long      data             

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-18 15:25
    Just to set things straight:

    The propeller has more registers than any other microcontroller I know. It has 512 registers also called COG RAM. What makes RAM a register? The fact that it can be used by the processors ALU for it's operations.

    What's missing in the propeller is an indirect addressing mode.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-02-18 15:53
    the djnz is often used for decrementing a counter. You have the right idea though. DOnt forget that with self-modifying code, there must be an instruction executed (or a nop) between modifying the instruction and executing the instruction. This is because of the pipeline.
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-02-18 15:55
    Yes, I planned to add: , let alone a indirect register method.

    I would be good if you could use something like this.

    :loop test (datapnt)+, asm_bit wz ' test the data that the datapnt is pointing at, post add 1 to datapnt.

    But the prop have a very clean instruction set,
    and the selfmode code is not that bad when everything else is such a joy.

    lenght counter and djnz i wanted to avoid, as the table is animation data that will loop forever.
Sign In or Register to comment.