Cortex-M3 pracuje tylko w Thumb-2 więc musi mieć dostęp do wszystkich rejestrów w tym trybie bo praca w trybie ARM (tylko 32bit instrukcje) tam nie istnieje. Thumb-2 łączy w sobie zarówno ARM jak i Thumb (wielkość opcode dla instrukcji może być 16 lub 32 bit).
"The Cortex-M3 core contains a decoder for traditional Thumb and new Thumb-2 instructions"
Czlowiek uczy sie cale zycie :)
eCos
formatting link
(pozwole sobie na drobna reklame) ma ustawine opcje gcc takie jak uzywales poczatkowo
-mcpu=cortex-m3 -mthumb i jak najbardziej wykorzystywane sa instrukcje thumb-2 (...) .syntax unified .thumb (...) .global hal_switch_state_vsr .thumb .thumb_func .type hal_switch_state_vsr, %function hal_switch_state_vsr:
mov r0,#CYGNUM_HAL_CORTEXM_PRIORITY_MAX msr basepri,r0 ^^^^^^^ to jest raczej thumb-2 mov r0,#2 // Set CONTROL register to 2 msr control,r0 isb // Insert a barrier
Dziwnie to wyglada jak dla mnie.
BTW.
formatting link
2.3.1. General-purpose registers
The general-purpose registers r0-r12 have no special architecturally-defined uses. Most instructions that can specify a general-purpose register can specify r0-r12.
Low registers
Registers r0-r7 are accessible by all instructions that specify a general-purpose register. High registers
Registers r8-r12 are accessible by all 32-bit instructions that specify a general-purpose register.
Registers r8-r12 are not accessible by all 16-bit instructions.
Jest dokładnie tak jak piszesz. Podstawa to ".syntax unified".
Cortex-M3 używa Thumb-2, a więc łączy on ARM (32 bitowe instrukcje) i Thumb (16 bitowe instrukcje) "na raz"- nie trzeba przestawiać procka do pracy w tryb tylko ARM albo tylko Thumb.
Napisałem program używając zarówno instrukcji ARM 32-bit jak i Thumb 16-bit w trybie asemblera Thumb-2.
Potem to wylistowałem. Efekt był taki, że w Thumb-2 można używać zarówno instrukcji ARM jak i Thumb a asembler sam wstawia odpowiednie opcode. Jeśli instrukcja jest dozwolona jako Thumb 16bit, wstawia opcode 16bit, jeśli tylko jako ARM 32bit wstawia opcode 32bit.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.