ARM汇编指令
1. 汇编语法
1.1 mov
movw r0, #63500 ; 0xf80c
将63500放到r0寄存器的低八位中
movt r0, #25667 ; 0x6443f80c
将25667放到r0寄存器的高八位中
1.2 lsl 左移
stmdb sp!, {r4, r5, r6, r7, sl, lr}
ldrb.w r6, [sp, #44] ; 0x2c
movs r0, #16
lsl.w r1, r0, r6
1.3 bx lr 返回值
bx lr
返回值放在r0寄存器中
1.4 数组加载:注意数组在地址上的偏移需要 -* 4,而Index是正常的 * 1
28003a6e: f641 7152 movw r1, #8018 ; 0x1f52
28003a72: f6c2 017f movt r1, #10367 ; 0x287f
28003a76: 7808 ldrb r0, [r1, #0]
28003a78: f855 1020 ldr.w r1, [r5, r0, lsl #2]
1.5 bne 判断不相等:判断r1寄存器是否等于0
2. 文件修改
1. 头文件和变量整理到模板中
2. 变量的赋值
1. 删掉extern
-
在full.log中查找变量
5dd87 . DW_TAG_variable DW_AT_name("xxx") DW_AT_decl_line(32) DW_AT_decl_column(23) DW_AT_decl_file(1) DW_AT_type(0x5c36a) DW_AT_external(true) DW_AT_declaration(false) DW_AT_location: addr(0x287f1f70)
-
继续查找
DW_AT_type(0x5c36a)
5c36a . TAG_array_type DW_AT_ordering(ORD_row_major) DW_AT_byte_size(20) DW_AT_type(0x5c365) 5c371 . . TAG_subrange_type DW_AT_type(0x5bfdf) DW_AT_byte_size(4) DW_AT_lower_bound(0) DW_AT_upper_bound(4)
数组变量5个,继续向下查找
- 变量为指针变量
5c365 . TAG_pointer_type DW_AT_type(0x5dc45)
- 找到最终的变量类型-结构体变量
5dc45 . TAG_typedef DW_AT_name("xxx") DW_AT_decl_line(290) DW_AT_decl_column(3) DW_AT_decl_file(39) DW_AT_type(0x5dc2a)
5dc2a . TAG_structure_type DW_AT_decl_line(288) DW_AT_decl_column(1) DW_AT_decl_file(39) DW_AT_byte_size(65536) DW_AT_accessibility(DW_ACCESS_public)