> here as this is not the point here - it's a WIP.  The point is that SDCC
> seems to be producing code that is extremely bloated.  There's really not
> too much going on in this code but yet the .asm seems to be be very large
> for what it is.
> 
> Is this normal for SDCC?

I scimmed through the .asm code, and it does not look too bad: SDCC
could do better on BANKSELs (or B[CS]F STATUS,[56] instructions), but
without pinning the variables to compiler-known memory banks, the
relocatable object file generation and linking approach cannot be as
efficient as other compilers (such as CCS's), which basically require
the whole project to be contained in a single .c file, so that the
compiler can create and optimize the memory map. [Huh, what a sentence,
sorry.] The SDCC approach would require significant work in the linker
to be done...

Related to BANKSELs, conditional branches could also be more efficient
by replacing SKIP cond; GOTO A; BANKSEL r; <assign r>; A: <continue>
with (BANKSEL r;)? SKIP !cond; <assign r> <continue>.

Apart from this, I do not see a significant number of overly complicated
code constructs... So I guess some code bloat is just "normal". Still,
specific hints for improvement are always welcome.

> Is there something I am doing wrong here during compilation? E.g. Linking in
> a library that I shouldn't be?

Code from the libraries is not taken into the .hex file unless it
(1) resides in a file which provides >=1 required symbol (that's why
    most library .c files only provide a single function), or
(2) is transitively required by already linked in code.
So it does not matter if you specify -llargelib.lib unless you actually
use >=1 symbol from the library. Printf always is a good candidate to
enlarge your program; so is floating point arithmetics ;-)

> Is there a way I can reduce the code.  As I said in an earlier posting,
> using PCW a friend has managed to produce a .hex file of 175 bytes as
> opposed to the 820 generated by SDCC.

For your sample code , you can save 2 or three instructions by using
OPTION_REG = 0x07 rather than PS0=1; PS1=1; PS2=1; ...

Regards,
Raphael Neider



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to