Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

More newbie questions- MAP file and char vs int

More newbie questions- MAP file and char vs int

2003-12-17 by Adrian

Larry,

> Yes, DDRx  is the direction register, PORTx is the
> output driver (or
> pull-ups) and PINx is the current state of the pin
> (regardless of whether it
> is input or output or if the output is driven high
> while the corresponding
> PORT bit is low, etc).  Direct assignment works with
> GCC - outp is old and
Thanks for confirming that.


> You might consider BASCOM: it is a basic compiler,
> so you can preserve your
I tried that in the demo form and my LCD code didn't
work (but see below) hence the move to WinAVR GCC. I
liked the BASCOM IDE, but WinAVR worked for me very
quickly (i was quite surprised) and in combination
with Studio and AVRISP it's not too bad switching
between applications.

I have discovered that my 'problem' was that the AVR
instruction time is too short for the LCD - that takes
150ns between CE low and the data bus being ready for
read - GCC must be making it single cycle instructions
as I've had to put a delay between CE and read to get
it in.

> basic stamp knowledge, but get a 10,000x faster
More importantly the BASCOM code was BIG. I didn't
look at the disassembly but it was using 70% of a 2313
just for the basic driver code - there's no way my
application would have got in too. GCC code is around
300 bytes (not words if I have read HEX file
correctly). Maybe they put in a bigger start-up
library?

On such a little device as the 2313 it is nice to be
able to access memory via arrays to implement string
functions simply and economically. BASIC hides that.

That brings me to the MAP. The STAMP has a really nice
graphic map to show program, constant and variable
consumption of resources. Can anyone explain how this
can be extracted from map file?

Whilst on resources, I've seen that a number of
example.c files define routines and variables as INT
even thoughnthey are clearly only 8 bits wide. Why
aren't they done as CHAR? Even if they are allocated
dynamically it's still taking more space than needed
and could add confusion if trying to force an INT into
a 8bit PORT.

TIA,

Adrian


=====
-
*********************************************

________________________________________________________________________
BT Yahoo! Broadband - Save £80 when you order online today. Hurry! Offer ends 21st December 2003. The way the internet was meant to be. http://uk.rd.yahoo.com/evt=21064/*http://btyahoo.yahoo.co.uk

RE: [AVR-Chat] More newbie questions- MAP file and char vs int

2003-12-17 by Larry Barello

The native data in GCC is the int, which is two bytes on the AVR.  Even if
you declare a return value as a char, GCC will return an int.  If you use a
char as an input to a switch() statement it will be promoted to int before
all tests (IIRC - this might have changed).  Enums default to int unless you
add -fshort-enums to the compiler command line. etc, etc.

That doesn't explain the declarations.  They should still declare as char or
unsigned char so they can benefit from other compilers, or compiler changes.

In the map file, look at the last entry under .text: that is your code space
usage.  I don't understand the linker: although the sections are in order,
the symbols, within a file, are all mixed up.  Makes it challenging to
figure out how big a particular routine is.

If you are comfortable with C, then there is no reason to mess with BASCOM,
except for all the library support (instant LCD, instant 1 wire, etc).  I
only use BASCOM for prototyping and play work.  I use GCC (and asm) for
almost everything else.

Cheers!
Show quoted textHide quoted text
-----Original Message-----
From: Adrian [mailto:adrian650@yahoo.com]
...
More importantly the BASCOM code was BIG. I didn't
look at the disassembly but it was using 70% of a 2313
just for the basic driver code - there's no way my
application would have got in too. GCC code is around
300 bytes (not words if I have read HEX file
correctly). Maybe they put in a bigger start-up
library?

On such a little device as the 2313 it is nice to be
able to access memory via arrays to implement string
functions simply and economically. BASIC hides that.

That brings me to the MAP. The STAMP has a really nice
graphic map to show program, constant and variable
consumption of resources. Can anyone explain how this
can be extracted from map file?

Whilst on resources, I've seen that a number of
example.c files define routines and variables as INT
even thoughnthey are clearly only 8 bits wide. Why
aren't they done as CHAR? Even if they are allocated
dynamically it's still taking more space than needed
and could add confusion if trying to force an INT into
a 8bit PORT.

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.