+91 9945200008     support@uttaracomputers.com
LOGIN     REGISTER    

A basic question

0
0

When a program is written for  a Micro processor / Micro controller( may be 8 bit 8051 controller / earlier 8086 processors, The  code (after compilation & linking)  will be stored in code memory area of the microcontroller or in an  external memory ( EPROM /FLASH) . During execution, the processor fetches the instruction directly from program memory and executes

 

Now the question is what happens when I write a C program on a desktop computer (let us say by using Turbo C compiler) and do as per below steps:

 

a file test.c is created, some program is written, the file is compiled and executed. Now there are three files test.c, test.obj and test.exe stored in hard disk.

 

Now I reboot the PC, and clicked on test.exe ( without opening the source code test.c)

The program runs and I can see the output.

 

I want to understand : when I clicked the exe file whether, the CPU fetches the instruction directly from hard disk and executes  similar to the process mentioned in first paragraph / anything else happens here?

  • You must to post comments
0
0

When you compile the C program test.c, the C compiler reads the file; translates the C code to CPU instructions ( but with relative offsets for addresses ); writes out the binary code to the file test.obj.  (REFER To the COMPILATION steps discussed in Sessions 18 through 22). Then the linker ( linking loader ) combines the needed library functions from the archive files on the hard disk; converts all addresses to absolute values; and writes out the binary code as the executable file test.exe (, say).  (REFER To the LINKING steps discussed in Sessions 23 and 24).  When you click test.exe ( Or run it from command line ), the Operating system loads the binary instructions from the executable file into the RAM ( memory ) and CPU starts executing the instructions that are in memory.

MLS Shastry

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.