Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ia32 assembly to c

Posted on 2013-12-13
3
Medium Priority
?
502 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 46

Accepted Solution

by:
Kent Olsen earned 1500 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

721 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