Skip to main content
arnold_w
Senior II
March 30, 2021
Question

Is it possible to use the Core General Purpose Registers R0...R12 as regular varibles?

  • March 30, 2021
  • 1 reply
  • 673 views

I'm working with the STM32F446 microcontroller and sometimes I want to assign a peripheral register values from different variables in as few clock cycles as possible. I read in PM0214 https://www.st.com/resource/en/programming_manual/dm00046982-stm32-cortex-m4-mcus-and-mpus-programming-manual-stmicroelectronics.pdf page 18 that the core has some General Purpose Registers R0 ... R12. Am I allowed to use those for my own purposes and if so, what's the syntax to use them?

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
March 30, 2021

In assembler you can manage them anyway you want.

The compiler follows the ABI specification, and allocates them to local and optimized variables. The register directive is generally ignored at this point.

Perhaps get a book on ARM Assembler / Architecture

Look at the code generated by the compiler.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..