Segment:Offset

Status
Not open for further replies.

lord loh.

Member
In 16 bit machines that have 20 bit address bus, the memory is supposed to have been divided into several segments having offsets of 0 through 65535.

This is supposed to hvae been done to store 20 bit address into two 16 bit registers.

A book that I have says :


The example makes me feel that each segment is of 16 bytes!!! Could the example probably be wrong ?

As per calculations. 20 bit address bus give a maximum addressable locations of 1MB. 16-bit address gives 64Kb.

Therfore there ought to be 16 segments each consisting of 64 Kb.

16 seg * 64Kb = 1024kb

What do I understand this as ?
 
lord loh. said:
The example makes me feel that each segment is of 16 bytes!!! Could the example probably be wrong ?

No the example the correct, i don’t understand your confusion.

lord loh. said:
As per calculations. 20 bit address bus give a maximum addressable locations of 1MB. 16-bit address gives 64Kb.

Therfore there ought to be 16 segments each consisting of 64 Kb.

16 seg * 64Kb = 1024kb

What do I understand this as ?

Yes it’s correct but as explained in the example your segment can start from any location divisible by 16 and more then one segments can overlap each other. Thus you can have more then 16 segments overlapping each other. It depends on how your data and code is organized and used.

Refer to **broken link removed** link for more details.
 
So, do I understand that the segment locations are arbitrary? and the lsb of the segment is always assumed to be 0?
 
Yeah, that’s correct, while addressing the physical memory your segment register is shifted by 4 bits so that 4 lsbs will be 0 and total address will be 20 bits wide, offset is added to this shifted value and final 20 bit address is placed on Address bus.
 
So in a 1 MB memory I can have a maximum of F0000 number of segments? or can I have more segments than that?
 
lord loh. said:
So in a 1 MB memory I can have a maximum of F0000 number of segments? or can I have more segments than that?

Hi,
No, you can only address 0-FFFF segments (16bits) The confusing part is that each segment can have 0-FFFF addresses. If you use memory blocks of 64k you need only the upper 4 bits in the segment register and you then have 16 unique segments.
But if you use smaller blocks of memory, you'll have more segments.

Anyway this is Intel.

TOK
 
Thanks a lot...but more questions...

The memory block. Whi sets the size of the memory block? The programmer, or the OS?

And can there be overlapping segemnts? That is segment 0 starts at 00000h and segment 1 starts at 00001h and so on. (I am mentioning the physical memory location which is a multiple of 16).
 

Ok, segment 0 starts as you say on address 00000h, but segment 1 starts at address 00010h (or 16 decimal) and so on.

The question of who sets the size of the memory block is not absolute. It is a mix of the memory model you use, what type of segment (data or program), your own decisions as a programmer and the limitations of the OS.

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