My question is geared towards the IA32 Assembly language that a C program produces. I've been given the following and my task is to figure out what the funciton does. I've written my comments next to each line and as far as I can tell it looks to me that if local variable a >= y then 0 gets returned, if not then other actions are taken until a is > and then a value for b is returned. Any help on exactly what this function does would be greatly appreciated.
Code:pushl %ebp movl %esp, %ebp subl $16, %esp movl $0, -8(%ebp) SET LOCAL VARIABLE B TO 0 movl $0, -4(%ebp) SET LOCAL VARIABLE A TO 0 jmp .L2 JUMP TO L2 IF (A<Y) .L3: movl -4(%ebp), %eax MOVE A TO EAX sall $2, %eax A * 2^2 IN EAX addl 8(%ebp), %eax ADD X + A IN EAX movl (%eax), %eax MOVE (X + A) IN EAX addl %eax, -8(%ebp) ADD (X + A) IN B addl $1, -4(%ebp) ADD 1 TO A .L2: movl -4(%ebp), %eax MOVE A TO EAX cmpl 12(%ebp), %eax COMPARE A TO Y jl .L3 IF A < Y JUMP TO L3 movl -8(%ebp), %eax MOVE B TO EAX leave ret RETURN B



LinkBack URL
About LinkBacks



