Skip to content

Instantly share code, notes, and snippets.

@lichenbo
Created October 31, 2012 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lichenbo/3985638 to your computer and use it in GitHub Desktop.
Save lichenbo/3985638 to your computer and use it in GitHub Desktop.
00401488 mov -0x4(%ebp),%eax ;i赋给$eax(i已被初始化为0)
0040148B shl $0x2,%eax ;$eax向左移2位(即乘4来计算偏移量)
0040148E add -0x10(%ebp),%eax ;$eax加上基址,计算出data[i]的地址,赋给$eax
00401491 mov (%eax),%eax ;取出data[i]的数据,并且赋给$eax
00401493 mov -0x8(%ebp),%edx ;取出x,赋给%edx
00401496 imul %edx,%eax ;$eax = $edx * $eax
00401499 mov %eax,-0x8(%ebp) ;x = $eax
0040149C incl -0x4(%ebp) ;i++
0040149F mov -0x4(%ebp),%eax ;i赋给eax
004014A2 cmp -0xc(%ebp),%eax ;比较length和i
004014A5 jl 0x401488 ;如果i < length,跳至00401488(即这段代码开始),实现循环
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment