Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Trying to understand .hex files obtained after compiling a XC8 MPLAB X project.

Status
Not open for further replies.

flote21

Advanced Member level 1
Advanced Member level 1
Joined
Jan 22, 2014
Messages
411
Helped
1
Reputation
2
Reaction score
3
Trophy points
1,298
Activity points
5,595
Hello guys,

I am wondering about the .hex files generated by this compiler. Normally the .hex files present the aspect attachedi in the "File1.hex". It is posible to appreciate that the programm is located in the first memory positions. However usgin the file1 mplab project, i have added a new routing (void estimate_temperature()) which is not calling any interruption and anything. It is a mathematical equation: temp = tem1*200/100. I compiled this new project and i generated "file2.hex". The it is possible to appreciate that in file2.hex the program starts in 0x0000 like file1.hex but then it jump to other memory position. My question is why this issue is happening, if both project has the same linker configuration and the only difference is the estimate_temperature routine? Is there anyway to generate a file2.hex like file1.hex?

Thanks.

View attachment file1.TXTView attachment file2.TXT
 

To "understand" the code assignment performed by your compiler and linker, you'll review the symbol and listing files, or load the the project with debug information in MPLAB debugger. All information is available at your fingertips!

A hex file can be disassembled, but it's the worst option and not necessary if you have the project files.

