当前位置:网站首页>Arm immediate
Arm immediate
2022-06-25 12:12:00 【xiaozhiwise】
/*
* 2018/12/20 11:43 qing
*/
/*
* ARM Medium MOV Command format
*/
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
| Cond | 0 0 | L| OpCode | S | Rn | Rd | Operand2 |
op2 Yes, it accounts for 12 position , among bit 11 - bit 8 Is shift (rotate), bit 7 - 0 It's a 8 The immediate number of bits (imm),
mov Rn, op2 @ After performing Rn = op2 >> (rotate * 2), The shift here is a cyclic right shift , It's up to mov Not all immediate numbers can be represented by an instruction
1. mov r3, #0x56000000
although 0x56000000 It's a 32 The number of bits , But you can find such a 8 Immediately , Move right to get , Look at the machine code e3a03456 , Expand to binary , Compare the format below
31 27 23 19 15 11 7 3
1110 0011 1010 0000 0011 0100 0101 0110
Cond[31:28] = 1110
[27:26] = 00
L[25] = 1 , representative op2 It's an immediate number
OpCode[24:21] = 1101
S[20] = 0
Rn[19:16]= 0000
Rd[15:12]= 0011 , R3
Op2[11:8]= 0100 , Move right 4 * 2 position
Op2[7:0] = 0101 0110 , 8 Immediately , 0x56
First of all to 0x56 Expanded into 32 Signed number of bits , 0x00000056 , Then cycle right 8 position , Got it. 0x56000000
2. mov r3, #0x56000014
0x56000014 You can't get it by shifting , The compiler will report an error ,C A program written in a language , The compiler does this :
mov r3, #0x56000000
add r3, r3, #0x14
Instead of mov Another instruction of is ldr, It might be more convenient .
/*
* stay ARM The rule of using immediate numbers in
*/
stay ARM It can't be like X86 That way, the immediate number is directly loaded into the register . Because the immediate number you use is limited .
Can pass LDR Bypass these restrictions , There are the following techniques :
Every one of them ARM The width of the instruction is 32 position , All instructions are conditionally executable .
Yes 16 Medium conditions can be used, and the occupation of each condition in the machine code is 4 position . After that we need 2 Bit as destination register .2 Bit as the first operation register ,
1 Bit is used as the flag bit for setting the status , Plus, for example, opcodes (opcode) Occupation of these . Finally, each instruction leaves us only space for storing immediate numbers 12 A wide . That is to say 4096 Different values .
That means ARM In the use of MOV The immediate range of values that can be manipulated when instructing is limited . If it's big , It can only be split into multiple parts and spliced with a shift operation .
So the rest 12 Bits can be divided again ,8 Bit is used for loading 0-255 Any value in ,4 Bit is used to do 0~30 Cyclic right shift of bits .
This means that the immediate number can be obtained by this formula :v = n ror 2 * r. let me put it another way , Valid immediate values can be obtained by moving right in a loop .
Here's an example
Valid values :
#256 // 1 Cycle moves to the right 24 position --> 256
#384 // 6 Cycle moves to the right 26 position --> 384
#484 // 121 Cycle moves to the right 30 position --> 484
#16384 // 1 Cycle moves to the right 18 position --> 16384
#2030043136 // 121 Cycle moves to the right 8 position --> 2030043136
#0x06000000 // 6 Cycle moves to the right 8 position --> 100663296 ( Hexadecimal value 0x06000000)
Invalid values:
#370 // 185 Cycle moves to the right 31 position --> 31 Out of range (0 – 30)
#511 // 1 1111 1111 --> The bit model does not conform to
#0x06010000 // 1 1000 0001.. --> The bit model does not conform to
边栏推荐
- 20、wpf之MVVM命令绑定
- sklearnex 让你的 sklearn 机器学习模型训练快得飞起?
- Sword finger offer II 091 Painting house: application of state machine DP
- 什么是Flink?Flink能用来做什么?
- 一套自动化无纸办公系统(OA+审批流)源码:带数据字典
- WebRTC Native M96 基础Base模块介绍之网络相关的封装
- 实现领域驱动设计 - 使用ABP框架 - 系列文章汇总
- A set of automated paperless office system (oa+ approval process) source code: with data dictionary
- 动态代理
- SQL server saves binary fields to disk file
猜你喜欢
![Caused by: org. xml. sax. SAXParseException; lineNumber: 1; columnNumber: 10; Processing matching '[xx][mm][ll]' is not allowed](/img/27/ebf13bdb16978bedbeaa5cd1d780c9.jpg)
Caused by: org. xml. sax. SAXParseException; lineNumber: 1; columnNumber: 10; Processing matching '[xx][mm][ll]' is not allowed

2022年首期Techo Day腾讯技术开放日将于6月28日线上举办

【OceanBase】OceanBase简介及其与MySQL的比较

What are redis avalanche, penetration and breakdown?

VFP serial port communication is difficult for 9527. Maomao just showed his skill and was defeated by kiss

Real software developers will use this method to predict the future

使用php脚本查看已开启的扩展

黑马畅购商城---8.微服务网关Gateway和Jwt令牌

黑马畅购商城---2.分布式文件存储FastDFS

The cloud native data lake has passed the evaluation and certification of the ICT Institute with its storage, computing, data management and other capabilities
随机推荐
How to use SPSS to do grey correlation analysis? Quick grasp of hand-to-hand Teaching
Effective reading of literature
交易期货沪镍产品网上怎么开户
VFP calls the command line image processing program, and adding watermark is also available
黑马畅购商城---2.分布式文件存储FastDFS
Using DBF of VFP to web salary query system
Windows11 MySQL service is missing
JSON format processing
The latest IT learning route in 2020
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.type参数指定强调线的id子集的线条的类型(type)
Database Series: MySQL index optimization summary (comprehensive version)
What are redis avalanche, penetration and breakdown?
Convergence by probability
Dark horse shopping mall ---6 Brand, specification statistics, condition filtering, paging sorting, highlighting
一个硬件工程师走过的弯路
. Using factory mode in net core
Is it safe to open an account and buy stocks? Who knows
Is the online stock trading account opening ID card information safe?
R语言使用glm函数构建泊松对数线性回归模型处理三维列联表数据构建饱和模型、epiDisplay包的poisgof函数对拟合的泊松回归模型进行拟合优度检验(检验模型效果)
Hook技术