I am trying to convert this assembly code into a C snippet.
movl $0, -4(%ebp) # 4
movl -4(%ebp), %eax
sall $2, %eax
addl 8(%ebp), %eax
movl (%eax), %eax
cmpl 12(%ebp), %eax
jg .L6
.L6:
nop
Here's what I have so far, but I think something is wrong. The line "movl (%eax), eax" confuses me in particular.
int local = 0;
if ((int*)((local << 2) + param1) > parameter2) {
; // do nothing
}
Your interpretation of movl %(eax), %eax
is correct, but that of the line addl 8(%ebp), %eax
is not. The correct code whould be something like this:
// parameter1 is an int* at 8(%ebp)
// parameter2 is an int at 12(%ebp)
int local = 0; // at -4(%ebp)
if (parameter1[local] > parameter2) {
; // nop
} else {
// whatever is betwween jg and .L6
}