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

#device ANSI

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



Joined: 17 Jun 2019
Posts: 563
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

#device ANSI
PostPosted: Wed Feb 26, 2020 2:46 pm     Reply with quote

Here is what CCS reports using "#device ANSI" does (it includes a few things not listed in the PDF manual):

Default signed.

Default case sensitive.

Default overloading allowed.

const is treated as readonly, not our special rom thing.

All RAM is zeroed at the start of main().

Not sure what "default signed" implies. I did some tests, and "int/char/int16/etc." all appear to be signed in default (CCS4?) mode. Also, function overloads seem to be supported without specifying ANSI.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
allenhuffman



Joined: 17 Jun 2019
Posts: 563
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Feb 26, 2020 3:08 pm     Reply with quote

Quote:
All RAM is zeroed at the start of main().


I did a quick test with this and confirmed it works. I looked for a way to do this without using ANSI and found:

Code:
#zero_ram
void main()


Do that and it clears memory before it runs. The details say:

Quote:
This directive zero's out all of the internal registers that may be used to hold variables before program execution begins.


...registers? But it does appear to clear RAM as the name says.

Update: And there is also #zero_local_ram, which just zeros out any uninitialized variables. This can generate much larger code than just clearing the entire memory, but may be useful if you are trying to keep some memory preserved between code restarts.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?


Last edited by allenhuffman on Wed Feb 26, 2020 3:57 pm; edited 1 time in total
allenhuffman



Joined: 17 Jun 2019
Posts: 563
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Feb 26, 2020 3:13 pm     Reply with quote

Quote:
Default case sensitive.

Using:
Code:
#case

Will give you this without using ANSI.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?


Last edited by allenhuffman on Wed Feb 26, 2020 3:16 pm; edited 1 time in total
allenhuffman



Joined: 17 Jun 2019
Posts: 563
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Feb 26, 2020 3:15 pm     Reply with quote

Quote:
const is treated as readonly, not our special rom thing.

Likely, this will do the same thing w/o using ANSI:
Quote:
#device CONST=READ_ONLY

Uses the ANSI keyword CONST definition, making CONST variables read only, rather than located in program memory.

_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 26, 2020 3:16 pm     Reply with quote

16/18 series PICs, CCS defaults int8 to unsigned

from the manual 'data defintions, basic types'..
...Data is always positive. This is the default data type if not specified.

Pretty sure with PIC24s, the default is signed.... though I don't use PIC24s.

re: ZERO RAM, yes only affects RAM not SFRs.... Microchip tend to think of 'where stuff is stored' as 'registers'. RAM is also called GPR, or General Purpose Registers.
allenhuffman



Joined: 17 Jun 2019
Posts: 563
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Feb 26, 2020 3:18 pm     Reply with quote

temtronic wrote:
16/18 series PICs, CCS defaults int8 to unsigned


Thanks for the clarification. I notice manual sections will say [PCD] by some items. I believe that is what I am using (About says so) but I wondered if there was something that specified changes between PIC18/PIC24/PIC32/etc. I should be watching out for.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 26, 2020 5:14 pm     Reply with quote

Compiler version is based on PIC series....need to look at CCS site for what's what...

I know there's differences, size of words, default types, etc. but I'm sticking to PIC18F46K22s as my 'Swiss Army Knife' PIC. Too old to play with multiple PICs though at one time I was fluent with Z80 ASM, 68HC11 ASM, Intel 80C32 AMS/BASIC, 1802 ASM and 705KICS.....yeesh, that's only the ones I can name offhand....
I do have some Intel 8008s here...
one day I need to order a big bin.....
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