|
||||||
| 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. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 |
| Sponsored Links |
|
|
|
|||
|
***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.
|
|
|||
|
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 |
|
|||
|
Sorry I don't know, I don't use GDB. I find unit testing to be far quicker and more effective than traditional debuggers.
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |
| 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 |
Goal: 100,000 Posts
Complete: 82%