How to use Hi(r8-r12) register in Cortex-m0?

2.4k views Asked by At

In ARM/Thumb architecture, there are 16(r0-r15) registers in a single cpu. Furthermore, Thumb-Instruction-Set can only use the first 8(r0-r7) registers and the r13,r14 and r15 register.But the last 5(r8-r12) register are still in the cpu. How can we use these Hi(r8-r12) registers?

Recently, I am designing a protecting scheme in ARM Cortex-M0 CPU. In my project, I want to use r9 and r10 to store some information. Because other instructions would not use these registers, so I don`t need to push and pop these registers.

Can anyone help me with these? Should I use BX or BLX instruction to switch instruction set?

Instruction I use the r9 register

Wrong information

2

There are 2 answers

0
RuSh On

Cortex-M0 only supports Thumb instruction set (and some instructions from Thumb2). So, there is no possibility of instructionset switching from Thumb to ARM.

Reference: https://en.wikipedia.org/wiki/ARM_Cortex-M#Instruction_sets

ARM documentation from http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0040d/Bgbbfcgc.html gives little hint about possible usages high-registers.

[If time permits, I will tryout somethings and will update this post soon]

1
hesham_EE On

Notice that in ARMv6-M architecture, few instructions accept high registers. The most notable of them is mov (not movs). This way, you can read in any of the lower registers from memory then move these values from the low register to the high register you want. An example code:

LDR  r0, [r1]     ; read into r0 the value at address r1
MOV  r9, r0       ; move the recent read value to r9

This way, you can make use of the high register. I hope this helps, though a little late :)