interpreting assembly instructions
I am trying to translate the following:
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
m开发者_StackOverflow社区ovl -0x4(%ebp), %eax
sall $0x2, %ebp
addl 0x8(%ebp), %ebp
movl (%ebp), %ebp
addl %ebp, -0x8(%eax)
addl $0x1, -0x4(%eax)
What is the best way to translate this code?
For the original question:
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'
Dry-running the statements give:
y[z + 4][3] = 'A';
精彩评论