当我们写一个连续switch(个数大于三个)判断时,查看汇编指令时,会出现
0x104fcd8bc <+68>: ldrsw x10, [x8, x11, lsl #2]
那么ldrw指令是干嘛的,我来讲解一下,如果有错误,请指明谢谢!
x8 + x11 左移2位赋值给x10 = x8 + 8 (因为x11里面存的2,然后向左移2位就是8)
register read x8
x8 = 0x0000000104fcd938 aaaaaaaaa`add + 192
x 0x0000000104fcd938
0x104fcd938: 9c ff ff ff a8 ff ff ff b4 ff ff ff c0 ff ff ff ................
0x104fcd948: cc ff ff ff d8 ff ff ff e4 ff ff ff f0 ff ff ff ................
register read x11
x11 = 0x0000000000000002
x11 左移二位为8
x10 = x8 + 8 (即:ff ff ff 9c + 8 ----> ff ff ff b4)
x10 = ff ff ff b4