Sujet : Re: Why Bloat Is Still Software's Biggest Vulnerability
De : occassionally-confused (at) *nospam* nospam.co.uk (Peter)
Groupes : sci.electronics.designDate : 12. Mar 2024, 14:10:48
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uspk8m$91ne$4@dont-email.me>
References : 1 2 3 4
User-Agent : Forte Agent 3.3/32.846
RichD <
r_delaney2001@yahoo.com> wrote:
Given these considerations, does anybody write assembly code for
modern RISC processors?
Yes; some stuff cannot be done in C. Start with loading SP. No way in
C!
Some code in an RTOS is not possible in C. Look at the FreeRTOS
sourcecode. There are bits of asm in there.
Also asm has great uses for protecting from optimisation (which can
change silently by upgrading the compiler!). Asm never gets modified;
essential when talking to devices needing specific minimum /CS timing
etc.
Another example, for accurate delays (ST32F417, 168MHz)
// Hang around for delay in microseconds
__attribute__((noinline))
void hang_around_us(uint32_t delay)
{
delay *= (SystemCoreClock/4100000L);
asm volatile (
"1: subs %[delay], %[delay], #1 \n"
" nop \n"
" bne 1b \n"
: [delay] "+l"(delay)
);
}