Solved

ia32 assembly to c

Posted on 2013-12-13
3
477 Views
Last Modified: 2013-12-13
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.
0
Comment
Question by:KeithStone
  • 2
3 Comments
 

Author Comment

by:KeithStone
ID: 39716932
I believe that the program is checking for palindromes, but im not really sure about parts b and c
0
 
LVL 45

Accepted Solution

by:
Kdo earned 500 total points
ID: 39717115
Hi Keith,

This is clearly an assignment of some sort, probably class/school work.  As such, out ability to help is limited so that we all maintain a high degree of academic integrity.

One thing that we can't do is rewrite this for you.  Short of that, how can we help?


Kent
0
 

Author Closing Comment

by:KeithStone
ID: 39717233
You're right, ill get it done myself
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now