Solved

Paragraph Boundary

Posted on 1998-08-04
4
1,359 Views
Last Modified: 2012-05-04
I am not very clear on the concept of the paragraph boundary. They say each
program segment start at the paragraph boundary ( evenly divisible by 16 or
hex 10 ). I don't understand what they mean? I know that they would contain
addresses divisible by 16 eg 32, 48, 64 etc but don't know more than that.
Could anyone elaborate on that  please?
0
Comment
Question by:ashfawad
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
bjt3 earned 50 total points
ID: 1020323
Well, if this is what I think it is, here's what's going on.

The CPU you're dealing with has a segmented memory architecture.  That is, addresses
are built up from segment or index registers and an offset address.  The segment/index
register is usually shifted up and the offset added to it.  In some architectures, there's no bit
overlap and in others there is.  Segmented architectures are just one way to address more
memory than you have address bits.

What you're referring to is a CPU with a segment register that shifts up 4 bits and hence all
the "base" addresses end in hex 0.  Assuming that you have more than 4 bits available to you
in the offset address, then you can (in some architectures) end up in the interesting state
in which you can address the same bytes of physical memory with many differing combinations
of segment and offset (add one to the segment, subtact 16 from the offset, etc).

So, an example, segment register contains 1234 hex, offset is abc hex.  This refers to
(1234 hex * 10 hex) + abc hex = 12340 hex + abc hex = 12dfc hex.  Which you could also
address with a segment register of 1233 hex and an offset of acc hex. This 16 byte block is
sometimes called a paragraph and the address may be written as segment:offset
or 1234:0abc in this case.

Note that there are many other possibilities for segmented architectures, as well as
completely different solutions other than segmented.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1020324
Just a side note, you seem to have posted three copies of your question, all of which are the same.  You can delete the other two and get the points before someone locks them after which you will be in trouble...
0
 

Author Comment

by:ashfawad
ID: 1020325
I have read somewhere that the segments, being on the paragraph boundary, have addresses divsible by hex 10.They contain 0s in their right most bit. So when such an address is stored without the four zeros because it is assumed the address would contain them. And I think that is why you take a segment address and mutiply by hex 10 in the above example and then add the offset value to it which gives you 12dfc. Now is this the location that segment would start? I am not seeing any 16 bytes block. The segment register has 1234 hex, which is actually 12340 hex (which is some number divisible by hex10). Then you add abc to it which makes it 12dfc. Is the difference between 12340 hex and 12dfc hex is 16 bytes?

From whatever I have read so far, it seems like when they say,
" a segment begins at a paragraph boudary", it means its starting address ( no matter what it is) is always divisible by 16 decimal or hex 10. Which means its addresses always contain 0's in the rightmost bit.
0
 
LVL 7

Expert Comment

by:bjt3
ID: 1020326
The segment registers in a segmented architecture always have the INDEX (key word) of
the segment that you're referring to.  Let's look at it another way.  Let's break memory up
into 16 byte chunks.  Physical address 0 through 15 are in chunk 0 (segment 0), addresses
16 through 31 are in chunk 1 (segment 1), etc, etc.  The segment register contains the
INDEX of the 16 byte chunk that you're interested in.  So, take the segment number and
multiply by 16 to get the actual byte address of the beginning of that chunk.  You then need
to add the OFFSET into that 16 byte block to completely specify any address within
physical memory.

In the example given, the segment register pointed to the 1234th (hex) chunk (paragraph)
of memory.  That's actually physical address 12340 (hex).  To specify the the 5th byte in
that block, the address is 12345 (hex).  Due to the way this was implemented in this
architecture, you can also specify offset much greater than 15(decimal) and point into
another paragraph.  Hence, in the previous example, we used 1234:abc.  abc as an offset
actually points to a 16 byte chunk ab (hex) chunks "away" from the 1234 (hex) chunk.  This
is the same address as (1234+ab):0c which is 12df:0c which is address 12dfc

We could break memory up into any size chunks: 16 bytes, 23 bytes, 1 byte, whatever.
Computers are good a powers of 2 and CPUs are great at shifting.  So power-of-2 size
chunks work best.  In this case, 16 was chosen, which is 4 bits.  So, the base address
of ANY segment has its lowest 4 bits set to 0.  Note, however, that this is just the base
address of the segment.  Any usable address (data, code, whatever) will contain ALL of
the bits of the address space and point to any byte within that paragraph.  So, yes, what
you see is that the base addresses of segments all look like xyz0 hex where the lowest
digit is always 0.

For another viewpoint, I did some searching just now and found another explanation that
might help.  Take a look at

http://www.technology.niagarac.on.ca/courses/comp335/notes/x86-model.htm

Ok.  Now why does this happen ?  The CPU registers can only specify 16 bit addresses.
That allows you to talk to addresses 0-FFFF hex.  Adding in this memory management
model using segments, you "add" 4 bits to the addressing allowing the CPU to talk
to addresses 0-FFFFF hex.  You've increased your addressing range by a factor of
16, but didn't need to make the address registers in the CPU any larger.  Any given operation
can talk to a range of 0-FFFF starting at any segment address.  Think of it as a 16 bit
address window in a 20 bit address space.  The segment register tells you the base address
of the window.  Any address is computed using the two registers:segment and offset.  You
then have multiple segment registers for different contexts (code, data, stack, etc) and a CPU
that knows that it uses the code segment register for code references and the data
segment register for data references, etc.  Rather than have a single 16 bit address space,
you now have mutiple 16 bit address spaces for the different sections of your program.

Whew !  This is getting long.  There are other advantages and possibilities with this
memory management scheme.  There are also other memory management schemes.
It all looks pretty complicated, but it's just a lot of details based on really simple ideas.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I recently purchased an HP EliteBook 2540p notebook/laptop. It has two video ports on it – VGA and DisplayPort. HP offers an optional docking station for the 2540p that also has both a VGA port and a DisplayPort. There are numerous online reports do…
this article is a guided solution for most of the common server issues in server hardware tasks we are facing in our routine job works. the topics in the following article covered are, 1) dell hardware raidlevel (Perc) 2) adding HDD 3) how t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now