
This is the implementation of the gcc 68HC11 crosscompiler for MSDOS.

Compiler:            GNU C/C++ 2.6.3  (without Objective C)
Machine Description: Otto Lind 
Assembler/Linker:    Alan R. Baldwin


NO WARRENTY

Because this cross-compiler and its additional sources are licensed free
of charge, there is no warrenty for it. The entire risk is with you.
Should any of the included binaries or sourcecodes prove defective, you
assume the cost of all neccessary servicing, repair or correction.
Please also read the GNU General Public License (COPYING).

Contents
--------

1. Setup XGCC
2. 68HC11 specific Pragmas and Options
3. Notes on crt0.o
4. Using XGCC
5. 68HC11 Assembler and Linker


1. Setup XGCC
-------------

- Add the homedirectory of xgcc to gcc\bin\igcc.bat
- Call igcc from your autoexec.bat


2. 68HC11 specific Pragmas and Options
--------------------------------------

68HC11 specific pragmas:

#pragma interrupt
   Define the next function as interrupt routine. A RTI instruction is added 
   rather than RTS. 

#pragma short_branch
   Use short branches

#pragma long_branch
   Use long branches

68HC11 specific options:

-mshort_branch       shorter code, but possible range errors
-mlong_branch        larger code

For more information look at the GNU CC manual or the files
gcc.i? and cpp.i?, which are included in the .\DOC\ directory.


3. Notes on crt0.o
------------------

Use MAKECRT0.BAT to rebuild crt0.o. There are still many functions
missing in crt0.o. For example, there is no ___buildin_new or
___buildin_delete, which are needed for of the C++ new and delete 
operators. More important: There is no initalisation of static
variables (see below). I would be glad to hear about better startup code.

crt0.o is not automaticly included by xgcc. You must specify it at the 
commandline. Within crt0.o a 68HC11 boottable is present. The generated 
s19 code can  be programmed into an eprom, which must be present until 
adress $ffff. The eprom base adress must be known to the linker (see 
test.bat). The are some system functions added to crt0.o, which allow
the use of interrupt funktions without the interrupt pragma. Please
look at .\INCLUDE\OS.H

XGCC and the current crt0.o use the following memory:
0x0000-0x001b     null-ptr and temp-register for the GNU compiler
0x001b-           start of _BSS
0xffd0-0xffff     HC11 interrupts


4. Using XGCC
-------------

To generate valid HC11 code, the correct segment adress of _CODE and _BSS
must be present to the linker. As shown in .\SRC\TEST.BAT, the start
of a segment is set with the -b option:
   ld -b_CODE=0x0e000 -b_BSS=0x0001b 
The _BSS area also contains the processors return-stack. Its
size is set to 96 Bytes in crt0boot.as. This small value allows to
run the example (.\SRC\TEST.BAT) without any external memory.

It seems, that the _DATA need not to be set. It is appended to the _CODE
segment. _DATA contains initialized memory. This is normaly located
in ROM area. So any static values may not be modified:

   int x = 400;
   int y;
   int test(void)
   {
      static int z = 500;
      x++;                 /* ILLEGAL: &x normaly is ROM area */
      y++;
      z++;                 /* ILLEGAL: &z normaly is ROM area */
      return y+x+z;        /* no problem to read the contents of x,y or z */
   }

This is truly a problem, but I do not know how to correct this.
Please note, that this does not affect the initialisation of
local values or the definition of global values:

   int x;
   int test(void)
   {
      int y = 500;
      y++;    
      x++;
      return y+x;
   }

With the definition 'int x;' in the example above, 'x' has an undefind value.



5. 68HC11 Assembler and Linker
------------------------------

as6811.exe is renamed to as.exe, aslink.exe is now called ld.exe.
ld.exe does not support link-files (option -f). Detailed information
can be found in ASMLNK.DOC.


Oliver Kraus
oliver@cip.e-technik.uni-erlangen.de


