Shop Learn
P2 PASM syntax — Parallax Forums

P2 PASM syntax

EEEE 1101100 RAA AAAAAAA AAAAAAAAA
JMP #A Jump to A. If R = 1, PC += A, else PC = A.

EEEE 1101101 RAA AAAAAAA AAAAAAAAA
CALL #A Call to A by pushing {C, Z, 10'b0, PC[19:0]} onto stack. If R = 1, PC += A, else PC = A.

How must JMP and CALL be used to exploit the full address range of 20 bits in PASM.

Comments

  • evanhevanh Posts: 12,022
    edited 2021-11-21 00:21

    As the syntax indicates, these are immediate only encodings. The assembler encodes the address for you. All need do is write call #label

    PS: Wherever "label" is located it'll be reachable since the full 20 bits gets encoded.

  •               orgh      $1000
    ''+------[ Load new COG code ]-------------------------------------------------+
    reload_cog      setq    #512-16-1                       '\ re-load COG 
                    rdlong  #0, ##@cog_code                 '/          
    

    The propeller tool bumps into the last line on the #0.
    What is wrong with it?

  • evanhevanh Posts: 12,022

    The correct syntax is rdlong 0, ##@cog_code

  • Isn't the memory content of address 0 of the COG-Ram taken as target?
    The # should be a direct value.

    FlexProp says >> error: Bad use of immediate for first operand of rdlong

    Propeller Tool says >> Expected a constant, unary operator, or "(".

    How could the original have been translated so that it worked?

    The many tools for translating are not very helpful for learning. :(

    I have taken over the first time so to test I'm not ready anyway there must still be thrown out some.

  • AribaAriba Posts: 2,551
    edited 2021-11-24 11:37

    @pic18f2550 said:
    Isn't the memory content of address 0 of the COG-Ram taken as target?
    The # should be a direct value.

    # is immediate, without # it's direct addressing.
    RDLONG reads into a register, you can't read into an immedate value.

    FlexProp says >> error: Bad use of immediate for first operand of rdlong

    Propeller Tool says >> Expected a constant, unary operator, or "(".

    FlexProp detects the error correct.

    How could the original have been translated so that it worked?

    >
    See evanh's post.

    The many tools for translating are not very helpful for learning. :(

    Then use only one.

    I have taken over the first time so to test I'm not ready anyway there must still be thrown out some.

    The real problem is that you don't get the absolute address with ##@cogcode in a Spin DAT section, but that got discussed many many times.

  • evanhevanh Posts: 12,022
    edited 2021-11-24 11:44

    Possibly the biggest reason for the syntax being as is, is so WRLONG can use both addressing modes:

    • wrlong 0, hubaddr - This copies the content of register 0 to hubaddr in hubRAM.
    • wrlong #0, hubaddr - Whereas this writes a 0 to hubaddr in hubRAM.
  • pic18f2550pic18f2550 Posts: 336
    edited 2021-11-24 15:55

    So with the Propeller Tool I better load a register with 0 to get this right.
    nope does not work either

  • ersmithersmith Posts: 5,107

    Consider this code:

        org 0
    reg0
        nop
        rdlong reg0, hubaddr
        rdlong 0, hubaddr
    hubaddr
        long $FF00  ' put any hub address here
    

    The two "rdlong" instructions will compile to exactly the same binary instruction; they are the same thing, because the symbol "reg0" is located at address 0. Both of them will take the 4 bytes in HUB starting at hubaddr and put them into COG memory location 0, which initially contains a "nop" instruction (which is represented by all 0's).

  • evanhevanh Posts: 12,022

    @pic18f2550 said:
    nope does not work either

    I suspect the not working part is elsewhere.

  • Ok if the correct CODE comes out that is OK. Thank you.

    I didn't find the "alignl" in the PASM exeltable. What is this for?

  • evanhevanh Posts: 12,022
    edited 2021-11-25 11:53

    ALIGNL is a "directive". It's tells the assembler you want the next data aligned, in the binary file it is assembling, on a longword boundary relative to the file start. The presumption is that it'll then align the same when loaded in memory too.

    EDIT: Or it could be relative to the previous ORG/ORGH. That could technically have a different outcome. Not sure, I've not actually read the definition.

    At any rate, the effect is it can add anything from 0 to 3 padding bytes at that point in the binary file (Assuming bytes is the base addressing size of course).

  • i always do this with a long statement without value. thanks

  • ersmithersmith Posts: 5,107

    @pic18f2550 said:
    i always do this with a long statement without value. thanks

    That does not work on P2, because the P2 allows LONG values to be placed on any boundary. That's why Chip added ALIGNL.

Sign In or Register to comment.