Hullo guys , I had to write my own assembly subroutines to be called from C files . From the ARM Cortex-M documentation , it's clear that when an interrupt occur , only R0->R3 , R12 are pushed into stack . So for safe operation , those 're the only registers allowed to be used when interrupts 're enabled ?
Take advantage of the fact that "PUSH" operates on a list of registers: "<reglist>". The ASM can be simplified:
__asm__ volatile("PUSH {R4-R6}\n\t");
__asm__ volatile("POP{R4-R6}\n\t");