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

    Quote Originally Posted by Art View Post
    variable blabla = 0
    was asmed to clrf statements because the last time I checked,
    PBP zeros variables by copying a zero value to the variable like any other value,
    wasting one instruction per "variable = 0" statement.
    No, PBP will use CLRF when zeroing a variable.

    That ISR is from the original Elapsed Timer Demo, in which I had declared the variables without bank assignments, letting PBP assign the banks as needed.

    By changing Seconds = Seconds + 1 to incf _Seconds,F, you have bypassed PBP's banking mechanism and it's likely you are overwriting other variables in RAM.
    The few bytes that were gained, were probably the instructions changing banks.

    If you declare the variables as BANK0 it would be ok.
    Or if you put them back to PBP statements it will be ok.
    DT

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Program fails crossing code page

    Nice to hear! Given I haven't tried it yet.
    Does var = var + 1 translate to an incf instruction?
    Maybe that is what I'm trying to remember...
    It was years ago, I disassembled a PBP program
    With the tool in ICprog for 16F84.

    Great news anyway if I don't have to drop anything fancy
    To gain space. Thanks

  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

    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

  4. #4
    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.

  5. #5
    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

  6. #6
    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