suppose that i write a program in turbo c:

Q1.) the operating system program is in RAM.(yes or no?)
Q2.) the turbo c application is in RAM. (yes or no?)

suppose that i have written this simple code:

#include <stdio.h>
void main()
int a=2,b=3,c;

<before compilation>
Q3.) when i start writing this code, and till i finish everything goes into RAM (yes or no?)
3.a) if every character does not go into RAM then where does it go?
3.b) after the program is written in what form is it , is it in the form of symbols and characters like it appears on screen, or in the form of ASCII code,or assembly code(MOV,JMP etc.) or in form of 0's and 1's. (before compilation).

<during/after compilation>
Q4.) i want to know what happens after assembly code is generated.i am confused about the concept of 'relocatable' machine cod, linker-loader and 'relocatable' object file.

4.a) and what does it mean that library functions are in relocatable format, arent they stored in the physical memory(RAM) while turboc application is being run.

Q5.) in the final executable file, are the codes of the three library functions copied where they are Called(is this why they are relocatable?) or the control is transferred to the memory locations of these functions.
Q6.) after the final code is generated is it placed contiguous memory locations??

although some of the questions may seem stupid, but i want to get a clear picture of what is going on in the computer, so i would love to have 'detailed' explanation with examples that a kid could also understand easily.

Please don't ask us to do your homework for you. In case you haven't figured it out yet, a running program is always in RAM (or possibly virtual memory on modern systems). Google is your friend. The answers to all of these questions can be found in the Wikipedia I think. It is elementary computer science.

Anyway, to sort of answer your question(s) about relocatable code. On some systems, such as embedded systems, you need to specify where in memory space your code will run from, usually in ROM. This is non-relocatable code. On current systems, where you are not running code from Read-Only-Memory (ROM), your code needs to be runable from any memory location, hence the "relocatable" concept - in that the code can be relocated to any suitable place in memory. When the operating system loads such a program into RAM, it decides where it should go, and then "fixes up", or "relocates", the memory addresses in the code to point to the correct memory addresses that it will actually be running from.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.