cancel
Showing results for 
Search instead for 
Did you mean: 

Port code from Hiware/Metrowerks to Cosmic

maxime2399
Associate II
Posted on November 30, 2002 at 06:18

Port code from Hiware/Metrowerks to Cosmic

3 REPLIES 3
maxime2399
Associate II
Posted on November 20, 2002 at 12:15

I have some C code that have been originally written for Hiware C compiler.

The problem is that I currently have only the Cosmic license and do not want to buy another compiler.

Does anyone have already ported some code from Hiware to Cosmic?

Is it easy? does anyone have advices?

Thank you!
Posted on November 20, 2002 at 15:33

The advantage of the C language is its protability. And since both C compilers are ANSI compliant, your work should be limited to

1. define a new script file which matches Cosmic requirement

2. modify your batch file or makefile to call the right compiler with the right compiler options

3. take care of the pragma definition (see interrupt subroutine, register location in zero page or 16-bit addressing page etc.)

4. Define the reset interrupt/vector table in an array (that's the way it is define with Cosmic)

5. Modify the in-line assembler function because it is called differently by the 2 compilers (1 line to change !)

I have done the work several times and it usually does not take that long. So it is... easy

For a Cosmic example, I will advise you Andy to take a look at a previous discussion :

''Getting started with ST72521: C source example ?''

You may have decided to use another device than the ST72521 however script file, vector table etc. are heavily commented. It will help you getting started

Jojo

janvi
Associate II
Posted on November 30, 2002 at 06:18

ported a project from Hiware to Cosmic recently what contained C and Assembly mix. The main job is to write a new lfk linkfile for the cosmic linker and I also wrote a new makefile what considers the option switches of the Cosmic tools. Conditional translation is compatible between Hiware and Cosmic and the Cosmic linker was able to override all his default section names to those introduced to the project with the Hiware linker. This way, a switch allows the translation of the project with both tools now, but Cosmic always shows the better code opitmizations and runtime efficiency.

The important things to consider are:

C-part mainly nothing

the section syntax (#pragma) is slighly diffrent becouse Cosmic can derive the section properties from default defined section while Hiware always need complete property definitions

If a label is defined public, the Hiware needs to know the size with .b or .w modifiert. This modifier must not written to the XDEF with the Cosmic Assembler becouse he can derive the size from section and definition inside the same file. XREF is compatible and both use same size modifiert but I believe it will be a question mark forever to understand why Hiware needs the size definition of externals defined 2 times.

If you use gnu-make downloaded from Cosmic try the --win32 switch for Micro$oft compability - thats all

Good luck and drop me a message if other problems occor...