PBP Wish List


Results 1 to 6 of 6

Thread: PBP Wish List

Threaded View

  1. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I agree, it would be nice to have functions built into PBP. But until that happens, here is a round about way of achieving the same thing, kinda, sorta.

    First, you need to create a "macro" that copies the passed parameters into known locations. Then create your subroutine just like normal, keeping in mind that the input and output are always thru the known Temp variables.

    After the macro copies the parameters to the Temp variables, it will call the code for the function. When the function is finished it will return to the macro which will copy the result to the third parameter. You can pass as many parameters as you want (as long as they fit on 1 line).
    Code:
    Temp1  var word
    Temp2  var word
    Temp3  var word
    
    asm
    Foo macro W1, W2, R1
       MOVE?WW   W1, _Temp1    ; Copy  first parameter to Temp Variable 1
       MOVE?WW   W2, _Temp2    ; Copy second parameter to Temp Variable 2
       L?CALL    _FooCode      ; call the Foo functions code
       MOVE?WW   _Temp3, R1    ; Copy Temp3 to result
       endm
    endasm
    
    
    FooCode:                  ' PBP code for the function
      Temp3 = Temp1 * Temp2
      ' and whatever else Foo does
      ' final result must be in Temp3
    return
    To use the new function

    Code:
    bar    var word
    bleh   var word
    belch  var word
    
    @ Foo  _bar, _bleh, _belch
    or

    Code:
    Dogs          var word
    FleasPerDog   var word
    TotalFleas    var word
    
    @ Foo  _Dogs, _FleasPerDog, _TotalFleas
    The example shown will only work with words, to use bytes: change the appropriate MOVE?WW to MOVE?BB

    The biggest benefit of a function is the ability to embed it in a math formula or conditional test. Unfortunately, this Macro type function DOES NOT allow you to do that. So I'm still hoping for true functions in PBP also.
    Last edited by Darrel Taylor; - 23rd July 2003 at 05:34.

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. PBP List file???
    By MOUNTAIN747 in forum General
    Replies: 2
    Last Post: - 28th February 2010, 19:48
  3. List of instructions used in PBP ?
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd November 2007, 11:22
  4. PBP Editor Wish List:
    By blainecf in forum PBP Wish List
    Replies: 7
    Last Post: - 12th July 2006, 21:07
  5. PBP wish list.....
    By muddy0409 in forum PBP Wish List
    Replies: 7
    Last Post: - 21st November 2005, 09:51

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts