Searching \ for '[PIC] Help with MPLINK' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Help with MPLINK'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Help with MPLINK'
2004\10\06@101640 by John J. McDonough

flavicon
face
>From time to time, I write code that needs to be in the first page of
program memory.

I can, of course, specify the addresses for each routine, but that makes
reuse difficult, and makes it impossible to build a reasonable library
containing these routines.  I have taken to adding a special section for
these routines in the linker script, but that approach seems clumsier than
necessary.

What are other people doing to solve this problem?  Is there a "standard"
approach?  Is there something buried in the documentation that I've
overlooked?

--McD


_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\06@110617 by Alan B. Pearce

face picon face
>>From time to time, I write code that needs to
>>be in the first page of program memory.

Why does it need to be in the first page?? With the linker it is easy to
write the code so it is modular, and only the interrupt code ends up "having
to be" in the first page for maximum execution speed.

To help with this I would recommend you look seriously at Olin's development
environment, available at http://www.embedinc.com/pic/ and follow how he
sets up the modules. The environment also contains a very useful macro file
which has a whole heap of macros related to paging and banking, and making
the hassles of changing these almost disappear.

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\06@110922 by Jan-Erik Soderholm

face picon face
John J. McDonough wrote :

> > From time to time, I write code that needs to be in the first page of
> > program memory.

I'm not sure who wrote that, since it had an ">" in front of it
and seemed to be a quote.

> I can, of course, specify the addresses for each routine, but
> that makes reuse difficult, and makes it impossible to build a
> reasonable library containing these routines.  I have taken to
> adding a special section for these routines in the linker script,
> but that approach seems clumsier than necessary.

That are the two ways I know of.

> What are other people doing to solve this problem?

I must have mised the first part of the thread. What problem ?
(That is, not how to put code in the first page, but the problem you
are solving by doing so...)

Regards,
Jan-Erik.
_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\06@115001 by John J. McDonough

flavicon
face
----- Original Message -----
From: "Jan-Erik Soderholm" <spam_OUTjan-erik.soderholmTakeThisOuTspamtelia.com>
Subject: RE: [PIC] Help with MPLINK


> I'm not sure who wrote that, since it had an ">" in front of it
> and seemed to be a quote.

I don't know where that came from.  Occasionally I see weird things in the
front of my emails lately.  That's the first time I've seen a '>' that
wasn't intended.

> I must have mised the first part of the thread. What problem ?
> (That is, not how to put code in the first page, but the problem you
> are solving by doing so...)

I was specifically concerned about using object files and the linker.
Obviously, when you are writing absolute code, you specify where everything
is, and that is that.  But when you are writing relocatable code, it does
seem sort of annoying to have to specify absolute addresses any more than
necesary.

It also got me wondering whether I have any control over whether the linker
assigns locations that straddle page boundaries.  Generally, I'm using page
zero to avoid having to fiddle with page bits when I'm doing table lookups.
Yes, I know it's not a lot of code, it's just the hassle factor.  But why go
to the trouble if the linker might just place a 50 word table at address 2F0
for example.

--McD


_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\06@134656 by Jan-Erik Soderholm

face picon face
John J. McDonough wrote :

> From: "Jan-Erik Soderholm" <.....jan-erik.soderholmKILLspamspam@spam@telia.com>
>
> > I must have mised the first part of the thread. What problem ?
> > (That is, not how to put code in the first page, but the problem you
> > are solving by doing so...)
>
> I was specifically concerned about using object files and the linker.

Yes, that was clear :-)

> Obviously, when you are writing absolute code, you specify
> where everything is, and that is that.  But when you are writing
> relocatable code, it does seem sort of annoying to have to
> specify absolute addresses any more than necesary.

That is what "relocatable" stands for.

> It also got me wondering whether I have any control over
> whether the linker assigns locations that straddle page
> boundaries.

I think that the linker sees each section in the LNK file
as a continous area, with no concern about page boundaries.

