Program fails crossing code page


Closed Thread
Results 1 to 11 of 11

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Program fails crossing code page

    Yes, var = var + 1 turns into an incf.

    Here's a small program ...
    Code:
    B   VAR BYTE
    W   VAR WORD
    
    B = 0
    W = 0
    
    B = B + 1
    W = W + 1
    After compiling, a quick look in the .LST file reveals all.
    Code:
                          00107 ; C:\PIC\ART\ASMVSPBP.PBP       00014   B = 0
                          00108         MOVE?CB 000h, _B
      00000000                M PREV_BANK = 0
    0001   01BA               M         clrf    _B
                          00109 
                          00110 ; C:\PIC\ART\ASMVSPBP.PBP       00015   W = 0
                          00111         MOVE?CW 000h, _W
      00000000                M PREV_BANK = 0
    0002   01B8               M         clrf    _W
      00000000                M PREV_BANK = 0
    0003   01B9               M         clrf    (_W) + 1
                          00112 
                          00113 ; C:\PIC\ART\ASMVSPBP.PBP       00017   B = B + 1
                          00114         ADD?BCB _B, 001h, _B
      00000000                M PREV_BANK = 0
    0004   0ABA               M         incf    _B,   F
                          00115 
                          00116 ; C:\PIC\ART\ASMVSPBP.PBP       00018   W = W + 1
                          00117         ADD?WCW _W, 001h, _W
      00000000                M PREV_BANK = 0
    0005   0AB8               M         incf    _W,   F
    0006   1903               M         btfsc   STATUS, Z
    0007   0AB9               M         incf    (_W)   + 1, F
    DT

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Program fails crossing code page

    Ah, nice to know. It looks like there was a time when this wasn't the case:
    http://www.rcfaq.com/PIC/optimize.htm
    Although incrementing a variable shouldn't have ever used three words unless a clrwdt was thrown in as well.

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


    Did you find this post helpful? Yes | No

    Default Re: Program fails crossing code page

    That page has been pointed to several times around here.
    It's probably the worst examples of PBP programming found anywhere on the internet.

    Sure, the programs are smaller when you use some of those techniques.
    But the savings come from bypassing the normal bank switching and page bit setting that PBP does to insure everything keeps working properly.

    The examples are fine by themselves because they are never larger than 2K and variables are never outide of bank0.
    But when you try to use them in your program that is bigger with more variables, all hell breaks loose.

    There are a couple true statements on the page, but with so much bad advice, it's hard to find them?

    My advice is to delete that bookmark from your favorites, and forget what you read.

    In his defense, ... it was 2002. I had some strange ideas about PBP back then too.
    DT

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Program fails crossing code page

    Haha, It was likely intended to apply to 1-2K pics!

    Um, all hell did break loose. The ISR routine was the problem BTW.

    It's probably the worst examples of PBP programming found anywhere on the internet.
    Maybe I need to post some code to claim that title.

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