当前位置:网站首页>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
边栏推荐
- 图片打标签之获取图片在ImageView中的坐标
- ArcGIS services query filter by time field
- JS indexof() always returns -1
- Sword finger offer II 091 Painting house: application of state machine DP
- 开哪家证券公司的账户是比较好,比较安全的
- 网络 | 衡量网络好坏的指标及测试方法
- Startups must survive
- 做自媒体视频需要怎么做才能年收入一百万?
- Evaluating the overall situation of each class in a university based on entropy weight method (formula explanation + simple tool introduction)
- How do super rookies get started with data analysis?
猜你喜欢
Why can't you Ping the website but you can access it?
confluence7.4. X upgrade record
Rank sum ratio comprehensive evaluation method for common models in mathematical modeling
Redis雪崩、穿透和击穿是什么?
Startups must survive
15、wpf之button样式小记
Why can't the form be closed? The magic of revealing VFP object references
How to use SPSS to do grey correlation analysis? Quick grasp of hand-to-hand Teaching
20、wpf之MVVM命令绑定
使用php脚本查看已开启的扩展
随机推荐
Is the online stock trading account opening ID card information safe?
Simple use of stream
【OceanBase】OceanBase简介及其与MySQL的比较
R语言dist函数计算dataframe数据中两两样本之间的距离返回样本间距离矩阵,通过method参数指定距离计算的方法、例如欧几里得距离
Quarkus SaaS dynamic data source switching implementation, simple and perfect
客户经理的开户二维码开户买股票安全吗?有谁知道啊
R语言使用glm函数构建泊松对数线性回归模型处理三维列联表数据构建饱和模型、epiDisplay包的poisgof函数对拟合的泊松回归模型进行拟合优度检验(检验模型效果)
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用epiDisplay包的lrtest函数执行多个模型似然比检验对比两个模型的性能是否有差异
SQL server saves binary fields to disk file
Evaluating the overall situation of each class in a university based on entropy weight method (formula explanation + simple tool introduction)
Hook技术
How to use ARIMA model for prediction?
一个硬件工程师走过的弯路
[regression analysis] understand ridge regression with case teaching
Thirty lines of code prevent VFP forms from running repeatedly, and the function supports parameter transfer
Rank sum ratio comprehensive evaluation method for common models in mathematical modeling
RecyclerView滚动到指定位置
云原生数据湖以存储、计算、数据管理等能力通过信通院评测认证
Understanding and construction of devsecops and Devops
19. Implementation of MVVM architecture based on WPF event to command