Link to home
Start Free TrialLog in
Avatar of KeithStone
KeithStoneFlag for United States of America

asked on

ia32 assembly to c

The following is a function that returns either 1 or 0 based on the provided input.
_test:
       pushl       %ebp
       movl       %esp,      %ebp
       subl       $24,      %esp
       movl       8(%ebp),      %eax
       movl       %eax,      -4(%ebp)
       movl       -4(%ebp),      %eax
       movl       %eax,      (%esp)
       call       _strlen
       movl       %eax,      -16(%ebp)
       movl       -16(%ebp),      %eax
       cmpl       $1,      %eax
       jg       LBB1_2
       movl       $1,      -12(%ebp)
       jmp       LBB1_5
LBB1_2:
       movl       -4(%ebp),      %eax
       movb       (%eax),      %al
       movl       -16(%ebp),      %ecx
       subl       $1,      %ecx
       movl       -4(%ebp),      %edx
       movb       (%edx,%ecx),      %cl
       cmpb       %cl,      %al
       je       LBB1_4
       movl       $0,      -12(%ebp)
       jmp       LBB1_5
LBB1_4:
       movl       -16(%ebp),      %eax
       subl       $1,      %eax
       movl       -4(%ebp),      %ecx
       movb       $0,      (%ecx,%eax)
       movl       -4(%ebp),      %eax
       addl       $1,      %eax
       movl       %eax,      (%esp)
       call       _test
       movl       %eax,      -12(%ebp)
LBB1_5:
       movl       -12(%ebp),      %eax
       movl       %eax,      -8(%ebp)
       movl       -8(%ebp),      %eax
       addl       $24,      %esp
       popl       %ebp
       ret
a. Provide an input for which this function will return 1. What does this function do?
b. Write the equivalent C function.
c. The performance of this function will be abysmal. There are two major issues with the code.
Identify them and rewrite the function to perform better.
Avatar of KeithStone
KeithStone
Flag of United States of America image

ASKER

I believe that the program is checking for palindromes, but im not really sure about parts b and c
ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're right, ill get it done myself