T8U4_Memory_Model
T8U4_Memory_Model
· The memory model sets the supportable size of code and data area.
· We need to specify an appropriate memory model before compiling and linking the source
code.
· Using memory model we can set the size limits of the data and code.
· C++ program always use different segments for code and data.
· The memory model your option for decides the default method of memory addressing , and the
default memory model is small.
Tiny : Use the tiny model when memory is at an absolute premium . All four segment registers ( CS,DS ,
ES , and SS) are intialized with the same address, and all addressing is accomplished using 16 bits .
small: All codes should fit into a single 64-KB segment , and all data should fit into a second 64-KB
segment . All pointers are 16 bits in length.Execution speed is similar to that in the tiny model.
Medium : All data should fit into single 64-KB segment . However the code is allowed to dresses. With
this the access to data is fast.However , slower program execution is observed with this model.This
model is suitable for big programs that do not store a large amount of data in memory
Compact : All codes should fit into a 64KB segment , but the data can be use multiple segments ,
However , no data item can surpass 64KB . All pointers to data are 32 bits, but jumps and calls can use
16-bit address.
Large : Both code and data are allowed to use multiple segments. All pointers are 32-BITs in length.
However , no single data item can exceed 64-KB . Code execution is slower.
Huge: Both code and data are allowed to use multiple segments. Every pointer is 32 bits in length and it
is different from large memory model only vy pointer math and not by segments.
· FP_SEG() - This macros is used to obtain the segment address of the given pointer varaible.
· FP_OFF() - This macro is used to obtain the offset address of the given pointer variable.
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int ch;
getch();
OUTPUT