考慮下面的源代碼,其中,R,S,和T是與#定義聲明的常量:有故障判定常數在這個彙編代碼
int A[R][S][T];
int store_ele(int i, int j, int k, int *dest)
{
*dest = A[i][j][k];
return sizeof(A);
}
在編譯該程序,GCC生成以下組件的代碼:
i at %ebp+8, j at %ebp+12, k at %ebp+16, dest at %ebp+20
1. movl 12(%ebp), %edx //move j into register %edx
2. leal (%edx, %edx, 8), %eax //move address %edx+%edx*9 into %eax
3. leal (%edx, %eax, 4), %eax //move address %edx + %eax*4 into %eax
4. imull $111, 8(%ebp), %edx //111*i goes into %edx
5. addl %edx, %eax
6. addl 16(%ebp), %eax //add k to %eax
7. movl A(, %eax, 4), %edx //%eax*4 offset by address of A moved into %edx
8. movl 20(%ebp), %eax
9. movl %edx, (%eax)
10. movl $888, %eax
我知道最後一條指令 'MOVL $ 888%EAX' 說有888個字節,這相當於222個int(我*∫* K)。正如你所看到的,我知道每條指令都在做什麼,但是我很難逆向工程來確定傳遞給i,j和k的常量。
我不期待答案,但任何提示點我在正確的方向將不勝感激
你正在使用哪個版本? –
在查看代碼後,我能夠確定%edx經歷了一系列算術運算,然後在指令9%處將edx作爲解除引用移至%eax(其被設置爲當時的地址A) 。另外,非常感謝無論誰編輯我的帖子以適合適合的格式,我是本站的noob。 – user3296049
這個版本是ATT – user3296049