Shop OBEX P1 Docs P2 Docs Learn Events
Propeller II programing questions to Chip - Page 4 — Parallax Forums

Propeller II programing questions to Chip

12467

Comments

  • AribaAriba Posts: 2,682
    edited 2012-12-29 18:37
    David Betz wrote: »
    Not really. GAS needs to be as compatible with PASM as possible. I'll do whatever Chip does.

    Wise decision :smile:
  • SapiehaSapieha Posts: 2,964
    edited 2012-12-29 18:37
    Hi David.

    Nice decision

    David Betz wrote: »
    Not really. GAS needs to be as compatible with PASM as possible. I'll do whatever Chip does.
  • potatoheadpotatohead Posts: 10,253
    edited 2012-12-29 19:09
    I agree with that assessment.
  • SapiehaSapieha Posts: 2,964
    edited 2012-12-29 19:44
    Hi.

    Instruction's PDF Updated in first post
  • SapiehaSapieha Posts: 2,964
    edited 2012-12-31 07:21
    Hi.

    Happy new year to all

    From Sweden.
  • Bill HenningBill Henning Posts: 6,445
    edited 2012-12-31 12:17
    Happy New Year!!! (in less than 12 hours here in Vancouver, BC)
    Sapieha wrote: »
    Hi.

    Happy new year to all

    From Sweden.
  • cgraceycgracey Posts: 14,133
    edited 2012-12-31 17:41
    The immediate iteration count and instruction count in REPS and REPD are one-based in the assembly language source, though they are encoded as zero-based in the opcode.

    REPS #16,#1 encodes %00000000001111 for the '#16' and %000000 for the '#1'.

    When REPD uses a D register to express iterations, it follows the same rule, where execution of the block will occur only once when the D register holds $00000000, or 2^32 times when D holds $FFFFFFFF.

    I've been on taking a break over the holidays, but I'm getting back on the documentation work.

    I posted this on the doc thread earlier, but here is the latest, again. See the section on REPS/REPD:

    Prop2_Docs.txt
  • David BetzDavid Betz Posts: 14,511
    edited 2012-12-31 18:56
    I'm not sure I understand what the OFFP instruction does. It seems like it toggles the direction of a pin. Is that correct? Is there any way to set the direction of a pin other than by using the DIRA-DIRD registers?
  • potatoheadpotatohead Posts: 10,253
    edited 2012-12-31 21:18


    GETP

    D/#n

    Get pin number given by register “D (0-511)” or “n (0-127)”into !Z or C flags.



    GETPN

    D/#n

    Get pin number given by register “D (0-511)” or “n (0-127)”into Z or !C flags.



    OFFP

    D/#n

    Toggle pin number given by register “D (0-511)” or “n (0-127)” off or on. DIR



    NOTP

    D/#n

    Invert pin number given by the value in register “D (0-511)” or “n (0-127)”. OUT



    CLRP

    D/#n

    Clear pin number given by the value in register “D (0-511)” or “n (0-127)”. OUT



    SETP

    D/#n

    Set pin number given by the value in register “D (0-511)” or “n (0-127)”. OUT



    SETPC

    D/#n

    Set pin number given by the value in register “D (0-511)” or “n (0-127)” to C



    SETPNC

    D/#n

    Set pin number given by the value in register “D (0-511)” or “n (0-127)” to !C



    SETPZ

    D/#n

    Set pin number given by the value in register “D (0-511)” or “n (0-127)” to Z



    SETPNZ

    D/#n

    Set pin number given by the value in register “D (0-511)” or “n (0-127)” to !Z


  • AribaAriba Posts: 2,682
    edited 2012-12-31 22:22
    David Betz wrote: »
    I'm not sure I understand what the OFFP instruction does. It seems like it toggles the direction of a pin. Is that correct? Is there any way to set the direction of a pin other than by using the DIRA-DIRD registers?

    If you use one of the pin output instructions (SETP, CLRP, NOTP ...) the direction is automatically set to output, you don't need to set DIRx first. If you want then the pin to be an input you can use OFFP one time to set it to input. So: Yes there is another way beside setting DIRx.

    Andy
  • potatoheadpotatohead Posts: 10,253
    edited 2013-01-01 03:05
    Sorry David, my whole post did not come through.

    As Andy just mentioned, the pin specific instructions set states just given pin numbers. Just dropping the table there didn't do a lot of good. :(
  • David BetzDavid Betz Posts: 14,511
    edited 2013-01-01 04:33
    Ariba wrote: »
    If you use one of the pin output instructions (SETP, CLRP, NOTP ...) the direction is automatically set to output, you don't need to set DIRx first. If you want then the pin to be an input you can use OFFP one time to set it to input. So: Yes there is another way beside setting DIRx.

    Andy
    Thanks! That wasn't clear to me from the preliminary instruction set document. Does GETP automatically set the pin to an input?
  • David BetzDavid Betz Posts: 14,511
    edited 2013-01-01 05:13
    I'm trying to write some inline functions for manipulating pins and am finding it awkward that the pin instructions use the C or Z flag for the pin value rather than a register. I've come up with these two sequences to get and set a pin but it seems like there has to be a better way. Any ideas?
    r0              long    0
    r1              long    0
    
    
    ' get the value of a pin
    '   r0 contains the pin number
    '   returns pin value in r0
    my_getpin       getpin r0 wc
              if_c  mov r0, #1
              if_nc mov r0, #0
    my_getpin_ret   ret
    
    
    ' set the value of a pin
    '   r0 contains the pin number
    '   r1 contains the pin value
    my_setpin       cmp r1, #0 wz
              if_z  clrp r0
              if_nz setp r0
    my_setpin_ret   ret
    
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-01-01 05:52
    Can you just use RCL to rotate the carry bit into the register?

    Something like:

    rcl R0,#1

    After you get the pin input into C.
  • David BetzDavid Betz Posts: 14,511
    edited 2013-01-01 05:55
    mindrobots wrote: »
    Can you just use RCL to rotate the carry bit into the register?

    Something like:

    rcl R0,#1

    After you get the pin input into C.
    Yes but then I'll have to clear the register first and that will be the same number of instructions as I'm using now. It might look better though without the conditions. Thanks for the suggestion.
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-01-01 06:04
    I haven't started stringing instructions together yet. My first impressions were these new pin instructions would make quick work of sending/receiving a string of bits to/from a pin. Single bits may not pick up any efficiencies unless we're missing a trick.

    It has got me thinking about PASM again! :0)
  • David BetzDavid Betz Posts: 14,511
    edited 2013-01-01 06:10
    mindrobots wrote: »
    I haven't started stringing instructions together yet. My first impressions were these new pin instructions would make quick work of sending/receiving a string of bits to/from a pin. Single bits may not pick up any efficiencies unless we're missing a trick.

    It has got me thinking about PASM again! :0)
    I think the new instructions will work well in PASM code but I'm not sure if the C compiler will be able to make use of them easily. The P2 is much more of a CISC machine than P1 and compilers have always had a hard time making good use of some CISC instructions.
  • Roy ElthamRoy Eltham Posts: 2,996
    edited 2013-01-01 08:17
    David,
    You could use MUXC or MUXNC to set all the bits of a destination register to C or !C.

    Also, you could uses RCR D,1, then SETPC to set a pin to the state of bit 0 of D. Or do the CMP D, 0 wz, then SETPZ.
  • cgraceycgracey Posts: 14,133
    edited 2013-01-01 10:06
    David Betz wrote: »
    I'm not sure I understand what the OFFP instruction does. It seems like it toggles the direction of a pin. Is that correct? Is there any way to set the direction of a pin other than by using the DIRA-DIRD registers?

    It seems our early documentation is wrong. Here is OFFP:

    OFFP D/#n - clears both the DIR bit and PIN bit for the pin (input with output bit low)
  • cgraceycgracey Posts: 14,133
    edited 2013-01-01 10:10
    David Betz wrote: »
    Thanks! That wasn't clear to me from the preliminary instruction set document. Does GETP automatically set the pin to an input?

    GETP and GETNP do not affect the DIR bit. They only read the input, regardless of its DIR state. In other words, if a pin is outputting a low, but is externally being forced high, you will read the high state.
  • David BetzDavid Betz Posts: 14,511
    edited 2013-01-01 11:02
    cgracey wrote: »
    It seems our early documentation is wrong. Here is OFFP:

    OFFP D/#n - clears both the DIR bit and PIN bit for the pin (input with output bit low)
    Thanks Chip! That description of OFFP makes more sense given the opcode name.
  • David BetzDavid Betz Posts: 14,511
    edited 2013-01-01 11:03
    cgracey wrote: »
    GETP and GETNP do not affect the DIR bit. They only read the input, regardless of its DIR state. In other words, if a pin is outputting a low, but is externally being forced high, you will read the high state.
    That makes sense. Thanks!
  • David BetzDavid Betz Posts: 14,511
    edited 2013-01-01 13:05
    Has anyone written a disassembler for the Propeller 2 instruction set? I have updated GAS to assemble P2 instructions but don't have the disassembler updated yet.
  • SapiehaSapieha Posts: 2,964
    edited 2013-01-02 09:28
    Hi Chip.

    Is it possible You can post any simple block diagram how to program counters / theirs possibilits
  • cgraceycgracey Posts: 14,133
    edited 2013-01-02 09:41
    Sapieha wrote: »
    Hi Chip.

    Is it possible You can post any simple block diagram how to program counters / theirs possibilits

    I'm covering the branch instructions now. I'll do the counters next. Thanks.
  • SapiehaSapieha Posts: 2,964
    edited 2013-01-02 09:44
    Hi Chip.

    Thanks

    cgracey wrote: »
    I'm covering the branch instructions now. I'll do the counters next. Thanks.
  • SapiehaSapieha Posts: 2,964
    edited 2013-01-03 23:58
    Hi.

    PDF in first post updated
  • SapiehaSapieha Posts: 2,964
    edited 2013-01-09 18:15
    Hi All.

    Prop2_Docs.txt.pdf updated in first post
  • David BetzDavid Betz Posts: 14,511
    edited 2013-01-09 19:16
    How does WAITPEQ work on P2? How does it know which PINx register to examine?
  • cgraceycgracey Posts: 14,133
    edited 2013-01-09 21:30
    David Betz wrote: »
    How does WAITPEQ work on P2? How does it know which PINx register to examine?

    I forgot to mention this in the doc's. I'll add it tonight.

    In the meantime, you must use 'SETPORT D/#n' where bits 5 and 6 of the operand determine which port (0..3) the WAITPEQ/WAITPNE will look at.
Sign In or Register to comment.