Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-07-2007, 04:43 AM
Kaishain Kaishain is offline
Newbie
 
Join Date: Dec 2007
Posts: 3
Credits: 0
Rep Power: 0
Kaishain is on a distinguished road
Default C++ to ***embly conversion

Hello,

I'm looking for a way of getting an ***embly version of my programs. For example, I have the below (small) program called average.c:

Code:
#include <stdio.h>
float average(float x, float y);
int main() {
        float a, b, c;
        a = 1;
        b = 3;
        c = average(a, b);
        printf("The average of %f and %f is %f.\n", a, b, c);
}
float average(float x, float y) {
        float z;
        z = (x + y) / 2; /* The average */
        return z;
}

I want to convert this to an ***embly version, something like the following:

Code:
0x08048390 <main+32>: sub   $0x8,%esp
0x08048393 <main+35>: pushl 0xfffffff8(%ebp)
0x08048396 <main+38>: pushl 0xfffffffc(%ebp)


At the moment, I'm using the command 'gcc -S average.c', but it is only giving me the following type of ***embly:

Code:
main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        andl    $-16, %esp
        movl    $0, %eax

Does anyone know of a way to convert my C file to an ***embly file that contains all the memory addresses, etc., as per the second piece of code above?


Thanks,
K
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 12-07-2007, 12:40 PM
G_Morgan G_Morgan is online now
Guru
 
Join Date: Oct 2007
Age: 24
Posts: 442
Last Blog:
Just over the next hil...
Credits: 44
Rep Power: 8
G_Morgan has a spectacular aura aboutG_Morgan has a spectacular aura aboutG_Morgan has a spectacular aura about
Default

***embly usually uses relocatable code so won't hard code addresses. It deals with symbolic addresses rather than actual addresses. You won't get addresses until the loader has got the program running.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-09-2007, 11:00 AM
Kaishain Kaishain is offline
Newbie
 
Join Date: Dec 2007
Posts: 3
Credits: 0
Rep Power: 0
Kaishain is on a distinguished road
Default

Thanks for the reply!

When I run the program through GDB, I can type in, say, "main+52" and it comes up with some debugging information including the memory address of that piece of code.

Is there a way of doing something similar, but to all of the code at once? I don't want to have to type "main+1", "main+2", etc. all the way through the program as it'd just take forever...


Thanks again,
K
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-09-2007, 03:12 PM
G_Morgan G_Morgan is online now
Guru
 
Join Date: Oct 2007
Age: 24
Posts: 442
Last Blog:
Just over the next hil...
Credits: 44
Rep Power: 8
G_Morgan has a spectacular aura aboutG_Morgan has a spectacular aura aboutG_Morgan has a spectacular aura about
Default

Sorry I don't know, I don't use GDB. I find unit testing to be far quicker and more effective than traditional debuggers.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-10-2007, 04:07 AM
Kaishain Kaishain is offline
Newbie
 
Join Date: Dec 2007
Posts: 3
Credits: 0
Rep Power: 0
Kaishain is on a distinguished road
Default

I'll keep looking then. There must be a way of showing all the memory locations of pieces of code during run-time. Thanks for your replies anyway!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free ***embly Tutorials Jordan General Programming 39 10-05-2008 04:40 PM
***embly Applications skilletsteve General Programming 8 08-25-2006 06:32 PM
Companies That Hire ***embly Programmers encoder General Programming 14 08-01-2006 04:28 PM
***embly usage DevilsCharm General Programming 2 07-13-2006 12:54 PM
***embly tutorials Kaabi General Programming 1 07-05-2006 11:18 AM


All times are GMT -5. The time now is 10:58 AM.

Contest Stats

Xav ........ 1323.18
MeTh0Dz|Reb0rn ........ 1053.7
morefood2001 ........ 879.43
John ........ 877.37
marwex89 ........ 869.98
WingedPanther ........ 837.78
Brandon W ........ 749.07
chili5 ........ 310.39
Steve.L ........ 241.84
dcs ........ 216.02

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads