一千萬個為什麽

搜索

解釋裝配說明


我想翻譯以下內容:

Action:
 pushl %ebp
 movl %esp, %eax
 subl $0x32, %esp
 movl $0x0, -0x8(%eax)
 movl $0x0, -0x4(%eax)
 movl -0x4(%eax), %eax
 cmpl $0x32(%eax), %ebp
 movl -0x4(%ebp), %eax
 sall $0x2, %ebp
 addl 0x8(%ebp), %ebp
 movl (%ebp), %ebp
 addl %ebp, -0x8(%eax)
 addl $0x1, -0x4(%eax)

翻譯此代碼的最佳方法是什麽?

最佳答案

對於原始問題:

mov     -0x4(%ebp), %eax       # eax = z;
mov     0xc(%ebp), %edx        # edx = y;
mov     (%edx, %eax, 4), %eax  # eax = *(edx + eax + 4)
add     $0x3, %eax             # eax += 3
movb    $0x41, (%eax)          # *eax = 'A'

幹掉這些陳述給出了:

y[z + 4][3] = 'A';

轉載註明原文: 解釋裝配說明

猜你喜歡