Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    C code and its associated assembly code


    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
    Either at home or at work or down the pub
    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
    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?
    Should you be sitting wondering,
    Which Batman is the best,
    There's only one true answer my friend,
    It's Adam Bloody West!

    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