[an error occurred while processing this directive]
да всё просто +
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Kenat 18 января 2006 г. 16:47
В ответ на: Вопрос знатокам IAR for ARM (+) отправлено <font color=gray>Sgrig_</font> 18 января 2006 г. 16:34


The ARM assembler (armasm) supports the full range of MRS and MSR instructions, in the form:

MRS(cond) Rd, CPSR
MRS(cond) Rd, SPSR
MSR(cond) CPSR_fields, Rm
MSR(cond) SPSR_fields, Rm
MSR(cond) CPSR_fields, #immediate
MSR(cond) SPSR_fields, #immediate

where 'fields' can be any combination of "cxsf".

Note that MSR CPSR_c, #immediate is a legitimate instruction (despite what is written in early versions of the ARM ARM), so a sequence of two instructions like:

MOV r0, #0x1F
MSR CPSR_c, r0

as commonly found in boot code, can be combined into one instruction, like:

MSR CPSR_c, #0x1F ; go to System mode, IRQ & FIQ enabled

This immediate form of MSR can actually be used with any of the field masks, but care must be taken that a read-modify-write strategy is followed so that currently unallocated bits are not affected. Otherwise the code could have distinctly different effect on future cores where such bits are allocated. When used with the flag bits, the immediate form is shielded from this as bits 27-24 can be considered to be read only.


For MSR operations, we recommend that only the minimum number of fields are written, because some ARM implementations may need to take extra cycles to write specific fields; by not writing to fields which don't need changing reduces any such extra cycles to a minimum. For example, ARM9 needs more cycles than an ARM7 to execute an MSR when the CPSR control field is modified, to allow the changes to propagate through the pipeline correctly, so that register reads for the following instruction come from the correct banked registers.

For example, an MRS/BIC/ORR/MSR sequence to change processor mode is best written with the last instruction being MSR CPSR_c, Rm, though any other set of fields that includes 'c' will also work.

As another example, to restore a saved PSR value (where all fields need to be restored), you should use MSR SPSR_cxsf, Rm.

Be aware, however, that there is unfortunately a bug in the SDT 2.50 ARMulator - it fails to execute instructions with 'x' & 's' (you may see 'Undefined Instruction' instead) - see MSR SPSR_cxsf,Rm gives Undefined Instruction with ARMulator. This is fixed in SDT 2.51

To execute your code under the SDT 2.50 ARMulator, we suggest you apply the following workaround to your assembler sources:

IF :DEF: ARMULATOR_WORKAROUND
MSR SPSR_cf, R0
ELSE
MSR SPSR_cxsf, R0
ENDIF

Earlier releases of the assembler allowed other forms of the MSR instruction to modify the control field and flags field:

cpsr or cpsr_all Control and flags field.
cpsr_flg Flags field only.
cpsr_ctl Control field only

and similarly for SPSR. These forms are now deprecated, so should not be used. If your legacy code contains them, the assembler will report:

Warning: Deprecated form of PSR field specifier used (use _cxsf)

In most cases, you should simply modify your code to use '_c', '_f', '_cf' or '_cxsf' instead.



Составить ответ  |||  Конференция  |||  Архив

Ответы


Отправка ответа

Имя (обязательно): 
Пароль: 
E-mail: 
NoIX ключ Запомнить

Тема (обязательно):
Сообщение:

Ссылка на URL: 
Название ссылки: 

URL изображения: 


Rambler's Top100 Рейтинг@Mail.ru
Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание

E-mail: info@telesys.ru