PDA

View Full Version : Shift Function gives MPASM error



blackwood
- 25th September 2010, 03:49
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.

mackrackit
- 25th September 2010, 09:15
It would help if you would show your whole code.
What is the value of B1?

blackwood
- 25th September 2010, 09:36
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.

mackrackit
- 25th September 2010, 09:46
This compiles fine here


B1 var BYTE
B1 = 255
B1 = B1 << 5
So the problem is someplace else.

blackwood
- 25th September 2010, 22:37
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"

mackrackit
- 26th September 2010, 06:02
What is
'INCLUDE "NewRXbuff.inc"

The other two if unchanged are good files.

blackwood
- 27th September 2010, 08:45
Problem is fixed.

My original include files looked like:



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:


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.