Greetings again,
As I get more comfortable writing programs for PIC MCUs in both Assembly and C, I have come to notice one thing that bothers me. It seems that programs written in the C language take up a whole lot more program memory space than do programs which are written in Assembly.
To be clear and specific, my setup includes MPLAB IDE with MPASM for assembler programs, and MPLAB IDE with High-Tech PICC-Lite compiler for C programs.
As I started to notice this huge discrepancy between the program size between the 2 languages, I did an experiment. I took a program I had written in assembler and I rewrote it using C. With a PIC12F629 which has 1K program memory size, my assembler program uses a little over 580 words. The same program written for the same MCU in C cannot even be fully written before I use all 1K words. As a matter of fact, I'm barely halfway through writing the program in C.
That being said, here are my questions:
1. Is the overwhelming size of the C program a result of using the "lite" version. I know that there is a notice when I compile that says something along the lines of Omniscient code-generation is not available in the "lite" mode, and that my program could be 40% smaller. So okay, there's something, but still, the Assembler version uses 580 words, or a little over half the program memory, I get ~50% of the program written in C before I'm out of space, even if that was reduced by 40%, I still would be pushing 100% memory usage with a completed program. This furthers my speculation that C uses more space than assembler.
2. I could also speculate that perhaps I'm just not a very efficient C programmer, and maybe that's why my C program is so large. I could understand this considering I'm pretty noob to programming in general. I realize that no one can really verify or discredit this speculation without me posting some sort of code example, and I'm sorry to say that I cannot right now since I'm not on my own computer. If it's important to you though, I can post something later.
3. Is there a way (other than buying the pro version of High-Tech PICC) to reduce the size of my C programs while still accomplishing the same tasks? C programming seems so much easier than writing in assembly and takes far less time. Assembly seems quite cumbersome to me.
Thank you for all the time you folks put in to helping me.
As I get more comfortable writing programs for PIC MCUs in both Assembly and C, I have come to notice one thing that bothers me. It seems that programs written in the C language take up a whole lot more program memory space than do programs which are written in Assembly.
To be clear and specific, my setup includes MPLAB IDE with MPASM for assembler programs, and MPLAB IDE with High-Tech PICC-Lite compiler for C programs.
As I started to notice this huge discrepancy between the program size between the 2 languages, I did an experiment. I took a program I had written in assembler and I rewrote it using C. With a PIC12F629 which has 1K program memory size, my assembler program uses a little over 580 words. The same program written for the same MCU in C cannot even be fully written before I use all 1K words. As a matter of fact, I'm barely halfway through writing the program in C.
That being said, here are my questions:
1. Is the overwhelming size of the C program a result of using the "lite" version. I know that there is a notice when I compile that says something along the lines of Omniscient code-generation is not available in the "lite" mode, and that my program could be 40% smaller. So okay, there's something, but still, the Assembler version uses 580 words, or a little over half the program memory, I get ~50% of the program written in C before I'm out of space, even if that was reduced by 40%, I still would be pushing 100% memory usage with a completed program. This furthers my speculation that C uses more space than assembler.
2. I could also speculate that perhaps I'm just not a very efficient C programmer, and maybe that's why my C program is so large. I could understand this considering I'm pretty noob to programming in general. I realize that no one can really verify or discredit this speculation without me posting some sort of code example, and I'm sorry to say that I cannot right now since I'm not on my own computer. If it's important to you though, I can post something later.
3. Is there a way (other than buying the pro version of High-Tech PICC) to reduce the size of my C programs while still accomplishing the same tasks? C programming seems so much easier than writing in assembly and takes far less time. Assembly seems quite cumbersome to me.
Thank you for all the time you folks put in to helping me.