C to Assembly Code

Discussion in 'OT Technology' started by GSRacer2102, Mar 7, 2003.

  1. GSRacer2102

    GSRacer2102 Active Member

    Joined:
    Nov 16, 2001
    Messages:
    14,260
    Likes Received:
    0
    Location:
    Texas
    How do you go about looking at the assembly code for a C program?
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    you would need a decompiler
     
  3. crotchfruit

    crotchfruit Guest

    to build on what SLED suggested:

    there is a program that comes with most windows/dos distros: debug.exe

    run 'debug <program>' and you will be presented with a '-' prompt. from there, enter '?' to see all of your options. you'll be interested in (d)ump and (u)nassemble. play around with it.
     
  4. GSRacer2102

    GSRacer2102 Active Member

    Joined:
    Nov 16, 2001
    Messages:
    14,260
    Likes Received:
    0
    Location:
    Texas
    i tried doing it but it just closes the execute window
     
  5. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    Most C compilers can output assembly. For VC++, type the following from a command line: cl -c code.c -Facode.a
    This will compile your code.c and output the assembly to a file named code.a

    In gcc type: gcc -O2 -S -c code.c
    The -S option will save the assembly listing to a file named code.a
     
  6. GSRacer2102

    GSRacer2102 Active Member

    Joined:
    Nov 16, 2001
    Messages:
    14,260
    Likes Received:
    0
    Location:
    Texas
    how do i do that expalin??:(
     
  7. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    Are you using VC++ or gcc?
     
  8. GSRacer2102

    GSRacer2102 Active Member

    Joined:
    Nov 16, 2001
    Messages:
    14,260
    Likes Received:
    0
    Location:
    Texas
    u are too l33t what do u mean?
    c++ compiler or c compiler?
     
  9. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    Are you using Microsoft's C/C++ compiler, or are you using a GNU compiler on linux or some form of UNIX?
     
  10. GSRacer2102

    GSRacer2102 Active Member

    Joined:
    Nov 16, 2001
    Messages:
    14,260
    Likes Received:
    0
    Location:
    Texas
    I am using MetroWerks CodeWarrior so i guess thats a Microsoft C/C++ compiler
     
  11. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    No, it's not Microsoft's compiler. I've never used Metrowerks before. You're on your own to figure out if it provides the option to output assembly code.
     
  12. GSRacer2102

    GSRacer2102 Active Member

    Joined:
    Nov 16, 2001
    Messages:
    14,260
    Likes Received:
    0
    Location:
    Texas
    what do i need to do?
    where should I look?
     
  13. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    See if Metrowerks has a command line compiler. It's a compiler you can run from a command prompt (DOS box). Then you have to see if it takes a parameter to generate assembly code.

    In the example I gave you, Microsoft's command like compiler is cl.exe. To compile code from a command line, I would execute the command: cl -c code.c. This compiles code.c and generates an object file. If I add the -Facode.a option (cl -c code.c -Facode.a), I also get a file named code.a which contains the assembly code.
     
  14. GSRacer2102

    GSRacer2102 Active Member

    Joined:
    Nov 16, 2001
    Messages:
    14,260
    Likes Received:
    0
    Location:
    Texas
    I found it
    do you know if programs that test for the similarities between files test each and every line or do they just test for certain amount of line or how is it done?
     
  15. Dopeskills

    Dopeskills Nothing can beat the Hyundai !!!

    Joined:
    Feb 19, 2003
    Messages:
    326
    Likes Received:
    0
    Location:
    New Jersey
    The assembly output is going to be long as hell...

    I've done this before in g++/gcc <waste of time>
     
  16. kcarlson78

    kcarlson78 Meanwhile, Jesus continued to shake his head in ex

    Joined:
    Jun 27, 2002
    Messages:
    4,490
    Likes Received:
    0
    Location:
    Phoenix, AZ
    hmmmm I wonder if I could get away with that for my assembly language class... projects would be much easier to code in C++ and then convert.. ;)

    j/k.. interesting to know.. will have to play with it now..
     

Share This Page