Solved

ia32 assembly to c

Posted on 2013-12-13
3
488 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 45

Accepted Solution

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

733 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