Shop OBEX P1 Docs P2 Docs Learn Events
Why should I do such an assignment? — Parallax Forums

Why should I do such an assignment?

ErNaErNa Posts: 1,768
edited 2025-02-23 20:38 in PASM2/Spin2 (P2)
pub testmumpf (mumpf)
  mumpf := mumpf

this procedure can be compiled. But what actually happens?
A second question: how to create a newline when displaying code ? Thanks, solved

[code]
pub testmumpf (mumpf)
mumpf := mumpf
[/CODE]

Comments

  • @ErNa said:
    A second question: how to create a newline when displaying code ?

    >

    Triple backtick block, like this (escaped for demonstration)
    ```
    Code here
    ```

  • @ErNa said:
    pub testmumpf (mumpf) mumpf := mumpf
    this procedure can be compiled. But what actually happens?
    A second question: how to create a newline when displaying code ?

    [code]
    pub testmumpf (mumpf)
    mumpf := mumpf
    [/CODE]

    Hi,
    as I do not work with SPIN2, I cannot help you much with this question other than that a look into the .lst file is sometimes very interesting.
    I would assume, that nothing happens and if the optimizer is good, it will throw out all of it.
    Now off for a look at Hochrechnungen....
    Best regards Christof

  • ErNaErNa Posts: 1,768
    edited 2025-02-23 21:01

    @"Christof Eb." said:

    @ErNa said:
    pub testmumpf (mumpf) mumpf := mumpf
    this procedure can be compiled. But what actually happens?

    Hi,
    ... than that a look into the .lst file is sometimes very interesting.

    Best regards Christof

    I'm using Propeller tool, just to KISS. Expect to switch to another IDE only after having a first simple application running, I move from P1 to P2.
    What created the .list file ?

    Anyway: I started to write a statement like ab= a, using copy and paste resulting in a = a . Then I left the scene without adding the b, later returned, compiled and wondered, why no error was thrown, as it makes no sense to change the value of an input.
    Or is this an intended behavior for quick stimulation of a function to test?

  • @ErNa said:

    pub testmumpf (mumpf)
      mumpf := mumpf
    

    this procedure can be compiled. But what actually happens?

    With the usual Spin interpreter:

    • First local variable gets pushed onto the stack
    • Value is popped off the stack and stored into first local variable
    • Function exists and tears down the stack frame
  • evanhevanh Posts: 16,238
    edited 2025-02-23 22:44

    There is no error because it is legal syntax. The fact it is achieving nothing functional is not the compiler's concern.

    Christof's reference to a .lst file was probably from the Flexspin compiler. It provides a textural listing of what goes into the binary executable. Here's an example compile-to-native snippet:

    01ec4                 | _mountsd_0143
    01ec4     02 4A 06 F6 |     mov COUNT_, #2
    01ec8     28 01 A0 FD |     call    #pushregs_
    01ecc     84 00 00 FF 
    01ed0     5F B8 06 F6 |     mov arg01, ##@LR__2444
    01ed4                 | '     return _umount((char *)user_name);
    01ed4     AC C2 B0 FD |     call    #__system___umount
    01ed8     20 92 06 F1 |     add ptr___system__dat__, #32
    01edc     49 01 68 FC |     wrlong  #0, ptr___system__dat__
    01ee0     20 92 86 F1 |     sub ptr___system__dat__, #32
    01ee4     4A C5 02 F6 |     mov local01, ptr__dat__
    01ee8     08 C4 06 F1 |     add local01, #8
    01eec     15 B8 06 F6 |     mov arg01, #21
    01ef0     14 BA 06 F6 |     mov arg02, #20
    01ef4     10 BC 06 F6 |     mov arg03, #16
    01ef8     17 BE 06 F6 |     mov arg04, #23
    01efc     16 C0 06 F6 |     mov arg05, #22
    01f00     48 C7 02 F6 |     mov local02, objptr
    01f04     62 91 02 F6 |     mov objptr, local01
    01f08     A8 3A B0 FD |     call    #_sdsd_cc__sdsd_open
    01f0c     63 91 02 F6 |     mov objptr, local02
    01f10     4F C7 0A F6 |     mov local02, result1 wz
    01f14     98 00 90 5D |  if_ne  jmp #LR__0210
        ...
    

    And that was generated from:

    static FILE * mountsd( void )
    {
        FILE *handle;
        int  rc, clkdiv;
    
        umount("/sd");
        _seterror(0);
        handle = DRV._sdsd_open(CLK_RL, CMD_RL, DAT0_RL, PWR_RL, LED_RL);
        if( !handle )  {
    ...
    
  • ErNaErNa Posts: 1,768

    evanh, thanks for showing this. I ran into a problem moving SW to the P2, surprise: I had no problems using @@ in Spin, but something went wrong when I did the same in ASM. So I had to refresh (or gain) understanding how pointer addresses actually work. In the end I realized, I missed to instantiate a variable, and now it looks, I'm fine in this respect.

  • @evanh said:
    Christof's reference to a .lst file was probably from the Flexspin compiler. It provides a textural listing of what goes into the binary executable.

    Oh, yes, I meant this. Sorry for being unclear.

Sign In or Register to comment.