Solved

ia32 assembly to c

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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 writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

776 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