我试图理解一些汇编代码片段:
".syntax unified\n"
"1:\n"
" NOP\n"
" NOP\n"
" NOP\n"
" NOP\n"
" NOP\n"
" CMP %[SystemCoreClock],%[clock16MHz]\n"
" BEQ.n 2f\n"
" NOP\n"
" NOP\n"
" NOP\n"
" NOP\n"
" NOP\n"
" NOP\n"
" NOP\n"
" NOP\n"
" NOP\n"
"2:\n"
" SUBS %0, %0, #1\n"
" BNE.n 1b\n"
".syntax divided\n"
当程序分支到行中的标签2时,“f”的含义是什么:
" BEQ.n 2f\n"
和行中带“b”的分支有什么区别
" BNE.n 1b\n"
答案 0 :(得分:1)
这是一个特定于gnu汇编语言的懒惰程序员快捷方式AFAIK。 (汇编语言由汇编程序定义,程序读取它,有许多arm,mips,x86等汇编语言)
1:
2:
b 1b
b 2b
b 1f
b 2f
2:
b 1b
b 1f
1:
nop
nop
汇编然后反汇编
00000000 <.text>:
0: eafffffe b 0 <.text>
4: eafffffd b 0 <.text>
8: ea000002 b 18 <.text+0x18>
c: eaffffff b 10 <.text+0x10>
10: eafffffa b 0 <.text>
14: eaffffff b 18 <.text+0x18>
18: e1a00000 nop ; (mov r0, r0)
1c: e1a00000 nop ; (mov r0, r0)