Topic : Application note AN55: Porting Cosmic applications to Raisonance

Forum : ST7/STM8

Original Post
Post Information Post
April 1, 2009 - 10:12am
Raisonance Support Team

Hi all,

We just released an application note that will help in porting ST7/STM8 applications from the Cosmic compiler toolchain to the Raisonance compiler suite.

You can get the application note from the Raisonance microcontrollers Web site at http://www.mcu-raisonance.com/: Click on "support", then on "Product documentation", and you'll get it.

Enjoy,
Bruno

Replies
Post Information Post
+1
0
-1
December 7, 2009 - 9:25am
Guest

One thing missing from this: #pragmas...

+1
0
-1
December 7, 2009 - 10:37am
Guest

Specifically:

#pragma section

+1
0
-1
December 7, 2009 - 4:08pm
Raisonance Support Team

Hi,

Indeed we do not have the equivalent of the Cosmic "sections". This is because our linker does not need it.
In some (rare) situations where specific segments placement is required, instead of creating sections you can use the CODE(), FARCODE() etc linker directives that will make the job for you.

We are currently developing a linker extension which will make it easier to locate similarly named segments with a single directive using regular expressions (instead of providing the exaustive list of segments that must be applied the given directive)

This will be available in the next RKit-STM8 release, which is not planned yet.

Regards,
Bruno

+1
0
-1
December 10, 2009 - 9:10am
Guest

The App Note does specifically say that inline assembler is outside its scope, but here's a few things to note:

Cosmic allows C-style comments in inline assembler; Raisonance doesn't.

Cosmic allows C-style hex constants in inline assembler; Raisonance doesn't.

Cosmic requires (allows?) you to specify a leading underscore when accessing C variables; in Raisonance, you must not add this underscore.

The Raisonance compiler will hang (possibly unrecoverably) if there are any static local variables in a C file with the SRC option.

+1
0
-1
December 10, 2009 - 10:10am
Raisonance Support Team

Hi again Andy,

Indeed there are some differences in the inline assembler support. We will update the AppNote and add this information.

Remember, however, that inline assembler is highly unportable, and should not be used to make thing "go faster".

There are some cases where assembler is required:
- Cycle-accurate code
- Code that fiddles with the stack (setjmp/longjmp, context switches...)
- Code that uses CPU addressing modes that are not used by the compiler (RCSTM8 uses all STM8 adressing modes)
- Specific startup code

In such cases, assembly is required. But always prefer an external assembly file rather than inline assembly. This makes things more portable.
In other cases ("I want my IRQ handler to be fast") just stick to C!

Note that RCSTM8 offers some "intrinsic functions" which make it natural to insert a NOP, enable/disable IRQs and other core features right from the C language (no assembly required)

Concerning your last point (static local variables not supported in SRC mode) a compiler patch is under validation and will be released tomorrow, including this fix.

Regards,
Bruno

+1
0
-1
December 10, 2009 - 10:42am
Guest

Bruno wrote:
Remember, however, that inline assembler is highly unportable, and should not be used to make thing "go faster".

I thoroughly agree!

In addition, I'd say that it should not be used just to avoid writing separate assembler modules when that is really what you should be doing! (which appears to be the case with the ST Touch Sense Library)

The thing is, of course, if you're on a porting exercise, that usually means that you have to keep the code as close to the original as possible - whether or not you like the original!

Quote:
always prefer an external assembly file rather than inline assembly.

Absolutely!

Let's just say that again:

Quote:
always prefer an external assembly file rather than inline assembly.