data and code segement

Status
Not open for further replies.

BAT_MAN

Member level 5
Joined
Oct 9, 2006
Messages
90
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,845
why we usally have data and code segment seperated in our programs
 

both sements have different attributes ..Usually one is code is READ ONLY .So you want to protect the code from getting corrupted or modified ! .Otherwise this give raise to spaguetti CODE..you will never know where is the begining or end .
So if thomething goes bad you can loose your data ,though if properly backed up there is no reason.But the code is the intelligent part of the machine You want to protected from getting corrupted or lost ,or modified by somebody else to gain control of your system ...DATA is read and write, so they have to be in separate memories spaces,even if they are in the same memory chip, or they can also be in separate memory midiums .. SRAM,EPROM etc and have violation check circuitry.
 

the data and code segment are seperate because the code segment will not change but the data segemnt can change its values during run time. so to protect the code we store them seperately.
 

Somtime we should protect code segment from being read by the end user.
so we should use seperated segments.
 

The execution efficiency of a computer will be improved if the program is executed sequencially. The separation of the two segment will help it.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…