Topic : STM8 Copiler multipilcation

Forum : ST7/STM8

Original Post
Post Information Post
January 8, 2013 - 8:45am

How to force STM8 compiler to use optimal unsigned 16 x 16 ? 32 multiplication (?C?MULU161632)
All I do it still uses generic inefficient 32x32 version:

uint32_t multRez;
uint16_t var;

#define SPEED

multRez = (uint32_t)43678 * var;

#undefine SPEED

*** WARNING P005 IN LINE 814 OF src\functions.c : Control 'undefine' unknown

I can not use SPEED optimization for whole code just, but how do I instruct compiler to use SPEED optimization just for portion?
#define/#undefine - seems to be not working

Post Information Post
January 8, 2013 - 11:55am
Raisonance Support Team


For the SPEED optimization you can do as follow:

typedef unsigned long uint32_t;
typedef unsigned short uint16_t;

uint32_t multRez;
uint16_t var;

#pragma ot(7,SPEED)
void main( void )
multRez = (uint32_t)43678 * var;
#pragma ot(7,SIZE)

If you do two optimisation in the main function (SPEED optimising and a SIZE optimising in the same function) you will get the same result as before (?C?MULU161632).