Shop OBEX P1 Docs P2 Docs Learn Events
Operators in pasm — Parallax Forums

Operators in pasm

grahamreitzgrahamreitz Posts: 56
edited 2009-08-22 02:56 in Propeller 1
This is not legitimate pasm code, correct?
mov result, temp // #10


Although it does compile with the prop tool.

This is legitimate, correct?
mov result, #123 // #10



If pasm operators can only perform compile time operations, what is the value?

Why not do this? Since the answer to 123mod10 is fairly obvious.
mov result, #3



One use comes to mind for large pasm files where one constant, that gets operated on, is used often and as a constant variable it can be changed in one place.

If a runtime modulus operation is needed we need to create our own code to do it?

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-08-21 23:28
    greitz said...
    Why not do this? Since the answer to 123mod10 is fairly obvious.

    Although all integer constant expressions could be considered "obvious", you keep them separate to show the heritage of the numbers in order to create self documenting code.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-08-21 23:33
    I'm surprised that any source operand with a "#" in any position but the first character compiles. However, both of these should be correct:

            mov result, temp/10 'Load the contents of the memory location given by the address of temp divided by ten into result.
            mov result,#temp/10 'Load the address of temp, divided by ten, into result.
    
    
    


    -Phil
  • grahamreitzgrahamreitz Posts: 56
    edited 2009-08-22 01:35
    Thanks Phil.

    I was under the impression that pasm operators only worked on constants during compile time.

    If I understand now, operators will work on data in cog memory at run-time?
  • SRLMSRLM Posts: 5,045
    edited 2009-08-22 01:58
    No, labels are compile (assemble) time. According to the manual: "Operators - Propeller Assembly code can contain constant expressions, and those expressions may use any operators that are allowed in constant expressions."

    I think what Phil is saying is that they both store the address divided by 10, but the second also sets the immediate bit. This would be done at runtime.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-08-22 02:56
    greitz said...
    If I understand now, operators will work on data in cog memory at run-time?
    All assembly operands have to be resolved at compile time. The '#' only indicates that the source operand itself is contained within the instruction, rather than pointing to a location from which the actual operand can be loaded when the program runs.

    -Phil
Sign In or Register to comment.