To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1786
1785  |  1787
Subject: 
Re: Memory Usage
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Sun, 25 Mar 2001 12:58:44 GMT
Viewed: 
1633 times
  
Ok, thanks. I'll try everything else first, then try this if I get
desperate. The main thing I hit a wall with was when I switched to
floating-point, which increased my .lx filesize by about 2k, so if I go
back to fixed-point, turn sound off in config.h, and watch my stack sizes
in my execi I'll probably be ok. If I do happen to try -Os, I'll certainly
write back and say how it went.

Having written a few embedded-systems compilers, I must say that using
floating point on an 8-bit chip like the H8 is generally considered crazy.
The values eat memory, and the libraries drawn in can get really large (at
least for a production compiler that has to support full ANSI).

The H8/300 is a mightly little chip: 16 Mhz and 32kB of RAM is a VERY
POWERFUL computer, far better than my first home computer back in 1985.  But
floating point has no place here.  Try to approximate using integers.

A problem is that gcc has a poor linker that only resolves on a module
level, and not a per-function basis.  This means that if any function in a
certain file is needed, the code for the whole file will be linked in.

In general, it is a good idea on smaller chips to:

* Use 8-bit variables, i.e. char and unsigned char, wherever possible.

* Avoid pointers.

* Avoid function pointers.

* Avoid dynamic memory allocation.

* Avoid floating point like it was the black plague. Including floating-
  point constants.

* Send large data by reference rather than by copy (pointers to structs)

* Set the compiler to maximal size optimization.  You do not have a speed
  problem normally, the outside world is far slower than your code.

* Use the minimal number of tasks, since the tasking model used in LegOS is
  quite wasteful of the stack (one stack per task, "while(1)" task bodies,
  is a very bad way to use data memory).


/jakob



Message is in Reply To:
  Re: Memory Usage
 
(...) Ok, thanks. I'll try everything else first, then try this if I get desperate. The main thing I hit a wall with was when I switched to floating-point, which increased my .lx filesize by about 2k, so if I go back to fixed-point, turn sound off (...) (24 years ago, 15-Oct-00, to lugnet.robotics.rcx.legos)

6 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR