Newsgroups: comp.robotics
Path: brunix!uunet!gumby!wupost!micro-heart-of-gold.mit.edu!news.media.mit.edu!fredm
From: fredm@media.mit.edu (Fred G Martin)
Subject: Re: programming the miniboard
Message-ID: <1992Oct6.034508.1236@news.media.mit.edu>
Keywords: compact code 6811 miniboard
Sender: news@news.media.mit.edu (USENET News System)
Organization: MIT Media Laboratory
References: <monte.718302401@spider.wri.com>
Date: Tue, 6 Oct 1992 03:45:08 GMT
Lines: 71

In article <monte.718302401@spider.wri.com> monte@spider.wri.com
(Monte Seyer) writes: 

>I have been experimenting with writing C code for the miniboard
>using the Micro-C 6811 developers special.
>I haven't much experience writing code for small systems or in assembly.
>
>I have a few questions regarding programming the 6811/miniboard:
>
>With 2k memory, is coding in assembly pretty much required? 

It all depends on how large your project is.  I've seen people do some
pretty neat things in straight C before running out of the 2K of
memory.

The basic libraries are about 700 bytes and the C compiler is not
terribly efficient, so don't expect a large amount of code to fit, but
small things work just fine.

>When using the libraries from Fred Martin, can the libraries
>be configured so that portions not being used are eliminated?

When a given library routine is used, the whole file that contains it
is linked.  If you don't use any routines in a particular file, that
file is not linked.   One way to make more space would be to create a
separate file for each library routine, so you really only link the
ones you use.  MINILIB.SRC would be a good candidate for this.

Other things that can be removed:  the pulse width modulation routine
takes up 100 bytes or so, you can kill that from 6811ST.SRC and fix the
motor routine in MINILIB.SRC.

(You can see that I've already done some of this type of optimization
by creating #defines that either plug in or remove some functionality.
This is a good way to keep generality while conserving code space).

>Are any special cc11 flags useful?

Yes, use the optimizer.  I've never had any problems with it, and it
can only make your code smaller and faster.

>Any caveats on what constructs to avoid?
>Any suggestions/tricks for writing compact C/assembly code for 6811?

For both of these, I'd look at the assembly output of the compiler to
learn what works and what doesn't.  It's pretty straight-forward to
see what C code compiles to what assembly code.

One thing I've done is taken subroutines written in C and re-coded
them in assembly to save space.

>Suggestions for books on the above topic?

Make sure you have a copy of Motorola's 6811 book, the big pink one.
I also like the little pamphlet reference guide.  Call Motorola at
(800) 521-6274 to get copies.

>As an aside, what sorts of tasks are you planning for your miniboard?
>What about two or more miniboards working together?

This is something I'd really like to hear about.  Greg Ratcliff tells
me he's shipped 250 boards---wow!  I never thought there'd be such a
demand for this little board.

If you want to send project descriptions to me, I'll collate them and
post back to the net.

Cheers!

	-Fred

