PBP Using too many instructions


Results 1 to 15 of 15

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    ... In this case the multiple if statements are required.
    I have my doubts about that.
    Multiple IF statements usually just means Spaghetti.

    How would i go about doing the ASM macro thing?
    Well, here's one way ...
    Code:
    ;---------------------------------------------------------------------------
    ASM
    IfEqual  macro Bin, Cin, Lin          ; Bin is a BYTE variable
        RST?RP                            ; Cin is a constant to campare against
        movlw   Cin                       ; Lin is a label to jump to ...
        subwf   _vPWMPos,w                ;   if the condition is false
        btfsc   STATUS, Z
        goto    Lin
      endm
    ENDASM
    ;-----[Here's how you use it]----------------------------------------------
    
    @  IfEqual  _vPWMPos, 1, _L1
      ; code here executes if _vPWMPos = 1
    L1:
    
    @  IfEqual  _vPWMPos, 2, _L2
      ; code here executes if _vPWMPos = 2
    L2:
    In most cases, it will take 4-5 instructions.
    But care must be taken to insure it doesn't cross a Page Boundary.

    I still think you'll be better off using BRANCH.<hr>

    I think this would probably work "pin = (pinValue=PWMPos)" but i wonder if that would get compiled to the same kind of code as an if statement.
    That way only works if you can use the inverse of the result ...
    Code:
    myPIN = !(pinValue = vPWMPos)
    Of course, the inverse of that is ...
    Code:
    myPIN = !(pinValue != vPWMPos)
    Last edited by Darrel Taylor; - 11th October 2009 at 05:49. Reason: Modified macro
    DT

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 13:55
  2. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 14:43
  3. List of instructions used in PBP ?
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd November 2007, 12:22
  4. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 20:01
  5. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2005, 00:30

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