Hacker News new | ask | show | jobs
by jwr 4584 days ago
If only there was a tutorial like this, but for the Cortex-M series — specifically, M0+ and M4.

I recently had to dig through tons of documentation just to get started and ARM is really bad at providing overview documentation. As an example: I quickly discovered that the Cortex-M doesn't really have 16 registers. You only get 8 general-purpose registers and 5 kinda-registery-quick-storage-locations, which only certain instructions can access. To this day I couldn't find a clear list of instructions that can access these high registers.

3 comments

No, they're really all registers; it's just some of them aren't usable with all instructions for some of the M profile cores. Specifically, ARMv6M cores (like the M0) only implement the Thumb1 instruction set (the 16 bit instructions) plus a few additions so they don't need any ARM mode instructions for exception handling etc. ARMv7M cores (like the M3) implement pretty much all of Thumb2, including the 32 bit versions of instructions which allow you to make much greater use of the high registers (at the cost of slightly larger code).

http://infocenter.arm.com/help/topic/com.arm.doc.qrc0006e/QR... is the Thumb 16-bit instruction set quick reference card, which seems to have a reasonable summary of which instructions have which register restrictions.

M3 and M4 are two of the absolute nicest cores to program for. A reasonably orthogonal ISA that's still small enough to fit on one side of a reference card, enough registers, and a wonderfully simple performance model (everything is single-cycle except for multiplies and memory ops).
Thanks, that is very helpful, and I've never seen that reference card until now!
I'm co-authoring a textbook on ARM assembly language that focuses on the M3. It will be finished next year.
That is because those processors are running in thumb mode... essentially using 16-bit opcodes. The original ARM instruction set is 32-bit opcodes which is enough to encode 16 registers. The thumb mode was added to increase code density and subsequently they found it could be used for most common cases.