Need help with .exe file ??

This is a discussion on Need help with .exe file ?? within the C Programming forums, part of the General Programming Boards category; After Compiling an Error Free C Program we get an .exe file. I have Few Doubts considering this .EXE file ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Location
    Lucknow, India
    Posts
    72

    Need help with .exe file ??

    After Compiling an Error Free C Program we get an .exe file. I have Few Doubts considering this .EXE file !!
    1. is it true that generated .exe file contains only machine code ??
    2. if it is in machine code then Can we run this file at any System ??

    3. Suppose I write a program in C to print my name and then I copy my .exe file into a blank CD. After Removing my HD from my Computer if I boot my PC with this CD then Is it true that my .exe file will be executed by BIOS ????

    please Help me guys. I didnt hve any CD drive Right Now So i cant even test my Assumption no 3 as Well.!!!
    PLEASE HELP !!!! ^-^

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Gaurav Singh View Post
    After Compiling an Error Free C Program we get an .exe file. I have Few Doubts considering this .EXE file !!

    1. is it true that generated .exe file contains only machine code ??
    No. It also conatins constant data, resource information and variable mapping.

    2. if it is in machine code then Can we run this file at any System ??
    No. A windows program will run on any windows system. A linux program will run on any linux system.
    But, no, you don't get to directly execute windows proggies on linux or visa versa.

    The last time you asked this the conversation devolved into a confusing blather about emulators and such...
    Believe me... the answer is NO.

    3. Suppose I write a program in C to print my name and then I copy my .exe file into a blank CD. After Removing my HD from my Computer if I boot my PC with this CD then Is it true that my .exe file will be executed by BIOS ????
    ABSOLUTELY NOT! And thank goodness for that!

    Consider how many problems that would cause.
    Last edited by CommonTater; 02-08-2011 at 11:24 AM.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Location
    Lucknow, India
    Posts
    72
    thanks TATER. thanks A lot.
    You are really a good buddy. :-)

  4. #4
    Registered User
    Join Date
    Dec 2010
    Location
    Lucknow, India
    Posts
    72
    Someone please suggest me that in Which Direction i should Start Study if i want to write a Code of a bootable file for my PC... no matter what the Task is coded...
    I just want to write the Code in C which can be Boot by BIOS after removing the HARD DISK !!

    i.m using windows XP. Compiler: Borland C

  5. #5
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    I'm not really very sure what your trying to do. To run your code just after the bootup would be quite difficult but not impossible. When you initialise/boot your system the first pieces of code will be executed such as ResetCode, Hardware initialisation and then startup code. The tricky part here to write these code specially the startup code would be quite challenging. The reason why I say that is because you need to understand your hardware before you can write on of those modules. A startup is effectively a collection of assembly code, which enabled you run your high-level code. Taking C as an example, to run a C code, you need a stack allocated in your memory. The startup code

    1. Disables all the Interrupts
    2. Copy any initialised data from ROM to RAM
    3. Zero the uninitialized data area
    4. Allocate space for and initialise the stack
    5. Initialise the processor's stack pointer

    And then finally call main (which would eventually be your .exe file). Startup code is usually names startup.asm.

    Might be slightly different with the PC's. But the above strategy applies for almost all embedded systems

    ssharish.
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Gaurav Singh View Post
    Someone please suggest me that in Which Direction i should Start Study if i want to write a Code of a bootable file for my PC... no matter what the Task is coded...
    I just want to write the Code in C which can be Boot by BIOS after removing the HARD DISK !!

    i.m using windows XP. Compiler: Borland C
    Ok every journey begins with the first step.... here's the first 3...

    1) Update your compiler. Turbo C is probably older than you are. It's 16 bits and there's no modern computer that's going to boot from 16 bit code. Seriously, get yourself out of the stone age... smorgasbordet - Pelles C

    2) Learn about computers... some of what you are on about is just scarey ridiculous and you absolutely need to temper that with an ounce of knowledge and a pound of wisdom.

    3) Learn about C... learn the language, read the books, do the exercises, get experience, write code... lots and lots of code... get good at it.

    Then, maybe a couple of years from now, dredge this back up and see if it still seems like a good idea....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21