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

Lookup Table in assembly

Kevin L.Kevin L. Posts: 10
edited 2006-08-22 17:55 in Propeller 1
I'm looking for a simple example in assembly to do a lookup table.

DAT          org
 
          
'--------- How do I access the table below?
 
          mov     ptr, #2   'Get second item in table
          call    look
 
 

look
 
          ????
          mov     data, ????
          and     data, $FFFF
look_ret  ret
 
 
data      res     1
ptr       res     1
 
table     word    $0000
          word    $C0C1
          word    $C181
          word    $0140
          word    $C301
          word    $03C0
          word    $0280
' Many more values

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-21 22:51
    Here's an example:
    look       mov    temp,ptr
               add    temp,#table    ' input value in ptr (0 to n-1)
               movs   :inline,temp   ' have to use instruction modification
               nop                   ' need pause here for future pipelining
    :inline    mov    data,0-0       ' get long value from table
               test   ptr,#1   wz    ' do we want odd or even half
        if_z   and    data,mask      ' if even, take lower 16 bits
        if_nz  shr    data,#16       ' if odd, take upper 16 bits
    look_ret   ret
    mask       long   $FFFF
    
    


    You can do the same kind of thing if you need byte values.

    Post Edited (Mike Green) : 8/21/2006 10:54:54 PM GMT
  • Kevin L.Kevin L. Posts: 10
    edited 2006-08-22 16:31
    Thanks Mike!
  • HarleyHarley Posts: 997
    edited 2006-08-22 17:46
    It is a shame that some answers to questions are not visible for all of us.

    I, for one, would appreciate seeing the answer to Kevin's question of
    Kevin L. said...
    I'm looking for a simple example in assembly to do a lookup table.
    The answer not being posted isn't very helpful to others who may also learn from this message string.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
    h.a.s. designn
  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-22 17:55
    What happens when you try to see the answer? I'm not aware of any restrictions on the viewing of message threads, only that you have to be a registered member to post a reply. Maybe you looked for it while I was correcting a mistake around 10:55 GMT. Does it appear now? I'd be happy to repost it.
Sign In or Register to comment.