A linker might place the main() code or a separate run time library startup function (I don't know if it exists with XC8) behind other code, so it's moved when the code changes. No problem normally.

There are options to locate certain code parts at specific addresses, but it's not necessary for simple applications. You'll find all respective information in the XC8 documentation.
 

You can also view the current project MAP file, which I believe is generated by default and located in the same directory/folder as the HEX file.

The MAP file contains a verbose report of which various code segments are place in what storage classes, as FvM alluded, you can use various linker options to relocate, reserve and allocate various storage class regions to codes segments, variables, interrupts etc.

LoadableTest.X.production.map example:

Code:
Microchip MPLAB XC8 Compiler V1.31 ()

Linker command line:

--edf=C:\Program Files (x86)\Microchip\xc8\v1.31\dat\en_msgs.txt -cs \
  -h+dist/FSUSB-PIC18F4550/production\LoadableTest.X.production.sym \
  --cmf=dist/FSUSB-PIC18F4550/production\LoadableTest.X.production.cmf -z \
  -Q18F4550 -oC:\Users\bdg\AppData\Local\Temp\saruc.6 \
  -Mdist/FSUSB-PIC18F4550/production/LoadableTest.X.production.map -E1 \
  -ver=XC8 -ASTACK=060h-07ffh -pstack=STACK \
  -ACODE=01000h-01005h,01008h-01015h,01018h-07FFFh \
  -ACONST=01000h-01005h,01008h-01015h,01018h-07FFFh \
  -ASMALLCONST=01000h-01005h,01008h-01015h,01018h-010FFh,01100h-011FFhx111 \
  -AMEDIUMCONST=01000h-01005h,01008h-01015h,01018h-07FFFh -ACOMRAM=01h-05Fh \
  -AABS1=00h-07FFh -ABIGRAM=01h-07FFh -ARAM=060h-0FFh,0100h-01FFhx7 \
  -ABANK0=060h-0FFh -ABANK1=0100h-01FFh -ABANK2=0200h-02FFh \
  -ABANK3=0300h-03FFh -ABANK4=0400h-04FFh -ABANK5=0500h-05FFh \
  -ABANK6=0600h-06FFh -ABANK7=0700h-07FFh -ASFR=0F60h-0FFFh \
  -preset_vec=01000h,intcode=01008h,intcodelo=01018h,powerup,init,end_init \
  -pramtop=0800h -psmallconst=SMALLCONST -pmediumconst=MEDIUMCONST \
  -pconst=CONST -AFARRAM=00h-00h -ACONFIG=0300000h-030000Dh -pconfig=CONFIG \
  -AIDLOC=0200000h-0200007h -pidloc=IDLOC -AEEDATA=0F00000h-0F000FFh \
  -peeprom_data=EEDATA \
  -prdata=COMRAM,nvrram=COMRAM,nvbit=COMRAM,rbss=COMRAM,rbit=COMRAM \
  -pfarbss=FARRAM,fardata=FARRAM,nvFARRAM=FARRAM \
  -pintsave_regs=BIGRAM,bigbss=BIGRAM,bigdata=BIGRAM -pbss=RAM \
  -pidata=CODE,irdata=CODE,ibigdata=CODE,ifardata=CODE \
  C:\Users\bdg\AppData\Local\Temp\saruc.obj \
  dist/FSUSB-PIC18F4550/production\LoadableTest.X.production.obj 

Object code version is 3.11

Machine type is 18F4550

Call graph: (short form)




                Name                               Link     Load   Length Selector   Space Scale
C:\Users\bdg\AppData\Local\Temp\saruc.obj
                end_init                           106A     106A        4      80C       0
                reset_vec                          1000     1000        4      800       0
                idloc                            200000   200000        8   200000       0
                config                           300000   300000        E   300000       0
dist/FSUSB-PIC18F4550/production\LoadableTest.X.production.obj
                intcodelo                          1018     1018       52      80C       0
                intcode                            1008     1008       10      804       0
                intcode_body                       7FA8     7FA8       58     3FD4       0
                text2                              7F48     7F48       14     3FA4       0
                text1                              7F5C     7F5C       22     3FAE       0
                text0                              7F3C     7F3C        C     3F9E       0
                cstackCOMRAM                          1        1        9        1       1
                dataCOMRAM                            A        A        4        1       1
                cinit                              7F7E     7F7E       2A     3FBF       0
                idataCOMRAM                        7F38     7F38        4     7F38       0

TOTAL           Name                               Link     Load   Length     Space
        CLASS   STACK          

        CLASS   CODE           
                end_init                           106A     106A        4         0
                intcodelo                          1018     1018       52         0
                intcode                            1008     1008       10         0
                reset_vec                          1000     1000        4         0
                intcode_body                       7FA8     7FA8       58         0
                text2                              7F48     7F48       14         0
                text1                              7F5C     7F5C       22         0
                text0                              7F3C     7F3C        C         0
                cinit                              7F7E     7F7E       2A         0
                idataCOMRAM                        7F38     7F38        4         0

        CLASS   CONST          

        CLASS   SMALLCONST     

        CLASS   MEDIUMCONST    

        CLASS   COMRAM         
                cstackCOMRAM                          1        1        9         1
                dataCOMRAM                            A        A        4         1

        CLASS   ABS1           

        CLASS   BIGRAM         

        CLASS   RAM            

        CLASS   BANK0          

        CLASS   BANK1          

        CLASS   BANK2          

        CLASS   BANK3          

        CLASS   BANK4          

        CLASS   BANK5          

        CLASS   BANK6          

        CLASS   BANK7          

        CLASS   SFR            

        CLASS   FARRAM         

        CLASS   CONFIG         
                config                           300000   300000        E         0

        CLASS   IDLOC          
                idloc                            200000   200000        8         0

        CLASS   EEDATA         



SEGMENTS        Name                           Load    Length   Top    Selector   Space  Class

                cstackCOMRAM                   000001  00000D  00000E         1       1  COMRAM  
                reset_vec                      001000  000004  001004       800       0  CODE    
                intcode                        001008  000010  001018       804       0  CODE    
                intcodelo                      001018  000056  00106E       80C       0  CODE    
                idataCOMRAM                    007F38  000004  007F3C      7F38       0  CODE    
                text0                          007F3C  00000C  007F48      3F9E       0  CODE    
                text2                          007F48  000014  007F5C      3FA4       0  CODE    
                text1                          007F5C  000022  007F7E      3FAE       0  CODE    
                cinit                          007F7E  00002A  007FA8      3FBF       0  CODE    
                intcode_body                   007FA8  000058  008000      3FD4       0  CODE    
                idloc                          200000  000008  200008    200000       0  IDLOC   
                config                         300000  00000E  30000E    300000       0  CONFIG  


UNUSED ADDRESS RANGES

        Name                Unused          Largest block    Delta
        BANK0            000060-0000FF               A0
        BANK1            000100-0001FF              100
        BANK2            000200-0002FF              100
        BANK3            000300-0003FF              100
        BANK4            000400-0004FF              100
        BANK5            000500-0005FF              100
        BANK6            000600-0006FF              100
        BANK7            000700-0007FF              100
        BIGRAM           00000E-0007FF              7F2
        CODE             001004-001005                2
                         00106E-007F37             6ECA
        COMRAM           00000E-00005F               52
        CONST            001004-001005                2
                         00106E-007F37             6ECA
        EEDATA           F00000-F000FF              100
        FARRAM           000000-000000                1
        MEDIUMCONST      001004-001005                2
                         00106E-007F37             6ECA
        RAM              000060-0007FF              100
        SFR              000F60-000FFF               A0
        SMALLCONST       001004-001005                2
                         00106E-007F37              100
        STACK            000060-0007FF              7A0

                                  Symbol Table

_ADCON1                  (abs)        000FC1
_INTCON2bits             (abs)        000FF1
_INTCONbits              (abs)        000FF2
_LATD                    (abs)        000F8C
_LED                     dataCOMRAM   00000A
_PORTB                   (abs)        000F81
_RCONbits                (abs)        000FD0
_T0CONbits               (abs)        000FD5
_TMR0H                   (abs)        000FD7
_TMR0L                   (abs)        000FD6
_TRISBbits               (abs)        000F93
_TRISD                   (abs)        000F95
__CFG_BOR$ON             (abs)        000000
__CFG_BORV$3             (abs)        000000
__CFG_CP0$OFF            (abs)        000000
__CFG_CP1$OFF            (abs)        000000
__CFG_CPB$OFF            (abs)        000000
__CFG_CPUDIV$OSC1_PLL2   (abs)        000000
__CFG_EBTR0$OFF          (abs)        000000
__CFG_EBTR1$OFF          (abs)        000000
__CFG_EBTRB$OFF          (abs)        000000
__CFG_FCMEN$OFF          (abs)        000000
__CFG_FOSC$HSPLL_HS      (abs)        000000
__CFG_IESO$OFF           (abs)        000000
__CFG_LPT1OSC$OFF        (abs)        000000
__CFG_LVP$OFF            (abs)        000000
__CFG_MCLRE$ON           (abs)        000000
__CFG_PBADEN$OFF         (abs)        000000
__CFG_PLLDIV$5           (abs)        000000
__CFG_PWRT$OFF           (abs)        000000
__CFG_STVREN$ON          (abs)        000000
__CFG_USBDIV$2           (abs)        000000
__CFG_VREGEN$ON          (abs)        000000
__CFG_WDT$OFF            (abs)        000000
__CFG_WDTPS$32768        (abs)        000000
__CFG_WRT0$OFF           (abs)        000000
__CFG_WRT1$OFF           (abs)        000000
__CFG_WRTB$OFF           (abs)        000000
__CFG_WRTC$OFF           (abs)        000000
__CFG_XINST$OFF          (abs)        000000
__HRAM                   (abs)        000000
__Habs1                  abs1         000000
__Hbank0                 bank0        000000
__Hbank1                 bank1        000000
__Hbank2                 bank2        000000
__Hbank3                 bank3        000000
__Hbank4                 bank4        000000
__Hbank5                 bank5        000000
__Hbank6                 bank6        000000
__Hbank7                 bank7        000000
__Hbigbss                bigbss       000000
__Hbigdata               bigdata      000000
__Hbigram                bigram       000000
__Hbss                   bss          000000
__Hcinit                 cinit        000000
__Hclrtext               clrtext      000000
__Hcomram                comram       000000
__Hconfig                config       30000E
__Hconst                 const        000000
__HcstackCOMRAM          cstackCOMRAM 000000
__Hdata                  data         000000
__HdataCOMRAM            dataCOMRAM   000000
__Heeprom_data           eeprom_data  000000
__Hend_init              end_init     00106E
__Hfarbss                farbss       000000
__Hfardata               fardata      000000
__Hibigdata              ibigdata     000000
__Hidata                 idata        000000
__HidataCOMRAM           idataCOMRAM  000000
__Hidloc                 idloc        200008
__Hifardata              ifardata     000000
__Hinit                  init         00106A
__Hintcode               intcode      001018
__Hintcode_body          intcode_body 000000
__Hintcodelo             intcodelo    00106A
__Hintentry              intentry     000000
__Hintret                intret       000000
__Hintsave_regs          intsave_regs 000000
__Hirdata                irdata       000000
__Hmediumconst           mediumconst  000000
__HnvFARRAM              nvFARRAM     000000
__Hnvbit                 nvbit        000000
__Hnvrram                nvrram       000000
__Hparam                 rparam       000000
__Hpowerup               powerup      00106A
__Hram                   ram          000000
__Hramtop                ramtop       000800
__Hrbit                  rbit         000000
__Hrbss                  rbss         000000
__Hrdata                 rdata        000000
__Hreset_vec             reset_vec    001004
__Hrparam                rparam       000000
__Hsfr                   sfr          000000
__Hsmallconst            smallconst   000000
__Hstack                 stack        000000
__Hstruct                struct       000000
__Htemp                  temp         000000
__Htext                  text         000000
__Htext0                 text0        000000
__Htext1                 text1        000000
__Htext2                 text2        000000
__LRAM                   (abs)        000001
__Labs1                  abs1         000000
__Lbank0                 bank0        000000
__Lbank1                 bank1        000000
__Lbank2                 bank2        000000
__Lbank3                 bank3        000000
__Lbank4                 bank4        000000
__Lbank5                 bank5        000000
__Lbank6                 bank6        000000
__Lbank7                 bank7        000000
__Lbigbss                bigbss       000000
__Lbigdata               bigdata      000000
__Lbigram                bigram       000000
__Lbss                   bss          000000
__Lcinit                 cinit        000000
__Lclrtext               clrtext      000000
__Lcomram                comram       000000
__Lconfig                config       300000
__Lconst                 const        000000
__LcstackCOMRAM          cstackCOMRAM 000000
__Ldata                  data         000000
__LdataCOMRAM            dataCOMRAM   000000
__Leeprom_data           eeprom_data  000000
__Lend_init              end_init     00106A
__Lfarbss                farbss       000000
__Lfardata               fardata      000000
__Libigdata              ibigdata     000000
__Lidata                 idata        000000
__LidataCOMRAM           idataCOMRAM  000000
__Lidloc                 idloc        200000
__Lifardata              ifardata     000000
__Linit                  init         00106A
__Lintcode               intcode      001008
__Lintcode_body          intcode_body 000000
__Lintcodelo             intcodelo    001018
__Lintentry              intentry     000000
__Lintret                intret       000000
__Lintsave_regs          intsave_regs 000000
__Lirdata                irdata       000000
__Lmediumconst           mediumconst  000000
__LnvFARRAM              nvFARRAM     000000
__Lnvbit                 nvbit        000000
__Lnvrram                nvrram       000000
__Lparam                 rparam       000000
__Lpowerup               powerup      00106A
__Lram                   ram          000000
__Lramtop                ramtop       000800
__Lrbit                  rbit         000000
__Lrbss                  rbss         000000
__Lrdata                 rdata        000000
__Lreset_vec             reset_vec    001000
__Lrparam                rparam       000000
__Lsfr                   sfr          000000
__Lsmallconst            smallconst   000000
__Lstack                 stack        000000
__Lstruct                struct       000000
__Ltemp                  temp         000000
__Ltext                  text         000000
__Ltext0                 text0        000000
__Ltext1                 text1        000000
__Ltext2                 text2        000000
__S0                     (abs)        30000E
__S1                     (abs)        00000E
__S2                     (abs)        000000
___inthi_sp              stack        000000
___intlo_sp              stack        000000
___sp                    stack        000000
__accesstop              (abs)        000060
__activetblptr           (abs)        000002
__end_of__initialization cinit        007F9E
__end_of_hi_interrupt    intcode_body 008000
__end_of_init_extint     text2        007F5C
__end_of_init_timers     text1        007F7E
__end_of_lo_interrupt    intcodelo    00106A
__end_of_main            text0        007F48
__initialization         cinit        007F7E
__mediumconst            mediumconst  000000
__pcinit                 cinit        007F7E
__pcstackCOMRAM          cstackCOMRAM 000001
__pdataCOMRAM            dataCOMRAM   00000A
__pidataCOMRAM           idataCOMRAM  007F38
__pintcode               intcode      001008
__pintcode_body          intcode_body 007FA8
__pintcodelo             intcodelo    001018
__ptext0                 text0        007F3C
__ptext1                 text1        007F5C
__ptext2                 text2        007F48
__ramtop                 ramtop       000800
__size_of_hi_interrupt   (abs)        000000
__size_of_init_extint    (abs)        000000
__size_of_init_timers    (abs)        000000
__size_of_lo_interrupt   (abs)        000000
__size_of_main           (abs)        000000
__smallconst             smallconst   000000
_direction               dataCOMRAM   00000B
_hi_interrupt            intcode      001008
_init_extint             text2        007F48
_init_timers             text1        007F5C
_lo_interrupt            intcodelo    001018
_main                    text0        007F3C
_speedH                  dataCOMRAM   00000C
_speedL                  dataCOMRAM   00000D
end_of_initialization    cinit        007F9E
int_func                 intcode_body 007FA8
intlevel0                text         000000
intlevel1                text         000000
intlevel2                text         000000
intlevel3                text         000000
stackhi                  (abs)        0007FF
stacklo                  (abs)        000060
start                    init         00106A
start_initialization     cinit        007F7E


FUNCTION INFORMATION:

 *************** function _main *****************
 Defined at:
		line 30 in file "main.c"
 Parameters:    Size  Location     Type
		None
 Auto vars:     Size  Location     Type
		None
 Return value:  Size  Location     Type
		None               void
 Registers used:
		wreg, status,2, cstack
 Tracked objects:
		On entry : 
		On exit  : 
		Unchanged: 
 Data sizes:     COMRAM   BANK0   BANK1   BANK2   BANK3   BANK4   BANK5   BANK6   BANK7
      Params:         0       0       0       0       0       0       0       0       0
      Locals:         0       0       0       0       0       0       0       0       0
      Temps:          0       0       0       0       0       0       0       0       0
      Totals:         0       0       0       0       0       0       0       0       0
Total ram usage:        0 bytes
 Hardware stack levels required when called:    3
 This function calls:
		_init_extint
		_init_timers
 This function is called by:
		Startup code after reset
 This function uses a non-reentrant model


 *************** function _init_timers *****************
 Defined at:
		line 44 in file "main.c"
 Parameters:    Size  Location     Type
		None
 Auto vars:     Size  Location     Type
		None
 Return value:  Size  Location     Type
		None               void
 Registers used:
		wreg, status,2
 Tracked objects:
		On entry : 
		On exit  : 
		Unchanged: 
 Data sizes:     COMRAM   BANK0   BANK1   BANK2   BANK3   BANK4   BANK5   BANK6   BANK7
      Params:         0       0       0       0       0       0       0       0       0
      Locals:         0       0       0       0       0       0       0       0       0
      Temps:          0       0       0       0       0       0       0       0       0
      Totals:         0       0       0       0       0       0       0       0       0
Total ram usage:        0 bytes
 Hardware stack levels used:    1
 Hardware stack levels required when called:    2
 This function calls:
		Nothing
 This function is called by:
		_main
 This function uses a non-reentrant model


 *************** function _init_extint *****************
 Defined at:
		line 67 in file "main.c"
 Parameters:    Size  Location     Type
		None
 Auto vars:     Size  Location     Type
		None
 Return value:  Size  Location     Type
		None               void
 Registers used:
		wreg, status,2
 Tracked objects:
		On entry : 
		On exit  : 
		Unchanged: 
 Data sizes:     COMRAM   BANK0   BANK1   BANK2   BANK3   BANK4   BANK5   BANK6   BANK7
      Params:         0       0       0       0       0       0       0       0       0
      Locals:         0       0       0       0       0       0       0       0       0
      Temps:          0       0       0       0       0       0       0       0       0
      Totals:         0       0       0       0       0       0       0       0       0
Total ram usage:        0 bytes
 Hardware stack levels used:    1
 Hardware stack levels required when called:    2
 This function calls:
		Nothing
 This function is called by:
		_main
 This function uses a non-reentrant model


 *************** function _lo_interrupt *****************
 Defined at:
		line 108 in file "main.c"
 Parameters:    Size  Location     Type
		None
 Auto vars:     Size  Location     Type
		None
 Return value:  Size  Location     Type
		None               void
 Registers used:
		wreg, status,2, status,0
 Tracked objects:
		On entry : 
		On exit  : 
		Unchanged: 
 Data sizes:     COMRAM   BANK0   BANK1   BANK2   BANK3   BANK4   BANK5   BANK6   BANK7
      Params:         0       0       0       0       0       0       0       0       0
      Locals:         0       0       0       0       0       0       0       0       0
      Temps:          5       0       0       0       0       0       0       0       0
      Totals:         5       0       0       0       0       0       0       0       0
Total ram usage:        5 bytes
 Hardware stack levels used:    1
 Hardware stack levels required when called:    1
 This function calls:
		Nothing
 This function is called by:
		Interrupt level 1
 This function uses a non-reentrant model


 *************** function _hi_interrupt *****************
 Defined at:
		line 84 in file "main.c"
 Parameters:    Size  Location     Type
		None
 Auto vars:     Size  Location     Type
		None
 Return value:  Size  Location     Type
		None               void
 Registers used:
		wreg, fsr2l, fsr2h, status,2, status,0, prodl
 Tracked objects:
		On entry : 
		On exit  : 
		Unchanged: 
 Data sizes:     COMRAM   BANK0   BANK1   BANK2   BANK3   BANK4   BANK5   BANK6   BANK7
      Params:         0       0       0       0       0       0       0       0       0
      Locals:         0       0       0       0       0       0       0       0       0
      Temps:          4       0       0       0       0       0       0       0       0
      Totals:         4       0       0       0       0       0       0       0       0
Total ram usage:        4 bytes
 Hardware stack levels used:    1
 This function calls:
		Nothing
 This function is called by:
		Interrupt level 2
 This function uses a non-reentrant model



MODULE INFORMATION

Module		Function		Class		Link	Load	Size
shared
		__initializatio		CODE           	7F7E	0000	32

shared estimated size: 32

main.c
		_lo_interrupt  		CODE           	1018	0000	82
		_main          		CODE           	7F3C	0000	12
		_init_timers   		CODE           	7F5C	0000	34
		_init_extint   		CODE           	7F48	0000	20
		_hi_interrupt  		CODE           	1008	0000	28664

main.c estimated size: 28812


BigDog
 

Hi
My problem is that I need to move the code shifted in file2.hex because I have a bootloader in the uc installed. And looking at the xc8 linker options, their is one called codeoffset. But it only shift the 2 first lines to the address you want but the code placed later...I need to generate a .hex like file1.hex with all the code in the beginning and no jumpings. Reading the documentation of xc8 compilar I was not able to see anything useful. I have been playing with the linker option and I did no get anything either...any suggestion?
 

Yes, the previously posted MAP file happens to be for a "loadable" binary, which typically implies it was specifically compiled for a bootloader. You should notice the code is offset to 0x1000 and the region of flash above the offset is reserved with the appropriate linker option. Also, notice both interrupt vectors have been offset as well, from 0x0008 and 0x0018 to 0x1008, 0x1018. A few bytes of storage preceding these interrupt vectors has been reserved as well, to prevent an conflicting code being placed in close proximity to the relocated interrupt vectors.

What is the specific bootloader for which you are compiling the loadable app?


BigDog
 

One way is to copy .lnk file in your project directory and then modify it
I have done this when I wanted a specific segment (defined with #pragma in C file) to placed in specific location.

Look at the .lnk struct, it is self explainable:
Code:
// File: 18f24j10_g.lkr
// Generic linker script for the PIC18F24J10 processor

#DEFINE _CODEEND _DEBUGCODESTART - 1
#DEFINE _CEND _CODEEND + _DEBUGCODELEN
#DEFINE _DATAEND _DEBUGDATASTART - 1
#DEFINE _DEND _DATAEND + _DEBUGDATALEN

LIBPATH .

#IFDEF _CRUNTIME
  #IFDEF _EXTENDEDMODE
    FILES c018i_e.o
    FILES clib_e.lib
    FILES p18f24j10_e.lib

  #ELSE
    FILES c018i.o
    FILES clib.lib
    FILES p18f24j10.lib
  #FI

#FI

#IFDEF _DEBUGCODESTART
  CODEPAGE   NAME=page       START=0x0               END=_CODEEND
  CODEPAGE   NAME=debug      START=_DEBUGCODESTART   END=_CEND        PROTECTED
#ELSE
  [COLOR="#FF0000"]CODEPAGE   NAME=page       START=0x0               END=0x3FF7[/COLOR]
#FI

[COLOR="#FF0000"]CODEPAGE   NAME=config     START=0x3FF8            END=0x3FFD         PROTECTED
CODEPAGE   NAME=devid      START=0x3FFFFE          END=0x3FFFFF       PROTECTED[/COLOR]
 

Hi guys,

This is the expression which shift the complete code:

temp= log(temp_fpa1_t2);

Anybody know why this is happening? And how to solve it? I tired all the linker XC8 option and there is not way to move the code to starting position....Only when I remove the before expression, the program is moved to the starting position.

One way is to copy .lnk file in your project directory and then modify it
I have done this when I wanted a specific segment (defined with #pragma in C file) to placed in specific location.

Look at the .lnk struct, it is self explainable:
Code:
// File: 18f24j10_g.lkr
// Generic linker script for the PIC18F24J10 processor

#DEFINE _CODEEND _DEBUGCODESTART - 1
#DEFINE _CEND _CODEEND + _DEBUGCODELEN
#DEFINE _DATAEND _DEBUGDATASTART - 1
#DEFINE _DEND _DATAEND + _DEBUGDATALEN

LIBPATH .

#IFDEF _CRUNTIME
  #IFDEF _EXTENDEDMODE
    FILES c018i_e.o
    FILES clib_e.lib
    FILES p18f24j10_e.lib

  #ELSE
    FILES c018i.o
    FILES clib.lib
    FILES p18f24j10.lib
  #FI

#FI

#IFDEF _DEBUGCODESTART
  CODEPAGE   NAME=page       START=0x0               END=_CODEEND
  CODEPAGE   NAME=debug      START=_DEBUGCODESTART   END=_CEND        PROTECTED
#ELSE
  [COLOR="#FF0000"]CODEPAGE   NAME=page       START=0x0               END=0x3FF7[/COLOR]
#FI

[COLOR="#FF0000"]CODEPAGE   NAME=config     START=0x3FF8            END=0x3FFD         PROTECTED
CODEPAGE   NAME=devid      START=0x3FFFFE          END=0x3FFFFF       PROTECTED[/COLOR]
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top