This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is a DMB required between loading BASEPRI and storing BASEPRI_MAX?

Hi,

I have a question regarding BASEPRI, BASEPRI_MAX, and DMBs as they relate to both the V7-M and V7E-M architectures.

Let's say I have the following assembly,

// stuff
mrs r0, BASEPRI
msr BASEPRI_MAX, #3
// more stuff

Is it necessary to put a DMB between the two instructions so that the processor doesn't reorder the memory accesses? After reading Chris Shore's article here and reading through the data sheet of the MCU that I'm working with, my understanding is that a DMB isn't necessary because the special registers are  'strongly-ordered' memory (or are they 'device memory'? Was a little confused about this). That being said, here's where my confusion comes in - BASEPRI and BASEPRI_MAX have different encodings in their system instructions (section B5.1.1 of the ARM v7-M Architecture Reference Manual [ARM DDI 0403E.b ID120114]). For a mrs instruction, BASEPRI_MAX is aliased to BASEPRI, however, this is not the case for a msr instruction. So, if the system instructions are different, does this imply that the processor treats the two instructions above as independent, and is therefore free to execute them in any order it pleases?

Thanks!

Parents Reply Children