Shop OBEX P1 Docs P2 Docs Learn Events
Does the @-operator work for method-parameters? (ealier How does the pasm-code of FDX — Parallax Forums

Does the @-operator work for method-parameters? (ealier How does the pasm-code of FDX

StefanL38StefanL38 Posts: 2,292
edited 2015-02-14 06:15 in Propeller 1
Hi,

I want to write a VGA-2-FDX-wrapper.

The One-wire-Demo-code is written for VGA-Text or tv_text-driver
Some of the methods of VGA_text /TV_text differ from FDX.

So I want to write a variant of the FDX-object that has methods that
only the object-filename "vga_text" must be changed to "FDX_VGA_Text_Wrapper".

This means my FDX_VGA_Text_Wrapper-object must have f.e. a method

"start" with a single parameter naming the Tx-Pin.
The FDX-code still needs the other parameters Rx, mode and baudrate

So I want to hardcode these parameters but how?

I looked into the original start-method of FDX-code
 PUB start(rxpin, txpin, mode, baudrate)  : okay
  stop
  longfill(@rx_head, 0, 4)
  longmove(@rx_pin, @rxpin, 3)
  bit_ticks := clkfreq / baudrate
  buffer_ptr := @rx_buffer
  okay := cog := cognew(@entry, @rx_head) + 1

How the heck does the pasm-code get the tx-pin-number???

Does the @-operator work for method-parameters just the same as for global variables??
If yes - cool! Of not how the heck does it work?
Can somebody explain this to me?

best regards

Stefan

Comments

  • ratronicratronic Posts: 1,451
    edited 2015-02-13 12:12
    Stefan this part of the Pasm code translates txPin in spin to txmask in Pasm.
    entry                   mov     t1,par                'get structure address
                            add     t1,#4 << 2            'skip past heads and tails
    
                            rdlong  t2,t1                 'get rx_pin
                            mov     rxmask,#1
                            shl     rxmask,t2
    
                            add     t1,#4                 'get tx_pin
                            rdlong  t2,t1
                            mov     txmask,#1
                            shl     txmask,t2
    
                            add     t1,#4                 'get rxtx_mode
                            rdlong  rxtxmode,t1
    
  • StefanL38StefanL38 Posts: 2,292
    edited 2015-02-13 12:14
    HI Dave,

    Aha. So this means the @-operator works for global variables defined in the VAR-section AND works for method-parameters?

    best regards

    Stefan
  • ratronicratronic Posts: 1,451
    edited 2015-02-13 12:21
    In Pasm you only have DAT section variables for direct use so you can change them however you want but only prior to doing a cognew.
  • ratronicratronic Posts: 1,451
    edited 2015-02-13 12:43
    It starts by moving the Parameters passed to Hub memory using this code.
    longmove(@rx_pin, @rxpin, 3)                          'copy the start parameters to this objects pin variables
    

    You can see from this code they pass the beginning of hub variable rx_head to start which tx_pin comes shortly after.
    okay := cog := cognew(@entry, @rx_head) + 1           'start the new cog now, assembly cog at "entry" label.
    
  • StefanL38StefanL38 Posts: 2,292
    edited 2015-02-14 00:13
    I understand. Thanks for explaining.

    My fault. I was writing a question in the title and this question was answered.

    What I wanted to ask was something addtional:

    Does the @-operator work for SPIN-method-parameters too?

    Answer with Yes or No

    best regards

    Stefan
  • AribaAriba Posts: 2,690
    edited 2015-02-14 02:56
    Yes

    .. but you must be careful. These local variables (and parameters) are on the stack and therefore the adresses of the variables are only valid until you leave that methode.

    Andy
  • StefanL38StefanL38 Posts: 2,292
    edited 2015-02-14 06:15
    Ariba wrote: »
    Yes

    .. but you must be careful. These local variables (and parameters) are on the stack and therefore the adresses of the variables are only valid until you leave that methode.

    Andy

    and that's the reason why FDX has the command
       longmove(@rx_pin, @rxpin, 3)
    

    which copies the values from the parameters "rxpin" "txpin" "mode" to the global variables
    of the FDX-SPIN-file named very similar "rx_pin", "tx_pin", "rxtx_mode"

    best regards

    Stefan
Sign In or Register to comment.