On Tue, 10 Aug 1999, Jouni Mannonen wrote:

> Having just finished my latest app for Palm Pilot (Pocket SCORCH, game
> of the Scorched Earth style tank combat), space on a single 32K segment
> gets tight.
> 
> Are there any special GCC command line flags (anything specifically good 
> for Palm?) to make the compiler create code with less bloat? For what
> difference it makes, I'm compiling with C++ but in this one the code is
> rather simple and doesn't do virtual functions or anything tricky.

For gcc, the -O (-O1, inlines and a few things -O2 and -O3, maximum)
controls the level of optimization.  It varies by processor.  1-3 is the
range for Palm apps.  There are also a series of specific optimizations.
Further, strings (and most other global data) are initialized from the
code segment so it is better to store these as resources.

Also, you can inline certain functions (won't work with -O0).  Somewhere
on my web page (www.execpc.com/~tz) I have several apps which use
"stringil.h" which is my string function inlining library.  An excerpt
follows:

/* linux (posix?) says val should be an int */
#include <string.h>
#define VALT char

extern inline void *memset(void *dst, VALT val, size_t num)
{
  register void *ds = dst;
  while (num--)
    *((char *) dst)++ = val;
  return ds;
}

extern inline void *memcpy(void *dst, const void *src, size_t num)
{
  register void *ds = dst;
  while (num--)
    *((char *) dst)++ = *((char *) src)++;
  return ds;
}

This will run faster but might increase the size somewhat.

>From the limited tests I have done, GCC and CW both optimize well - so
shifting to CW won't necessarily help except it can do multisegment (but
the segment limit is 64K, but you have to order functions so no two are
more than 32K away call-to-entry point).

There may be other tricks you can do to speed things up, but I would have
to know more about your code.

Reply via email to