Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Peter Newsgroups: sci.electronics.design Subject: Re: Why Bloat Is Still Software's Biggest Vulnerability Date: Tue, 12 Mar 2024 13:10:48 +0000 Organization: A noiseless patient Spider Lines: 36 Message-ID: References: <980294@dontemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Tue, 12 Mar 2024 13:10:46 -0000 (UTC) Injection-Info: dont-email.me; posting-host="fb0768b4dc6b4d54882291ff97dde24f"; logging-data="296686"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CU5UagLSDOlpA1AiubkUF" Cancel-Lock: sha1:7mMUyNO6vjwwomnEfLF3HjOZfnw= X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: yes Bytes: 1975 RichD 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) ); }