[ECOS] stm32 hal_reset_vsr function tweak

Max Salov amx@me.by
Wed Jun 3 10:02:00 GMT 2009


Hi
I have a suggestion to define hal_reset_vsr function as noreturn. This 
tweak will save at least 4 bytes on stack, because LR register is pushed 
to stack and never poped back (function ends with infinite loop).

Without "no return" listing:

void hal_reset_vsr( void )
{
  8000de4:	b500      	push	{lr}
  8000de6:	b081      	sub	sp, #4
     // up GPIO, the SRAM, power management etc. This routine is
     // usually supplied by the platform HAL. Calls to
     // hal_variant_init() and hal_platform_init() later will perform
     // the main initialization.

     hal_system_init();

With "no return" listing:

08000de4 <hal_reset_vsr>:
     // up GPIO, the SRAM, power management etc. This routine is
     // usually supplied by the platform HAL. Calls to
     // hal_variant_init() and hal_platform_init() later will perform
     // the main initialization.

     hal_system_init();

Both variants were build with -O2 flag.
So the difference is in two words in stack and two instructions. 
Presence of "sub sp, #4" is mysterious for me.

P.S. I understand that such tweaks are miserable when minimum ecos 
configuration occupy 5-6k of rom and uses about 1k of ram.

Best regards,
Max.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list