当前位置:网站首页>Miscellaneous instructions of arm instruction set
Miscellaneous instructions of arm instruction set
2022-06-12 11:50:00 【fanxiaoyu321】
List of articles
This note records the following categories ARM Instructions :
- Status register access instruction ;
- Semaphore operation instruction ;
- An abnormal interrupt generates an instruction ;
Status register access instruction
ARM Two instructions are provided to exchange data directly between the status register and the general-purpose register .
- MRS:Move Register <-- State, Transfer the value of the status register to the general-purpose register ;
- MSR:Move State <-- Register, Transfer the value of the general register to the status register of the ;
When operating the status register , We should pay attention to the following points :
- Unused bits in the status register should not be modified ;
- T Flag bits should not be manually modified , Only through BX Command to modify ;
- Access to the status register should follow “ Read - modify - Write back to ” The order of ;
MRS
MRS{<cond>} <Rd>, CPSR
MRS{<cond>} <Rd>, SPSR
if CondPassed(cond) then
if R == 1 then
Rd = SPSR
else
Rd = CPSR
MSR
MSR{<cond>} CPSR_<fields>, #<immediate>
MSR{<cond>} CPSR_<fields>, <Rm>
MSR{<cond>} SPSR_<fields>, #<immediate>
MSR{<cond>} SPSR_<fields>, <Rm>
if CondPassed(cond) then
if opcode[25] == 1 then
operand = 8bit_immediate >> (rotate_imm * 2)
else
operand = Rm
if R == 0 then
if field_mask[0] == 1 and InAPrivilegedMode() then
CPSR[7:0] = operand[7:0]
if field_mask[1] == 1 and InAPrivilegedMode() then
CPSR[15:8] = operand[15:8]
if field_mask[2] == 1 and InAPrivilegedMode() then
CPSR[23:16] = operand[23:16]
if field_mask[3] == 1 and InAPrivilegedMode() then
CPSR[31:24] = operand[31:24]
else
if field_mask[0] == 1 and InAPrivilegedMode() then
SPSR[7:0] = operand[7:0]
if field_mask[1] == 1 and InAPrivilegedMode() then
SPSR[15:8] = operand[15:8]
if field_mask[2] == 1 and InAPrivilegedMode() then
SPSR[23:16] = operand[23:16]
if field_mask[3] == 1 and InAPrivilegedMode() then
SPSR[31:24] = operand[31:24]
among <fields> Press the status register as 8bit One group is divided into 4 Domains , The distribution is as follows :
| bits | fields Mark | explain |
|---|---|---|
| bits[31:24] | f | Conditional flag bit field |
| bits[23:16] | s | Status bit field |
| bits[15:8] | x | Extension bit field |
| bits[7:0] | c | Control bit field |
Semaphore operation instruction
Software programming , Semaphores are usually used for mutual exclusion between processes , The foundation for this requires an atomic operation , That is, read and modify semaphores in one instruction ,ARM Two instructions are provided to complete the signal operation .
- SWP: Word exchange instruction ;
- SWPB: Byte exchange instruction ;
SWP Word exchange instruction
SWP Put the memory unit ( Address Rn) The value in is read to Rd in , At the same time, register Rm Write to the memory unit , If Rd and Rm For the same register , Then it is equivalent to exchanging the contents of registers and memory cells .
SWP{<cond>} <Rd>, <Rm>, [<Rn>]
if CondPassed(cond) then
if Rn[1:0] == 0b00 then
temp = Mem[Rn, 4]
elif Rn[1:0] == 0b01 then
temp = Mem[Rn, 4] >> 8
elif Rn[1:0] == 0b10 then
temp = Mem[Rn, 4] >> 16
elif Rn[1:0] == 0b11 then
temp = Mem[Rn, 4] >> 24
Mem[Rn, 4] = Rm
Rd = temp
SWPB Byte exchange instruction
and SWP Instruction similar , The only difference is that the instructions exchange 8bit byte .
SWPB{<cond>} <Rd>, <Rm>, [<Rn>]
if CondPassed(cond) then
temp = Mem[Rn, 4]
Mem[Rn, 4] = Rm
Rd = temp
An abnormal interrupt generates an instruction
ARM Two instructions are provided for the software to actively trigger abnormal interrupts :
- SWI: Soft interrupt instruction . This instruction can generate SWI abnormal ,ARM This instruction can be used to call the program in privileged mode in the operating system in user mode , That is, the basis of system call implementation ;
- BKPT: Breakpoint interrupt instruction . seeing the name of a thing one thinks of its function , This instruction is used to generate software endpoints , For use by the debugger ;
SWI Soft interrupt instruction
SWI{<cond>} <immed_24>
if CondPassed(cond) then
R14_svc = address of next instruction after then SWI instruction
SPSR_svc = CPSR
CPSR[4:0] = 0b10011 // Enter SVC Pattern
CPSR[5] = 0 // ARM Pattern
CPSR[7] = 1 // close IRQ, But don't close FIQ
if high vectors configured then
PC = 0xFFFF_0008
else
PC = 0x0000_0008
BKPT Breakpoint interrupt instruction
BKPT <immed_16>
if (not overriden by debug hardware)
R14_abt = address of BKPT instruction + 4
SPSR_abt = CPSR
CPSR[4:0] = 0b10111 // Enter ABT Pattern
CPSR[5] = 0 // ARM Pattern
CPSR[7] = 1 // close IRQ, But don't close FIQ
if high vectors configured then
PC = 0xFFFF_000C
else
PC = 0x0000_000C
边栏推荐
- ARM指令集之跳转指令
- Problems in cross validation code of 10% discount
- Process creation and recycling
- 转载--win10打开任务管理器就蓝屏的问题
- ARM指令集之Load/Store指令寻址方式(二)
- 【QNX Hypervisor 2.2 用户手册】4 构建QNX Hypervisor系统
- UML series articles (31) architecture modeling - deployment diagram
- 6.6 分離卷積
- ARP protocol data processing process of neighbor subsystem
- Logrotate log rotation method create and copyruncate principles
猜你喜欢

Problems in cross validation code of 10% discount

Pytoch notes

TinyMCE realizes automatic uploading of pasted pictures

Lambda and filter, List 和 numpy array的索引,以及各种距离指标distance-metrics,拼接数组以及axis=0 and axis=1的区分

Windows10安装mysql-8.0.28-winx64

ARM指令集之批量Load/Store指令

Doris记录服务接口调用情况

C# 37. Textbox scroll bar and multiline

创建Servlet项目

【藍橋杯單片機 國賽 第十一届】
随机推荐
Socket programming UDP
影响店铺权重的三十一条,快来看看中招了吗
MySQL - built in function
35. 搜索插入位置
Blue Bridge Cup 2015 CA provincial competition (filling the pit)
TinyMCE series (II) TinyMCE plug-in development
5G NR协议学习--TS38.211下行通道
Node crawler puppeter usage
Video JS library uses custom components
Design of tablewithpage
Design of virtual scrolling list
Reentrantlock source code analysis
Judge whether the network file exists, obtain the network file size, creation time and modification time
First understand the onion model, analyze the implementation process of middleware, and analyze the source code of KOA Middleware
Face recognition PIP failed to install Dlib Library
A.前缀极差
机器学习之线性模型
Lambda and filter, List 和 numpy array的索引,以及各种距离指标distance-metrics,拼接数组以及axis=0 and axis=1的区分
Promise controls the number of concurrent requests
Architecture training module 7