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

Used memory test

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



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

Used memory test
PostPosted: Thu Feb 22, 2007 6:02 am     Reply with quote

Hello super-forum.
I'am going to selecting a processor for a project and have a program in a size about 3-4 kB. We have tried to compile the C-program with processor PIC16F688 and with PIC18F1320.
PIC16F688 result = 3142 bytes
PIC18F1320 result = 4842 bytes
We thought that the PIC18 will use less program memory because of itīs structure
(no page shift needed an so on)
(The compiler is a CCS type but not the newest one)

Do you know why this bad result with PIC18?
or
have you any experience of this type of test?
Ttelmah
Guest







PostPosted: Thu Feb 22, 2007 7:59 am     Reply with quote

First question. Do you use interrupts?. If so, the handlers for these will be significantly larger (there are a lot more registers that have to be saved...).
Second question. How old is the compiler?. Basically, the early PIC18 releases, very much used 16 code, with tweaks. Extra optimisations for the 18 were latter added and improved. Code sizes for 18 projects markedly dropped as the V3 compilers developed.
Third question. Do you use arithmetic?. The internal hardware multiply, is one of the biggest savings, but if not used, then improvements from here won't be large.
Now, it is worth also realising that some of the 'improved' instructions, don't save anything in space. For instance, the MOVFF instruction, which allows data to be moved from one place to another, without using W. Though it is a single instruction, it uses two words of instruction memory...The same applies with the direct memory accessing. Instructions to use this are larger. Finally, there will be significantly more 'initialisation' overhead on the 18 chip. Generally, every extra peripheral, increases the amount of code needed for this.
Because of all these, the bigger chips, will tend to use memory more slowly as new functions are added, but use more memory for smaller programs.

Best Wishes
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Feb 22, 2007 8:50 am     Reply with quote

Quote:
PIC16F688 result = 3142 bytes
PIC18F1320 result = 4842 bytes

Did you notice that the list file for the PIC16 mentions the number of instruction words (14 bits) while the list file for the PIC18 displays the number of bytes (8 bits)?
Are your given numbers already corrected for this difference?
Mortenc



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Thu Feb 22, 2007 11:13 am     Reply with quote

Dear ckielstra,

Many thanks to you,
It was just the different in the list file "words" in PIC16F688
and "bytes in PIC18F1320.
Sorry my bad knowledge of C yet.
I was also wondering why one normal assembly instruction was counting 2 on the programlines in the list file of PIC18, but only 1 program line in the PIC16. (why this confussion?)
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Feb 22, 2007 11:50 am     Reply with quote

Mortenc wrote:
I was also wondering why one normal assembly instruction was counting 2 on the programlines in the list file of PIC18, but only 1 program line in the PIC16. (why this confussion?)
Same reason, bytes versus words.
An instruction in the PIC has always a size of 1 or more words (14 or 16 bits). In the PIC16 you can only address a complete word but the PIC18 is more advanced and allows you to address the individual bytes.

In the PIC16 the program counter counts up with 1 word (14 bits) for each instruction. In the PIC18 the program counter counts up by 2 bytes for each instruction.
Mortenc



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Thu Feb 22, 2007 2:53 pm     Reply with quote

Well, thanks again,
I like this forum - It has been a good day - I learn something.
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