gnupic: Re: [gnupic] How do I specify certain addresses to not be banked?


Previous by date: 14 Sep 2009 12:13:50 -0000 Re: [gnupic] How do I specify certain addresses to not be banked?, Jesse Gordon
Next by date: 14 Sep 2009 12:13:50 -0000 Lightweight distros with GPUTILS in repository, Jason Hsu
Previous in thread: 14 Sep 2009 12:13:50 -0000 Re: [gnupic] How do I specify certain addresses to not be banked?, Raphael Neider
Next in thread:

Subject: Re: [gnupic] How do I specify certain addresses to not be banked?
From: Tamas Rudnai ####@####.####
Date: 14 Sep 2009 12:13:50 -0000
Message-Id: <492f1420909140513n5d50a882o2d9c3778d8e14651@mail.gmail.com>

It is better to use linker scripts and proper variable occupation with 'RES'
directive.

Anyway, it is also a common technique that you use a dedicated bank as a
"register area" or "temp bank" where the bank selection always points to
this area, and then use MOVFF to load the variables to this temporary area
before making any operation on it. For example if you need to do a long
calculation with several variables located in many different banks it is
better to move them to this "register area" and do all the calculations then
store the results back to it's original location. It is pretty much the same
as you were using a register architecture, and you can save CPU time and
program memory by this technique.

One another technique of course is to use the shared area for globals and
function parameters and each one of the program block use one particular
bank for it's locals (which the can be overlapped/overlayed with other
modules). Then at the module prolog you need to do a context saving and a
bank selection, then at the epilogue a context restore.

Which one is to use really depends on the application, and you can save on
banking quite a lot by choosing the right one.

Tamas



On Sun, Sep 13, 2009 at 5:39 PM, Jesse Gordon ####@####.#### wrote:

> Hi Raphael,
>
> Thank you very much. You were most helpful!
>
> Actually, I was, for some reason, under the impression that the banked bit
> was set by default in the assembler - but I see now that for addresses 0-7f
> it is not set - which is exactly and perfectly what I want!
>
> Then for my non-"globals" I can just define them with EQU 0x1xx and they
> will all use the current bank select.
>
> Thank you very much!
>
> -Jesse
>
> Raphael Neider wrote:
>
>> Hi Jesse,
>>
>>  And I wish to use the first half of bank 0 as "global" vars in the same
>>> way that the second half (the SFRs) are "global."
>>>
>>>  [>>snip<<]
>>
>>> So, here is the question: How can I make some of my own ram locations
>>> also always be accessed in bank 0 without me having to specify the ",0" on
>>> every file instruction?
>>>
>>> For example, if I do:
>>>
>>> MyGlobalByte   EQU   0xF01
>>>
>>> As it is, the assembler just drops the F00 part and a CLRF on
>>> MyGlobalByte will clear byte 1 in the currently selected bank. Why can't the
>>> assembler see that I've specified 0xF01 and automatically clear the
>>> use-bank-selected bit - Just like it does for addresses above 0xF80?
>>>
>>
>> The PICs have an access bank, which is split into general purpose
>> registers (often 0x00 - 0x7F, sometimes 0x00 - 0x5F) and special
>> function registers (0x80 - 0xFF, which are mapped to 0xF80 - 0xFFF,
>> sometimes 0x60 - 0xFF, remapped to 0xF60 - 0xFFF). The split point
>> is defined by Microchip and cannot be changed.
>> You can use
>>
>> MyGlobalByte EQU 0x001
>> ...
>> MyGlobalByte EQU 0x07F
>> SFR0xF80     EQU 0xF80
>> ...
>> SFR0xFFF     EQU 0xFFF
>>
>> and gpasm (knowing the memory layout of the target device) will
>> access these via the access bank. All other memory locations
>> (0x80 - 0xF7F) will use banked access - so use proper BANKSEL
>> directives where needed.
>>
>> Hope that helps,
>> Raphael
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ####@####.####
>> For additional commands, e-mail: ####@####.####
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
>
>


-- 
http://www.mcuhobby.com

Previous by date: 14 Sep 2009 12:13:50 -0000 Re: [gnupic] How do I specify certain addresses to not be banked?, Jesse Gordon
Next by date: 14 Sep 2009 12:13:50 -0000 Lightweight distros with GPUTILS in repository, Jason Hsu
Previous in thread: 14 Sep 2009 12:13:50 -0000 Re: [gnupic] How do I specify certain addresses to not be banked?, Raphael Neider
Next in thread:


Powered by ezmlm-browse 0.20.