[編輯] 有人可以向我解釋在這個問題中,我們如何得到M和N的值,遍歷相應彙編代碼的每一行?反編譯IA32 32位AT&T彙編代碼中的一個函數C
我總是被困在movl array2部分。我們如何推導出常數M和N的值:
M和N常量使用#
#define M <some value>
#define N <some value>
int array1[M][N];
int array2[N][M];
int copy(int i, int j)
{
array1[i][j] = array2[j][i];
}
如果上述代碼生成以下彙編代碼中定義?
copy:
pushl %ebp
movl %esp, %ebp
pushl %ebx
movl 8(%ebp), %ecx
movl 12(%ebp), %ebx
leal (%ecx, %ecx, 8), %edx
sall $2, %edx
movl %ebx, %eax
sall $4, %eax
subl %ebx, %eax
sall $2, %eax
movl array2(%eax, %ecx, 4), %eax
movl %eax, array1(%edx, %ebx, 4)
popl %ebx
movl %ebp,%esp
popl %ebp
ret
你真的希望我們輸入所有的?不要發佈代碼圖片!請解決你的問題。 – ikegami
爲什麼代碼爲圖像? –
當你說「我們得到M和N的值」時,你是什麼意思?你的意思是'我'和'j'? – ikegami