How to know some info?

John S. Fine johnsfine@verizon.net
Mon Nov 2 18:06:00 GMT 2009


There is no automatic way to write an ordinary C program to generate 
specific assembler code.  GCC has inline assembler directives, so I 
expect you could put the asm code directly into a .c file that would 
compile as the same asm code.  But that obviously is not the intent of 
the question.

What kind of test or homework was this from?  I don't think doing it for 
you is appropriate.

But here is the easy part:  64 bit x86 uses rsp and rbp for stack and 
frame pointers.  The other 64 bit registers are often used in their 32 
bit forms in 64 bit code, either because the operation is 32 bit or 
because the compiler knows the high 32 of 64 bits must be zero in that 
operation.  But the stack pointer in 64 bit architecture is 64 bit.

johncaponski wrote:
> Hi everyone! I've got an AT&T GNU assembler code produced by the compilation
> of a C programme that I don't know. I need to answer some cuestions about
> it. The thing is that I want to know how could I get that information using
> gcc compiler, I mean, I just want to know the options I should use with gcc
> and "myfile.s" to get that info.
>
> The cuestions are:
>
> - What architecture was this code compiled for?
> - 32 or 64 bits?
>
> In addition to that, I am asked to write the C programme that generated that
> code. Is there any automatic way to do that?
> This is the code:
>
>        .file "practica2_funcion.c"
>        .text
>        .p2align 4,,15
> .globl funcion
>        .type funcion, @function
> funcion:
>        pushl %ebp
>        movl    %esp, %ebp
>   



More information about the Gcc-help mailing list