(And besides,  a "location" can not, by definition, straddle page
boundaries...)

> Generally, I'm using page zero to avoid having
> to fiddle with page bits when I'm doing table lookups.

You mean you put the actual tables in page 0 ?
Or the actual code doing the lookup ?
Or both ?

And besides, *any* page whould probably be fine, as long as
the whole table is in the *same* page.

> Yes, I know it's not a lot of code, it's just the hassle
> factor.  But why go to the trouble if the linker might just
> place a 50 word table at address 2F0 for example.

Yes, personaly I don't find it to be a major problem to specify
absolute adresses for tables. Just put them where they become
easiest to use. The linker wil then "wrap" all other (executable)
code neatly around those tables. Or fill in the holes, so to speak.

But, as you say, it *is* possible to write table-read code (we are
talking about the "old" retlw-type tables, right ?) that handles
tables crossing page boundaries.  There is an app note that
describes that at Microchip  (the textual description is OK, but
the code example have bugs...)

Jan-Erik.

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\06@141019 by Mark Scoville

flavicon
face
I'm new to this list so I hope this makes it to the right place!

Yes you can avoid having the linker place code that straddles a page
boundary. I do this all the time. In the linker file you need to define a
codepage that is one page in length (or shorter)...

Example excert from (.LKR) linker file...

CODEPAGE   NAME=vectors   START=0x0      END=0x27     PROTECTED
CODEPAGE   NAME=page0     START=0x28     END=0xFF
CODEPAGE   NAME=page1     START=0x100    END=0x1FF    PROTECTED
CODEPAGE   NAME=page      START=0x200    END=0x0FFF
CODEPAGE   NAME=config    START=0xFE00   END=0xFE0F   PROTECTED

SECTION    NAME=JMPTBL   ROM=page1

The 3rd CODEPAGE line 'defines' an area of memory from 0x100 to 0x1FF and
gives it the name "page1"
The SECTION line tells the linker to put any code modules named JMPTBL in
page1

Then in the .ASM file you need to name the code areas like so...
JMPTBL        CODE

Then any code after the "JMPTBL CODE" directive will be placed between 0x100
and 0x1FF. Using this method gives you very good control over where the
linker puts things. If you simply start your code segments like so (without
the name )...

       CODE

       'code starts here'

Then the linker will stick the code in any unprotected codepage it finds.


Typically I have some things in a .ASM  file which I don't care about page
boundarys and some things I do care. So I write the code like so...

JMPTBL        CODE

       'Stuff that I don't want straddling a boundary (ends up at 0x100 to 0x1FF)'


               CODE

       'Other stuff that I don't care about page boundaries (ends up in one of the
unprotected codepages)'




This is covered in the MPLINK manual, but it does take some thinking about
it before it all makes sense.

I suggest you lookup the CODE directive in the MPASM manual, and also the
CODEPAGE and SECTION directives in the MPLINK manual.

Clear as mud?

-Mark


_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\06@162504 by John J. McDonough

flavicon
face
----- Original Message -----
From: "Mark Scoville" <mscovillespamKILLspamunicontrolinc.com>
Subject: RE: [PIC] Help with MPLINK


> Yes you can avoid having the linker place code that straddles a page
> boundary. I do this all the time. In the linker file you need to define a
> codepage that is one page in length (or shorter)...

Thanks, Mark.  I actually figured that out earlier today.  I tried all kinds
of things without success.  Of course, since I hadn't done it before I
imagined all sorts of possible limitations and the linker error messages
were less than helpful. That all helped me overlook the obvious for a few
hours ... I couldn't spell NAME!

But now it's working, and it makes sense, and it's exactly the sort of
behavior I would have hoped for.

It took me a while to get back to the list because I had to process one of
those dreaded honeydew expeditions.

--McD


_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

More... (looser matching)
- Last day of these posts
- In 2004 , 2005 only
- Today
- New search...