i am presently working on C but there are some situations i need to know the assembly code of corresponding C program.

if any can provide some general info of c - assembly it would be appreciated.

i have a program called

int main()
       printf("Hello,Plz Help\n");
       return 0;

if i run this program on Gcc compiler with -S option i could see some assembly instructions.

this is what it is generating . but i am unable to understand
it.below are few questions.

.file   "assm-c.c"
        .section        .rodata
        .string "Hello, Plz help\n"
.globl main
        .type   main,@function
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        andl    $-16, %esp
        movl    $0, %eax
        subl    %eax, %esp
        subl    $12, %esp
        pushl   $.LC0
        call    printf
        addl    $16, %esp
        movl    $0, %eax
        .size   main,.Lfe1-main
        .ident  "GCC: (GNU) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)"

what is .rodata
what is .LC0
and what is the procedure that is written in main:
it may be internal processor dependent what it is generating here.
but i want to know what are the general things that are done when converting to assembly.

i have some idea with fucntions
when ever a function is called .
1.push the arguments from right to left into the stack ( meaning allocate memory on stack)
2.push the return address of the function(caller's address)
3.push the base address of functions(caller' s again)
4. allocate memory for the locals.

and when the function returns clering the contents from the stack(dont have idea what does this mean)

is the above procedure correct or do i need to make any changes.

requesting you to guide me in correcting my mistakes and furthur updations.

7 Years
Discussion Span
Last Post by gerard4143
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.