Shop OBEX P1 Docs P2 Docs Learn Events
PASM issue — Parallax Forums

PASM issue

I am unable to compile a NOP in PASM if there is a condition used.

Example: if_z_and_c nop (fails with "Expected an assembly instruction" message)

Is this a tool issue or a PASM limitation? I am using the Propeller Tool v2.6.3

Thanks!

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2022-06-08 18:03

    Regardless of whether it's allowed or not, it's completely pointless. Even if it were allowed, it would be NOP whether the condition held of not. IOW, it would still use one instruction cycle, in either case.

    -Phil

  • I am using the construct to make my code timing constants. I don't think that's pointless. I can use another instruction (like if_z or data, #0) but it is a bit confusing.

  • Are you saying that a conditional still requires 4 cycles, even if the op isn't executed? I did not get that from the documentation (or I'm an idiot)

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2022-06-08 18:26

    Are you saying that a conditional still requires 4 cycles, even if the op isn't executed?

    Yes.

    -Phil

  • Thanks Phil. I have been using STM32 parts for years, but I am using the Prop1 for a project because you can actually buy them! It's been a steep learning curve...

  • Wuerfel_21Wuerfel_21 Posts: 5,053
    edited 2022-06-08 19:04

    You can't use conditions on NOP because it is actually just an alias for if_never rdbyte 0,0 nr (which is equivalent to any if_never instruction, but this one happens to assemble to zero)

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2022-06-08 19:14

    You can get the same granularity, albeit at the expense of an extra instruction cycle by putting a conditional on an instruction that takes two cycles, viz:

             if_condition  tjz  $,#0
    

    If the condition holds, the tjz will execute, testing itself for a zero condition. Since the instruction itself is non-zero, the jump will not take place, thus requiring two instruction cycles. If the condition does not hold, the tjz will not execute, thus requiring one instruction cycle.

    -Phil

  • Thanks for the insights. I re-read the Prop manual and found the info about conditionals taking 4 cycles. Doh!

Sign In or Register to comment.