有人能帮我理解那些装配线吗?

时间:2014-09-11 21:16:56

标签: assembly

有人可以帮我理解这个用于汇编下面的循环吗?

   0x08048d27 <+37>:    mov    $0x1, %ebx       //set ebx = 1
   0x08048d2c <+42>:    lea    -0x20(%ebp),%esi     //set esi to the address of the first element of the array
   0x08048d2f <+45>:    mov    -0x4(%esi,%ebx,4),%eax   //eax = esi + ebx * 4
   0x08048d33 <+49>:    sub    %ebx,%eax        //phase
   0x08048d35 <+51>:    cmp    %eax,(%esi,%ebx,4)

   0x08048d38 <+54>:    je     0x8048d3f <phase_2+61>

   0x08048d3a <+56>:    call   0x8049108 <explode_bomb>

   0x08048d3f <+61>:    add    $0x1,%ebx
   0x08048d42 <+64>:    cmp    $0x6,%ebx
   0x08048d45 <+67>:    jne    0x8048d2f <phase_2+45>
   0x08048d47 <+69>:    add    $0x30,%esp
   0x08048d4a <+72>:    pop    %ebx
   0x08048d4b <+73>:    pop    %esi
   0x08048d4c <+74>:    pop    %ebp

我特别困惑&#34; mov -0x4(%esi,%ebx,4),%eax&#34;和&#34; cmp %eax,(%esi,%ebx,4)&#34;,这些是什么意思?

谢谢!

1 个答案:

答案 0 :(得分:1)

mov    -0x4(%esi,%ebx,4),%eax

eax的值设置为[esi + ebx*4 - 4]

处的值
cmp    %eax,(%esi,%ebx,4)

eax[esi + ebx*4]

处的内容进行比较