能力值:
( LV2,RANK:10 )
|
-
-
3 楼
手册上用的是尺寸法,你要先换成binary,还有BL不是一条指令是两条指令。。。详细再好看看手册!
|
能力值:
( LV4,RANK:40 )
|
-
-
5 楼
写几个向后跳的
地址0X8000000到0X80AAAA8 机器码 0xf0aafd52
地址0X8000004到0X800AAA8 机器码 0xf00afd50
地址0X8000008到0X8000AA8 机器码 0xf000fd4e
|
能力值:
( LV3,RANK:20 )
|
-
-
6 楼
// 怎么样,爽吗
UINT32 ARM_BL(UINT32 src_addr, UINT32 dst_addr)
{
UINT32 offset = dst_addr-src_addr-8;
offset &= 0x3FFFFFF; // 去掉最高6位
offset >>= 2;
return 0xEB000000+offset;
}
|
能力值:
( LV3,RANK:20 )
|
-
-
7 楼
你问的是THUMB的BL吧,不是ARM的。THUMB的在这里:
UINT32 ExchangeHiLo(UINT32 v)
{
UINT32 v1 = v >> 16;
UINT32 v2 = (v & 0xFFFF) << 16;
return v1 + v2;
}
UINT32 THUMB_BL(UINT32 src_addr, UINT32 dst_addr)
{
UINT32 offset = dst_addr-(src_addr+4);
offset &= 0x1FFFFFF; // 去掉最高7位
UINT32 S_ = (offset & 0x1000000) >> 24;
UINT32 I1 = (offset & 0x800000) >> 23;
UINT32 I2 = (offset & 0x400000) >> 22;
UINT32 imm10 = (offset & 0x3FF000) >> 12;
UINT32 imm11 = (offset & 0xFFE) >> 1;
UINT32 J1 = (!I1)^S_;
UINT32 J2 = (!I2)^S_;
S_ <<= 26;
imm10 <<= 16;
J1 <<= 13;
J2 <<= 11;
UINT32 code = 0xF000D000+S_+imm10+J1+J2+imm11;
return ExchangeHiLo(code);
}
|
能力值:
( LV4,RANK:40 )
|
-
-
8 楼
学习啦,CORTEX A8用的也是这种吧,网上搜到过类似代码,但是我不会C语言看不懂。。。
我是自学派初中毕业证都没有,所以只能自己研究上土法啦。
|
能力值:
( LV4,RANK:40 )
|
-
-
10 楼
C语言实在看不懂,第一个函数不知道什么意思,模仿大神算法写了个汇编的
向后跳
bljisuan:
push {r2-r7,lr}
add r0, r0, # 0x04
sub r1, r1, r0
bic r1, r1, # 0xfe000000
ldr r7, = 0x1000000
and r2, r1, r7
lsr r2, r2, # 24
ldr r7, = 0x800000
and r3, r1, r7
lsr r3, r3, # 23
and r4, r1, # 0x400000
lsr r4, r4, # 22
ldr r7, = 0x3ff000
and r5, r1, r7
lsr r5, r5, # 12
movw r7, # 0xffe
and r6, r1, r7
lsr r6, r6, # 1
mvn r3, r3
and r3, r3, # 0x01
mvn r4, r4
and r4, r4, # 0x01
eor r3, r3, r2
eor r4, r4, r2
lsl r2, r2, # 24
lsl r5, r5, # 16
lsl r3, r3, # 13
lsl r4, r4, # 11
ldr r0, = 0xf000d000
add r0, r0, r6
add r0, r0, r5
add r0, r0, r3
add r0, r0, r4
add r0, r0, r2
pop {r2-r7,pc}
去掉J1 J2 S这三个的计算,向前跳的
bljisuan1:
push {r2-r7,lr}
sub r1, r1, r0
add r1, r1, # 0x04
ldr r7, = 0xffe
and r2, r1, r7
lsr r2, r2, # 1
movw r7, # 0x1000
sub r2, r7, r2
ldr r7, = 0x3ff000
and r3, r1, r7
lsr r3, r3, # 12
mov r7, # 0xff
sub r3, r7, r3
lsl r3, r3, # 16
ldr r0, = 0xf700f000
add r0, r0, r2
add r0, r0, r3
pop {r2-r7,pc}
验证一下
ldr r0, = 0x830a
ldr r1, = 0xcd9c
bl bljisuan1
mov r11, r0
ldr r0, = 0x8bd0
ldr r1, = 0xcd82
bl bljisuan
mov r12, r0
向前跳结果放在R11 向后跳结果放在R12
|