CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to use the #locate directive

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dmitrboristuk



Joined: 26 Sep 2020
Posts: 55

View user's profile Send private message

How to use the #locate directive
PostPosted: Thu Jul 29, 2021 1:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 29, 2021 1:29 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 29, 2021 1:54 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group