gcc executable size vs. target hex file size?

S

scrodchunk

I'm currently building a project in the gcc environment on unix and
getting the simulation phase of my work done. After it's nice and
clean, I'll be moving into an embedded environment and compiling the
code for my chosen target (not sure what it is yet, but an 8-bit
machine like an AVR or 'HC11);

Can anyone offer a sense of how big gcc compiled executables are
relative to final target hex files?? That is, if my executable in the
unix environment is 20k, will I need 20k of flash on my target device
for the same code?
 
J

Jack Klein

I'm currently building a project in the gcc environment on unix and
getting the simulation phase of my work done. After it's nice and
clean, I'll be moving into an embedded environment and compiling the
code for my chosen target (not sure what it is yet, but an 8-bit
machine like an AVR or 'HC11);

Can anyone offer a sense of how big gcc compiled executables are
relative to final target hex files?? That is, if my executable in the
unix environment is 20k, will I need 20k of flash on my target device
for the same code?

Try or one of the gnu.gcc groups. This is not
something defined by the language and totally off-topic here.
 
S

Stephen L.

scrodchunk said:
I'm currently building a project in the gcc environment on unix and
getting the simulation phase of my work done. After it's nice and
clean, I'll be moving into an embedded environment and compiling the
code for my chosen target (not sure what it is yet, but an 8-bit
machine like an AVR or 'HC11);

Can anyone offer a sense of how big gcc compiled executables are
relative to final target hex files?? That is, if my executable in the
unix environment is 20k, will I need 20k of flash on my target device
for the same code?

Why don't you just build it for the target
and see... Are you using any libraries
(standard or otherwise) that may not exist
on your target architecture?

Without seeing _any_ of your code it's hard
to guess. Did you code your simulation code
with consideration for the final target
architecture (did you use ints when all you
may have needed was a bit)? Does the target
really support standard `C', or is gcc
just a fast hand-assembler for your project.

Some of these smaller architectures with their
small memory byte-size and limited number of
available registers really have a difficult time
with 32-bit quantities of _anything_. On a 32-bit
architecture, moving a 32-bit value can usually
be done in one or two assembly instructions
taking 4 to 8 bytes. An 8-bit architecture
might require 4-6 bytes PER byte moved (between
16 and 24 bytes total) because they can
only move 8 bits at a time.

Don't forget about stack size considerations, etc.

But on the up side, if you think about the
embedded architecture during development,
sometimes the code can be significantly smaller...


HTH,

-
Stephen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top