Shop OBEX P1 Docs P2 Docs Learn Events
Please Confirm Documentation Error — Parallax Forums

Please Confirm Documentation Error

pjvpjv Posts: 1,903
edited 2011-09-14 20:38 in Propeller 1
Hi All;

In the Propeller Manual V1.2 on page 298, in bullet 3 under the Concise Truth Table, the note states that C (when written) is set on a jump except in the special circumstance.

My tests show the opposite, that C gets cleared (have not tested the special circumstance)

I believe my methods and results are correct; can anyone -or Parallax- please confirm the documentation to be incorrect?

Cheers,

Peter (pjv)

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2011-09-14 12:08
    I use the expression "cflag = value1 < value2" in SpinSIm, where value1 and value2 are unsigned integers. value1 comes from the destination field and value2 comes from the source field. The JMP instruction is in the same group of instructions as MAX, MIN, MOVI, MOVS and MOVD, which also compute C in the same way. The Prop tool assembles the JMP instruction with a zero in the destination field, so the C flag depends on the value stored at location zero and the jump address in value2. If location zero contains a PASM instruction it will be larger than the largest jump address of 511, so the C flag should be zero.
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-09-14 12:19
    There is no real jmp opcode, they are all changed to 'jmpret 0, source nr' by the assembler.

    A (wr) jmpret preforms a movs before it change the pc counter.

    You could type your own jmp by: jmpret dest, source nr wc

    if you set dest register to known value that is higher than 511 or 0 you get the c you want.


    Or if you start your code with:
    Org 0
    asm_entry long 0 (or long 512), both would be taken as being a nop.

    you can now use your regular jump: jmp #source wc (c is set if long 0 is used above)


    C= Unsigned (D < S)
  • pjvpjv Posts: 1,903
    edited 2011-09-14 14:32
    Dave and Tony;

    Thanks ever so much for this information. It really helps me understand what is going on now. Last year Kuroneko was trying to say similar things to me, and I did not grasp what was going on..... my code was running correctly, so I did not pursue it. I think I got it now!

    What a wondeful forum! Thanks again.

    Cheers,

    Peter (pjv)
  • kuronekokuroneko Posts: 3,623
    edited 2011-09-14 16:21
    tonyp12 wrote: »
    There is no real jmp opcode, they are all changed to 'jmpret 0, source nr' by the assembler.
    By that logic there is no real rdlong either :)
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-09-14 16:28
    Actually there is no real wrlong, as it's that one that is missing the r. (rdlong have r and that make sense as you want the dest field to get the result)
    It's not the underlying hub circuit that actually reads this r state and performs the read vs write?

    There is no real cmp or test either, just nr version of sub & and.

    If the prop had a CLR opcode, but it's just the assembler changing it to a mov dest,#0
    I would say clr is not real either though that is pseudo-opcode common on other mcu assembler (but this is given as not being real)

    Prop is the only mcu I know there I can set nr, so If I can recreate one opcode by just adding a nr to another opcode I would say one is real.
    And if I built an prop assembler, that's how I would treat them and do one pass to change these to real opcodes but with nr inserted.

    Plus I think it's easier to understand the props read/write rules on special registers
    if you know what's really going on but the only difference is that the final write to dest field is skipped with a nr.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-09-14 16:39
    On the other hand, there really are MUL, MULS, ENC and ONES instructions that the Prop tool will assemble. There just isn't any logic in the Prop to support them.
  • kuronekokuroneko Posts: 3,623
    edited 2011-09-14 16:42
    Tony, Dave: Don't cling too much onto 0..511. While the jump target only uses the lower 9bit, the comparison is still done with the full register. E.g. you might get some mixed parameter/address value from a rdlong and just jump to it.
    rdlong  addr, par wz
    if_nz   jmpret  par, addr wc,nr       ' set carry (I know that shadow[par] is 0)
            jmp     #$-2
    
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-09-14 17:19
    Only time I could see the use of jmp with wc is that you want to test if this is the first entry to this loop or if it come here from a jmp.
    But pretty sure there or other ways with the same amount of code to accomplice this.
    org 0
    asm_entry
               long 0 
               code {wc is never used} 
               code
    :loop if_c add mycounter,#1 
               code
               code       {using: if_z neg 0,#1 for example here would reverse the result}
               jmp #:loop wc {set c}
    
    {alternative version]
    {32bit in S is used in comparison and you are looking for c=clear solution, set the dest register to -1 as I could not see S ever being that.}
     
    
    asm_entry
                neg par,#1
                code {c is set}
                code
    :loop if_nc add mycounter,#1 
                code
                code
                jmpret par,#:loop wc nr {clear c]
    
  • kuronekokuroneko Posts: 3,623
    edited 2011-09-14 17:22
    tonyp12 wrote: »
    Why would you use nr on jmp? ,it's already set as nr.
    Too early here. I meant jmpret of course. As for wc usage, I need carry set as an entry condition (known state). If I can get it for free from a jmpret fine.
  • kuronekokuroneko Posts: 3,623
    edited 2011-09-14 18:55
    tonyp12 wrote: »
    32bit in S is used in comparsion and you are looking for c=clear solution, set the dest register to -1 as I could not see S ever being that.
    What's wrong with jmpret $, #imm wc,nr and jmpret reg, reg wc,nr? Besides, even if the source register is -1 it's still carry clear.
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-09-14 19:39
    It's only in that example that I'm jumping to a lower register.
    I could see that you use this as if/else kind of situation and jumping forward. (maybe $ still works?)

    sub dest, #2 wz
    if_z jmpret par,#lable wc nr {clear c]
    code
    code
    lable if_nc code
  • kuronekokuroneko Posts: 3,623
    edited 2011-09-14 19:53
    tonyp12 wrote: »
    It's only in that example that I'm jumping to a lower register.
    Doesn't matter. My issue is with the -1 requirement (in par). You don't need it.
  • pjvpjv Posts: 1,903
    edited 2011-09-14 20:26
    Hi Tony;

    Where I was being tripped up when I first posted this question was with a jmp #xx wc to prep the carry for a conditional instruction further down the line, and C was not consistent between my code and my test examples. All is well now, and I appreciate your, as well as Dave and Kuroneko's help inn clearing this up for me..... You guys sure know your stuff !

    Cheers,

    Peter (pjv)
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-09-14 20:38
    How about this situation, then you need -1 in par.

    org 0
    code wz
    negz par,#1 {let the status of z set par=1 or par= -1}
    code wz
    if_z jmpret par,#lable wc nr {clear or set c}
    code
    code
    lable if_nc_z code {what have to happend above for this be true, i'm not sure:)}
Sign In or Register to comment.