Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, Can any one please guide me how to generate assembly code for a C coden using gcc compiler? The generated assembly code should have startup routine, initialisation routine, main ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2012
    Posts
    3

    C code and its associated assembly code


    Hi,

    Can any one please guide me how to generate assembly code for a C coden using gcc compiler? The generated assembly code should have startup routine, initialisation routine, main routine and finalising routine.
    Will be awaiting eagerly for the response. Thanks in advance.

    -Janardhan N L

  2. #2
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,569
    I believe you use the -S switch with the -c switch. -S will generate an appropriately named assembly source and the -c switch stops the linker from running, so the command
    Code:
    gcc -O2 -S -c helloworld.c
    will give a helloworld.s with the assembly. Presumably, whether it has the specified routines depends on the c code?
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    The Fifth Continent

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •