Gursharan Singh Tatla
[email protected]
Memory Segmentation
The total memory size is divided into segments of various sizes.
A segment is ust an area area in memory. memory.
The process of dividing memory this way is called Segmentation Segmentation..
Memory Segmentation
!n memory" data is stored as #ytes.
$ach #yte has a specific address.
!ntel %0%6 has 20 lines address #us.
&ith 20 address lines" the memory that can #e addressed is 2 20 #ytes.
220 ' 1"0(%")*6 #ytes +1 ,-.
%0%6 can access memory with address ranging from 00000 / to /.
Memory Segmentation
!n %0%6" memory has four different types of segments.
These are
3ode 4egment
5ata 4egment
4tac 4egment
$7tra 4egment
Segment Registers
$ach of these segments are addressed #y an address stored in corresponding segment register.
These registers are 168#it in size.
$ach register stores the #ase address +starting address of the corresponding segment.
-ecause the segment registers cannot store 20 #its" they only store the upper 16 #its.
Segment Registers
Segment Registers
/ow is a 208#it address o#tained if there are only 168#it registers9
The answer lies in the ne7t few slides.
The 208#it address of a #yte is called its Physical Address.. Address
-ut" it is specified as a Logical Address. Address.
:ogical address is in the form of Base Address : Offset
Offset is the displacement of the memory location from the starting location of the segment.
Example
The value of 5ata 4egment ;egister +54 is 2222 /.
To convert this 168#it address into 208#it" the -!< appends 0/ to the :4-s of the address.
After appending" appending" the starting starting address of the 5ata 4egment #ecomes 22220/.
Example (Contd.)
!f the data at any location has a logical address specified as 2222 / 0016 /
Then" the num#er 0016 / is the offset.
2222 / is the value of 54.
Example (Contd.)
To calculate the effective address of the memory" -!< uses the following formula
$ffective Address Address ' 4tarting Address of 4egment > Offset
To find the starting address of the segment" -!< appends the contents of 4egment ;egister with 0/.
Then" it adds offset to it.
Example (Contd.)
Therefore
$A '
22220 / > 0016 / 888888888888 2226 /
Example (Contd.) -?T$ 0
2222 / 54 ;egister
22220 /
-?T$ 1 -?T$ 2
Offset ' 0016 /
8 8 8 8 8 Addressed -yte
2226 /
Max. Size of Segment
All offsets offsets are limited to 168#its.
!t means that the ma7imum size possi#le for segment is 216 ' 6)")) #ytes +6( -.
The offset of the first location within the segment is 0000 /.
The offset of the last location in the segment is /.
Where to Look for the Oset Segment
Offset Registers
Function
34
!B
Address of the ne7t instruction
54
-C" 5!" 4!
Address of data
44
4B" -B
Address in the stac
$4
-C" 5!" 4!
Address of destination data +for string operations
!"estion
The contents of the following registers are
34 ' 1111 /
54 ' /
44 ' 2)26 /
!B ' 122 /
4B ' 1100 /
5! ' 0020 /
3alculate the corresponding physical addresses for the address #ytes in 34" 54 and 44.
Sol"tion 1. S ! 1111 "
The #ase address of the code segment is 11110 /.
$ffective address of memory is given #y 11110/ > 122/ ' 12(2/.
#. $S ! %%%% "
The #ase address of the data segment is 0 /.
$ffective address of memory is given #y 0/ > 0020/ ' )0/.
%. SS ! #' "
The #ase address of the stac segment is 2)260 /.
$ffective address of memory is given #y 2)260/ > 1100/ ' 26)0/.