Hi I've just got back to work, and read this email Very useful, thank you. Cheers, Mark > -----Original Message----- > From: piclist-bounces@mit.edu > [mailto:piclist-bounces@mit.edu]On Behalf > Of Ken Pergola > Sent: 08 October 2004 17:46 > To: Microcontroller discussion list - Public. > Subject: RE: [PIC]Splitting assemblies in to multiple files > > > > Some clarifications: > > > Ken Pergola was wrong in writing: > > > Please note that you cannot use the 'ORG' directive in > > code targeted for the linker. > > > I should have said that you most likely will never need to use the ORG > directive in code targeted for the linker. > > The ORG directive will compile in code targeted for the > linker, and although > I personally never use the 'ORG' directive in my linker-based > code, it is > legal: > > > >From MPLAB IDE's online help: > > ===== > When generating an object file, the org directive is interpreted as > introducing an absolute CODE section with an internally > generated name. For > example: > > L1: org 0x200 > is interpreted as: > > .scnname CODE 0x200 > L1: > where .scnname is generated by the assembler, and will be > distinct from > every name previously generated in this context. > ==== > > > > Jan-Erik wrote: > > > code_reset code h'0000' > > goto main > > > > code_isr code '0008' > > your ISR code > > > > then later (anyware actualy) : > > > > code_main code ; no address needed. > > > > main do-whatever... > > > > Note that "code_isr" and "code_main" are not labels, they > > are names of the code sections in the source. > > > Just to add what Jan-Erik said, the text name or label > *before* the CODE > directive does not *have* to be a reference to a SECTION NAME > defined in the > linker script file. I feel it is very important to know this. > > > 1) You can use a SECTION NAME if you need that functionality > and need to > place code in that code section referenced by the section > name in the linker > script, or, you can just use a label so that in the MAP file > you will see > this label as a meaningful name under the 'Section' heading. > > 2) If that label is not a section name defined in your linker > script file, > MPLINK will place the code anywhere it sees fit. > > 3) You also have the choice of NOT putting a label in front > of the CODE > directive -- if you do this, MPLINK generates a name for you > in the MAP file > for that particular code section. > > > > For example, I don't even like to supply absolute addresses > in my reset and > ISR source code when I use the linker (I prefer to keep all > this in the > linker file to reduce editing absolute addresses in my source file): > > > > ResetVector CODE > . > . > . > > Main_code CODE > . > . > . > > InterruptVector_HighPri CODE > . > . > . > > InterruptVector_LowPri CODE > > . > . > . > > > > > 'Main_code', 'InterruptVector_HighPri' and > 'InterruptVector_HighPri' are a > SECTION NAMEs that I defined in the linker script file. > > > CODEPAGE NAME=ResetVector START=0x000000 END=0x000007 > CODEPAGE NAME=IntVectorHiPri START=0x000008 END=0x000017 > CODEPAGE NAME=IntVectorLoPri START=0x000018 END=0x000027 > CODEPAGE NAME=ApplicationCode1 START=0x000028 END=0x0065FF > > > SECTION NAME=Main_code ROM=ApplicationCode1 > SECTION NAME=ResetVector ROM=ResetVector > SECTION NAME=InterruptVector_HighPri ROM=IntVectorHiPri > SECTION NAME=InterruptVector_LowPri ROM=IntVectorLoPri > > > > Note that all labels before the CODE directive above are > actually the names > SECTIONs in the linker script. However, I do have some code > sections in > which I do not want to reference a specific SECTION in the > linker script -- > I want the linker to automatically allocate it, but I also > want to see a > meaningful name for that code section in the MAP file: > > > In those instances I just do this: > > > Messaging_code CODE > > > 'Messaging_code' is just a label of my choosing and it is NOT > a SECTION name > in this case -- it appears in the MAP file like this: > (hopefully the formatting below does not get mangled) > > > Section Info > Section Type Address Location Size(Bytes) > --------- --------- --------- --------- --------- > ResetVector code 0x000000 program 0x000008 > InterruptVector_HighPri code 0x000008 program 0x000002 > InterruptVector_LowPri code 0x000018 program 0x000002 > Main_code code 0x000028 program 0x0000b4 > Messaging_code code 0x003f76 program 0x00007e > > > If I decided not put that 'Messaging_code' label in front of the CODE > directive and just use the 'CODE' directive by itself, the > MAP file listing > would be different: > > Section Info > Section Type Address Location Size(Bytes) > --------- --------- --------- --------- --------- > ResetVector code 0x000000 program 0x000008 > InterruptVector_HighPri code 0x000008 program 0x000002 > externalLatch_code code 0x00000a program 0x00000e > InterruptVector_LowPri code 0x000018 program 0x000002 > .code code 0x003f76 program 0x00007e > > > > See how using 'Messaging_code CODE' in your source code creates a > meaningful section name in the MAP file? 'Messaging_code' > versus '.code' > (which MPLINK generated). > > > I hope this is helpful. > > Best regards, > > Ken Pergola > > > > > > > > > > > > > > > > > > > > > > Best regards, > > Ken Pergola > > > > > > > > > > > > > > > > > > _______________________________________________ > http://www.piclist.com > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > ============================================================================== This message is for the sole use of the intended recipient. If you received this message in error please delete it and notify us. If this message was misdirected, CSFB does not waive any confidentiality or privilege. CSFB retains and monitors electronic communications sent through its network. Instructions transmitted over this system are not binding on CSFB until they are confirmed by us. Message transmission is not guaranteed to be secure. ============================================================================== _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist