Random notes
------------
A random set of notes about sdcc and how it works.

Sandeep:
--------
Adding memory maps for AVR, setup default map for
local & global variables in port.h will be initialised
by the _<port>_finaliseOptions() [good functions]..some
kludges remain because of the "overlay" segment for 8051.

The memory segment stuff will have to be made more flexible.
Currently there does not seem to be a 1-to-1 correspondence 
between storage class & memory map. (should there be??).

Also Added check for memory map in SDCCmem.c allocLocal
and allocglobal for "eeprom" memory space (AVR).



Michael:
--------
Tracing parmBytes and function calls.

Bug:
void printf(const char *format);

void puts(const char *s)
{
	printf(s);
}

Generates the pseudo-code:
	  hl = s
	  push hl
	  call printf
	  pop l (not hl - so parmBytes is too small)

parmBytes for a function call seems to be setup in geniCodeCall in
SDCCicode.c.

geniCodeCall:
* Takes care of calls with side effects (?)
* Generates the icode to push the parameters (this also computes the 
  resulting stack size)
* Generates a CALL or PCALL depending on if its a function or pointer to.
* Computes the result
* Adds the code for the call to the chain.

My bug is probably in geniCodeParms - it's probably computing the
size of pointers wrong.

geniCodeParms:
* A 'parm' node causes this to be run on the tree branches.
* It switches on the stack mode and sendto mode, and adds the
  instructions required to push or put.
* A push adds the result of 'getSize' to the stack size.

So the bug is probably in getSize.  's' is not an aggregate, so the
bug is in getSize().

It seems that IS_SPEC() is being set, deferencing *s so that it's size
is sizeof(char) == 1.  It's either a SPECIFIER or a DECLARATOR - seems that
were the wrong way around.  This is set in SDCCsymt.c, SDCCval.c, and the 
yacc file. SDCCsymt.c and SDCCval.c havnt really changed in 5 days - must
be SDCC.y.  Nope, no changes.  diff against 5 days ago shows only intersting
changes are in SDCCicode.  Same with -14 days.

Michael
-------
Next bug is global function parameters not being pushed correctly. i.e

unsigned int counter;

void print(void)
{
	printf("Counter is %u\n", counter);
}
generates:
_print::
	ld hl,#_counter
	push hl
	ld hl,#str_1
	push hl
	call printf
	fix, ret

which is more like:
	printf("Counter is %u\n", &counter);
	
First looking in SDCCicode.c for the stuff that generates function calls:
Probably a bug in geniCodeParams.
Nope, a bug in my stuff :)
