News:

Let's find out together what makes a PIC Tick!

Main Menu

unused code included in assembler

Started by See_Mos, Apr 15, 2022, 10:15 AM

Previous topic - Next topic

See_Mos

How should I exclude code from an INC file to stop it being added to the assembler?

I just noticed that unused LCD setup code is being added to the assembly of some code that I am working on.

I use INC files to set up 18F25K22 devices.  The LCD is selected and set up in the INC file like this

$define _LCD_PORT_ 3                    ' LCD PortA = 0, PortB = 1, PortC = 2
                                        ' 3 = custom or no LCD
'Include "18F25K22 IntOsc 4.inc"         ' setup LCD etc.
'Include "18F25K22 IntOsc 8.inc"
'Include "18F25K22 IntOsc 16.inc"
Include "18F25K22 Intosc 64.inc"

If the LCD_PORT_3 is selected then the INC should skip the LCD setup and the message which is at the end of the INC, however, I have just noticed that if 3 is selected the compilation sets up an LCD for PORTB and includes the unused message.

Compiler V4.0.1.5
Rename the attached file to INC

See_Mos

I solved it by copying the three lines to show the message into each of three sections above and deleting the last five lines from the INC

John Drew

Quote from: See_Mos on Apr 15, 2022, 04:06 PMI solved it by copying the three lines to show the message into each of three sections above and deleting the last five lines from the INC
Maybe not for your application but if they are written as procedures and a procedure is not called then the code won't be included.