How do I specify certain addresses to not be banked?

View: New views
4 Messages — Rating Filter:   Alert me  

How do I specify certain addresses to not be banked?

by Jesse Gordon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greetings. This is my first post - so please be patient as I learn the
ropes. Thanks!

I'm working with an 18f1220.

I wish to use bank 1 for my main code, and bank 2 for my low priority
ISR so they can have each plenty of non-shared ram.

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."

Let me explain:

PORTA, for example, is defined as:
PORTA           EQU  H'0F80'

Let's say I then do a:
CLRF PORTB
the assembler (gpasm-0.13.4 beta) does (and should) clear the access bit
so the CLRF will always operate on 0x80 in bank zero.

Thus, no matter what bank is currently set in BSR, a CLRF on PORTA will
always hit bank 0...

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?

That way, whenever I do an operation on MyGlobalByte, it would always
(without me having to specify ",0") access 0x01 in bank 0.

Surely I can go change some line in some file to make it do that task
for the range of 0xF00-0xFFF since it already does it for 0xF80-0xFFF.

Thank you very much,

-Jesse


---------------------------------------------------------------------
To unsubscribe, e-mail: gnupic-unsubscribe@...
For additional commands, e-mail: gnupic-help@...


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

by Raphael Neider-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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: gnupic-unsubscribe@...
For additional commands, e-mail: gnupic-help@...


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

by Jesse Gordon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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: gnupic-unsubscribe@...
> For additional commands, e-mail: gnupic-help@...
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: gnupic-unsubscribe@...
For additional commands, e-mail: gnupic-help@...


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

by Tamas Rudnai :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <jesseg@...> 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: gnupic-unsubscribe@...
>> For additional commands, e-mail: gnupic-help@...
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: gnupic-unsubscribe@...
> For additional commands, e-mail: gnupic-help@...
>
>


--
http://www.mcuhobby.com