Shop OBEX P1 Docs P2 Docs Learn Events
Shift in pasm i got lost — Parallax Forums

Shift in pasm i got lost

AnubispodAnubispod Posts: 42
edited 2014-12-28 17:23 in Propeller 1
Hi , i need some help ???

i have a word declared in pasm what reads in the value from a buffer what alternates

the 1 value is 35828 dec 1000_1011_1111_0100 bin
the 2 value is 3060 dec 0000_1011_1111_0100 bin
now where im stuck i need to decode that

from right to left
0-10 are the value 11-14 are the ch number and 15 tells me if it is a repeat frame


rdword decode,t4
mov ch,decode
shl ch,#1
shr ch,#12
wrword ch,t4

now it should schow me 1 in the app but it shows 1 and 17 ???? alternating


Mhh i thought it should kill the bit 15 and then move it over to to the right to get only the chanel number

Comments

  • pik33pik33 Posts: 2,366
    edited 2014-12-28 05:38
      shl ch,#1
      shr ch, #12
    

    does the same as shr ch, #11

    What did you try to do doing this shl? Get rid of bit 15? If so, the Propeller is 32 bit and you should try
      shl ch,#17
      shr ch,#28
    

    then you will have bits 11..14 in sh, the rest will be lost.
  • kwinnkwinn Posts: 8,697
    edited 2014-12-28 06:27
    You can shift the data back and forth like you did, or you can mask off the desired bits after shifting them as shown below.
            rdword decode,t4
            mov   ch,decode
            shr   ch,#11            ' shift right to remove value
            and   ch,#%1111     ' mask off channel number
            wrword ch,t4
    
  • AnubispodAnubispod Posts: 42
    edited 2014-12-28 06:30
    Ahh tank you ,

    i have now a other little problem or question

    how would i get now my pointer increased by the channel number i hold in a long not res

    i have t4 what points to the start of my array,
    then i have my channel number 0-11 in a long

    when i try some thing like

    add t4,ch*2

    does not work ???
  • pik33pik33 Posts: 2,366
    edited 2014-12-28 08:13
    This is assembler, not spin or c, and ch is cog register so you cannot do this in this way. Instead
      mov ch2,ch
      shl ch2,#1
      add t4,ch2
    
    (....)
    
    ch2 res 1
    
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-12-28 09:42
    Don't forget that, even though you read the value from the hub as a 16-bit word, it exists in the cog register as a 32-bit long. So to shift out bit 15, you have to shift left by 17, not 1.

    -Phil
  • AnubispodAnubispod Posts: 42
    edited 2014-12-28 12:09
    Thanks a lot got it working :)
  • ElectrodudeElectrodude Posts: 1,658
    edited 2014-12-28 17:23
    Anubispod wrote: »
    how would i get now my pointer increased by the channel number i hold in a long not res

    A res is a long, using it just saves some hub ram.
Sign In or Register to comment.