View previous topic :: View next topic |
Author |
Message |
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
How to use the #locate directive |
Posted: Thu Jul 29, 2021 1:09 am |
|
|
How to use the #locate directive to work with int1 and int16 format variables. Is it possible to place variables in bank-independent registers 0x70 - 0x7F to work in critical sections of the program. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Thu Jul 29, 2021 1:29 am |
|
|
You can't use this with int1. An int1, occupies one bit of a memory location,
not a location itself.
Int16, yes, but with 'caveats' depending on the chip involved. Remember
n PIC24/33 etc. chips, int16's must reside on even memory locations. Though
your reference to 0x70 to 7F, suggests you are on a PIC16.
Beware though. The compiler will be using some of the 0x70 to 7F area
for it's own scratch variables to help with handling these, so you may
lose more than you gain.
Remember you have to generate the variables first, before you #locate
them.
Code: |
int16 value;
#locate value=0x70
int16 second;
#locate second=0x72;
|
If you don't declare the variables first, it can only generate an int8. |
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Thu Jul 29, 2021 1:54 am |
|
|
Thanks. Do I understand correctly that the bank-independent registers used by the BIF are marked with @, for example, for the Delay_ms () subroutine, I find in the assembler code @078, @079, @07A |
|
|
|