Shop OBEX P1 Docs P2 Docs Learn Events
Question regarding PASM — Parallax Forums

Question regarding PASM

Patrick1abPatrick1ab Posts: 136
edited 2010-05-05 19:51 in Propeller 1
Hi all!

I splitted a PASM function into two parts:

wINDIRECT                 

'Populate reg and data before calling this routine.

              'and       reg,    _wordmask      'Ensure only a word will be copied over
              mov       t2,     reg
              and       t2,     _lowerbyte
              shl       t2,     shift1
              
              andn      outa,   A0mask          
              or        outa,   A1mask          'Set address to $02 (LSBs of address Register)
              or        outa,   RDmask          'Set RDpin high
              andn      outa,   WRmask          'and WRpin low to perform a write operation

              and       outa,   invDATAmask        'Clear all data lines 
              or        outa,   t2              'set the data pins to the given value
              andn      outa,   CSmask          'Begin the data transmission
              nop
              or        outa,   CSmask          'End the data transmission (first half of the address)

              mov       t2,     reg
              and       t2,     _upperbyte
              shl       t2,     shift2
              or        outa,   A0mask          
              andn      outa,   A1mask          'Set address to $01 (MSBs of address Register)
              'andn      outa,   CSmask          'Start the data transmission (second half of the address) 

              and       outa,   invDATAmask        'Clear all data lines
              or        outa,   t2              'set the data pins to the given value
              andn      outa,   CSmask          'Begin the data transmission
              nop
              or        outa,   CSmask          'End the data transmission (first half of the address)
              

:dataonly     and       data,   #$FF            'Ensure only a byte will be copied over
              mov       t2,     data
              shl       t2,     shift1

              or        outa,   A0mask
              or        outa,   A1mask          'Set address to $03 (data Register)
              'andn      outa,   CSmask          'Start the data transmission (payload data)
                            
              and       outa,   invDATAmask        'Clear all data lines
              or        outa,   t2              'set the data pins to the given value
              andn      outa,   CSmask          'Begin the data transmission
              nop
              or        outa,   CSmask          'End the data transmission (first half of the address)


wINDIRECT_ret ret                               'Return to the calling loop



Now if I want to call the whole function I'm using
call      #wINDIRECT



but how do I call the sub function only?

I tried the following code but it does not work:
call      #wINDIRECT:dataonly

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-05-05 19:45
    First of all, you can't use a local label (":dataonly") for a call from somewhere else. Second, you need another _ret label for this like:
    wINDIRECT
    '... stuff
    dataonly
    '... other stuff
    dataonly_ret
    wINDIRECT_ret
         ret
    


    This way, you can call either wINDIRECT or dataonly
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-05-05 19:45
    See changes below.
    Patrick1ab said...
    Hi all!

    I splitted a PASM function into two parts:

    wINDIRECT                 
    
    'Populate reg and data before calling this routine.
    
                  'and       reg,    _wordmask      'Ensure only a word will be copied over
                  mov       t2,     reg
                  and       t2,     _lowerbyte
                  shl       t2,     shift1
                  
                  andn      outa,   A0mask          
                  or        outa,   A1mask          'Set address to $02 (LSBs of address Register)
                  or        outa,   RDmask          'Set RDpin high
                  andn      outa,   WRmask          'and WRpin low to perform a write operation
    
                  and       outa,   invDATAmask        'Clear all data lines 
                  or        outa,   t2              'set the data pins to the given value
                  andn      outa,   CSmask          'Begin the data transmission
                  nop
                  or        outa,   CSmask          'End the data transmission (first half of the address)
    
                  mov       t2,     reg
                  and       t2,     _upperbyte
                  shl       t2,     shift2
                  or        outa,   A0mask          
                  andn      outa,   A1mask          'Set address to $01 (MSBs of address Register)
                  'andn      outa,   CSmask          'Start the data transmission (second half of the address) 
    
                  and       outa,   invDATAmask        'Clear all data lines
                  or        outa,   t2              'set the data pins to the given value
                  andn      outa,   CSmask          'Begin the data transmission
                  nop
                  or        outa,   CSmask          'End the data transmission (first half of the address)
                  
    
    dataonly     and       data,   #$FF            'Ensure only a byte will be copied over
                  mov       t2,     data
                  shl       t2,     shift1
    
                  or        outa,   A0mask
                  or        outa,   A1mask          'Set address to $03 (data Register)
                  'andn      outa,   CSmask          'Start the data transmission (payload data)
                                
                  and       outa,   invDATAmask        'Clear all data lines
                  or        outa,   t2              'set the data pins to the given value
                  andn      outa,   CSmask          'Begin the data transmission
                  nop
                  or        outa,   CSmask          'End the data transmission (first half of the address)
    
    dataonly_ret
    wINDIRECT_ret ret                               'Return to the calling loop
    



    Now if I want to call the whole function I'm using
    call      #wINDIRECT
    



    but how do I call the sub function only?

    call      #dataonly
    



    I tried the following code but it does not work:
    call      #wINDIRECT:dataonly
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
    My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
    and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
    Las - Large model assembler Largos - upcoming nano operating system
  • Patrick1abPatrick1ab Posts: 136
    edited 2010-05-05 19:51
    Wow, that was quick. Thanks to both of you wink.gif
Sign In or Register to comment.