Shift Function gives MPASM error


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2010
    Posts
    6

    Default Shift Function gives MPASM error

    I have a PIC18F2520 project which uses shift operators.

    e.g. B1 = B1 << 5
    (B1 is a byte variable)

    When it compiles, MPASM produces the following error result:

    ERROR[126] f:\pbp26\pbppic18.lib 662: Argument out of range (16388 not between 0 and 16383)

    If I comment out the shift function, the project compiles/assembles without error. Any shift function produces a similar error.

    I have to use MPASM so how can I perform a shift function.

    I am using PBP2.6a and MPASM v5.37.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    It would help if you would show your whole code.
    What is the value of B1?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2010
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    The value of B1 does not seem to affect the error message. I have tried forcing B1 to 1, 40 and 255 and the error message is the same.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This compiles fine here
    Code:
     
    B1  var BYTE 
    B1 = 255
    B1 = B1 << 5
    So the problem is someplace else.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2010
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I have just found that if I comment out the following include files, the shift function in the main program compiles/assembles without error.

    With the shift function omitted and these files included, the program compiles/assembles without error and runs perfectly so somehow one of them is affecting MPASM and shift functions.

    'INCLUDE "DT_INTS-18.bas"
    'INCLUDE "ReEnterPBP-18.bas"
    'INCLUDE "NewRXbuff.inc"

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    What is
    'INCLUDE "NewRXbuff.inc"

    The other two if unchanged are good files.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Sep 2010
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Problem is fixed.

    My original include files looked like:


    Code:
    INCLUDE "vars4.inc"
    GoTo Initialise
    INCLUDE "DT_INTS-18.bas"
    INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    INCLUDE "NewRXbuff.inc"
    INCLUDE "Init18_4.inc"
    INCLUDE "Rxmsg18_1.inc"
    INCLUDE "Scan2.inc"
    INCLUDE "Display4.inc"
    INCLUDE "Process18_4.inc"
    INCLUDE "MonMode_1.inc"
    INCLUDE "MSSP.inc"
    Whilst the Goto immediately after "vars..." may look strange, it was done this way many years ago when the project used a PIC16F876. I can't remember the reason for doing it this way but it always worked when assembling with PBP so there has been no reason till now to change.

    With this new version of the project using a PIC18, by removing or moving the Goto the project now compiles/assembles without error. My includes are now:

    Code:
    INCLUDE "vars4.inc"
    INCLUDE "DT_INTS-18.bas"
    INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    INCLUDE "NewRXbuff.inc"
    INCLUDE "Init18_4.inc"
    INCLUDE "Rxmsg18_1.inc"
    INCLUDE "Scan2.inc"
    INCLUDE "Display4.inc"
    INCLUDE "Process18_4.inc"
    INCLUDE "MonMode_1.inc"
    INCLUDE "MSSP.inc"
    It still puzzles me why the PIC18 project worked perfectly until I added shift functions which then caused MPASM to generate errors.

    mackrackit, thanks for trying to help.

Members who have read this thread : 1

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