Howdy -- I'm starting with Cortex M processors, but I have lots of experience with 8bit MCUs.
I have been working on learning the STMicro PAL headers.
One thing, coming from an 8051, is that you can individually set/read pins. I didn't think this was significant, until I kind of started looking at the HAL headers and realized there doesn't seem to be similar functionality.
In 8051 with the Keil compiler, you do something like:
sbit LedOutput P2^5;
Is this not the Cortex M way to accomplish bit level reads like that?
Like I was taken aback that there is an BSRR and BRR registers. No such concepts on 8051s.
THERE IS AN EPIC THREAD ON THIS FROM 9 YEARS AGO: http://www.keil.com/forum/15029/direct-referrence-to-gpio-pins/
Near the end of this masterpiece post, there is some discussion of bit banding and reading individual bits in the works for M3's.
Did this ever come to fruition for M0's?
In the STHeaders, define all the individual registers, with shifts and masks. So it seems like bit level access is not the way this works in 2018.
If you want to read an individual register, is shifts and masks the most efficient way to get the job done on a Cortex M0?
>>I want to make sure I'm not using a bunch of extra overhead for what seems like such a menial atomic operation on an 8051
RISC just makes you move things through visible registers rather than letting microcode hide it in invisible ones. The operation that takes dozens of cycles on the 8051 takes 3 cycles to clock along the pipeline in the Cortex, plus some more to complete depending on the bus speeds involved.
Things you can contain in registers take a single cycle, and other things that take multiple instructions and tens of dozens of cycles on an 8051 are done in far fewer or one. Say 32-bit addition, or multiplication, things like division are massively more efficient. The CM0 removes the hardware divider, the software version will significantly outpace the equivalent 8051 implementation.
The "BSRR" operation is just combinational logic around a flip-flop, people have been using for many decades
en.wikipedia.org/.../Flip-flop_(electronics)