473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

pointer normalization

Dear all,

can any one explain what is meant by pointer normalization
given here:-

http://c-faq.com/ansi/norml.html
Jun 27 '08 #1
22 2414
sophia said:
Dear all,

can any one explain what is meant by pointer normalization
given here:-

http://c-faq.com/ansi/norml.html
It is possible for a pointer value to have more than one object
representation. If p1 and p2 are two pointers to the same object, but with
different object representations, then p1 == p2 is required to yield 1, so
the implementation must (behave as if to) supply code to "normalise" the
pointer values used in the comparison - i.e. to convert one or the other
or both to a common form. (This was perfectly common in MS-DOS days.)

Note that the same requirement (of identifying the equality of those two
pointers) is not imposed on memcmp(&p1, &p2, sizeof p1).

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #2
On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.invalidwrote:
sophia said:
Dear all,
can any one explain what is meant by pointer normalization
given here:-
http://c-faq.com/ansi/norml.html

It is possible for a pointer value to have more than one object
representation. If p1 and p2 are two pointers to the same object, >but with different object representations,
Object in C means region of data storage isn't it ?

i am not getting your point,
same object with different representations ?
Jun 27 '08 #3
On 16 Apr, 13:33, sophia <sophia.ag...@gmail.comwrote:
On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.invalidwrote:
*can any one explain what is meant by pointer normalization
given here:-
>http://c-faq.com/ansi/norml.html
It is possible for a pointer value to have more than one object
representation. If p1 and p2 are two pointers to the same object,
but with different object representations,

Object in C means region of data storage isn't it ?

i am not getting your point,
*same object with different representations ?
not possible on a sane architecture, but see the "Segmentation"
section of http://en.wikipedia.org/wiki/Intel_8086
--
Nick Keighley


Jun 27 '08 #4
sophia said:
On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.invalidwrote:
>sophia said:
Dear all,
can any one explain what is meant by pointer normalization
given here:-
>http://c-faq.com/ansi/norml.html

It is possible for a pointer value to have more than one object
representation. If p1 and p2 are two pointers to the same object, >but
with different object representations,

Object in C means region of data storage isn't it ?

i am not getting your point,
same object with different representations ?
Consider MS-DOS's 20-bit pointers, where logical addresses are described by
two 16-bit values, called "segment" and "offset" respectively. To get the
physical address, we left-shift the segment value by four bits, and then
add the offset value.

Logical Logical Physical
segment offset address
address address
0001 1030 01040
0002 1020 01040
0003 1010 01040
0004 1000 01040
0005 00F0 01040

etc.

Five different pointer representations, all pointing to the same physical
object. All must compare equal when compared with ==. The implementation
is responsible for making this work.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #5
In article <aY*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
....
>Consider MS-DOS's 20-bit pointers, where logical addresses are described by
two 16-bit values, called "segment" and "offset" respectively. To get the
physical address, we left-shift the segment value by four bits, and then
add the offset value.
A nitpick surely worthy of this group...

It's not "MS-DOS's 20-bit pointers". This is a feature of the 8086
processors (and its descendants, running in "real mode"). It is not a
function of the OS in any way.

Further note that the descendants still maintain this functionality; it
is just that it is rarely used. It is no longer necessary (at least up
to the 4G mark. I'm not sure what happens if you have a machine with
more than 4G RAM).

Jun 27 '08 #6
In article <fu**********@news.xmission.com>,
Kenny McCormack <ga*****@xmission.xmission.comwrote:
>In article <aY*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
...
>>Consider MS-DOS's 20-bit pointers, where logical addresses are described by
two 16-bit values, called "segment" and "offset" respectively. To get the
physical address, we left-shift the segment value by four bits, and then
add the offset value.

A nitpick surely worthy of this group...
And note that a *real* first-class nitpicker would point out that it's
not even *MS*-DOS, as if this functionality were someone unique to
and/or invented by Microsoft...

Jun 27 '08 #7
sophia wrote:
>
On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.invalidwrote:
sophia said:
Dear all,
can any one explain what is meant by pointer normalization
given here:-
>http://c-faq.com/ansi/norml.html
It is possible for a pointer value to have more than one object
representation. If p1 and p2 are two pointers to the same object,
but with different object representations,

Object in C means region of data storage isn't it ?

i am not getting your point,
same object with different representations ?
Consider, for example, "real mode" on an x86 CPU. On that particular
platform, addresses are represented by a 16-bit segment and a 16-bit
offset. (The physical address is segment*16+offset.) Using this
particular architecture, the following segment/offset pairs all point
to the same physical address:

1234:0000
1230:0040
1200:0340
1000:2340
and even
1111:1230
0235:FFF0

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Jun 27 '08 #8
Kenny McCormack wrote:
In article <aY*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
...
>Consider MS-DOS's 20-bit pointers, where logical addresses are described by
two 16-bit values, called "segment" and "offset" respectively. To get the
physical address, we left-shift the segment value by four bits, and then
add the offset value.

A nitpick surely worthy of this group...

It's not "MS-DOS's 20-bit pointers". This is a feature of the 8086
processors (and its descendants, running in "real mode"). It is not a
function of the OS in any way.
Well if we're nitpicking.. :P
He didn't claim ms-dos 'owns or invented' the concept. He just offered
it as an example. MS-DOS did in fact have 20bit pointers because it ran
on 8086.
Jun 27 '08 #9
In article <48********@news.acsalaska.net>, anoncoholic <no@no.netwrote:
>Kenny McCormack wrote:
>In article <aY*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
...
>>Consider MS-DOS's 20-bit pointers, where logical addresses are described by
two 16-bit values, called "segment" and "offset" respectively. To get the
physical address, we left-shift the segment value by four bits, and then
add the offset value.

A nitpick surely worthy of this group...

It's not "MS-DOS's 20-bit pointers". This is a feature of the 8086
processors (and its descendants, running in "real mode"). It is not a
function of the OS in any way.

Well if we're nitpicking.. :P
He didn't claim ms-dos 'owns or invented' the concept. He just offered
it as an example. MS-DOS did in fact have 20bit pointers because it ran
on 8086.
I doubt the MSDOS standards document uses the phrase "20 bit"...

Jun 27 '08 #10
Kenny McCormack wrote:
In article <aY*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
...
>>Consider MS-DOS's 20-bit pointers, where logical addresses are
described by two 16-bit values, called "segment" and "offset"
respectively. To get the physical address, we left-shift the segment
value by four bits, and then add the offset value.

A nitpick surely worthy of this group...

It's not "MS-DOS's 20-bit pointers". This is a feature of the 8086
processors (and its descendants, running in "real mode"). It is not a
function of the OS in any way.

Further note that the descendants still maintain this functionality;
it is just that it is rarely used. It is no longer necessary (at
least up to the 4G mark. I'm not sure what happens if you have a
machine with more than 4G RAM).
The system could employ PAE to use upto 64 Gb, though applications still
see only 4 Gb and remain flat model based.

Jun 27 '08 #11
On Apr 16, 5:47*am, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
On 16 Apr, 13:33, sophia <sophia.ag...@gmail.comwrote:
On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.invalidwrote:
*can any one explain what is meant by pointer normalization
given here:-
http://c-faq.com/ansi/norml.html
It is possible for a pointer value to have more than one object
representation. If p1 and p2 are two pointers to the same object,
but with different object representations,
Object in C means region of data storage isn't it ?
i am not getting your point,
*same object with different representations ?

not possible on a sane architecture, but see the "Segmentation"
section ofhttp://en.wikipedia.org/wiki/Intel_8086
Many sane architectures support virtual memory, by means of which you
can create aliases of the same object at different virtual addresses.

On some architectures, certain bits in an address determine whether,
for instance, the same address range is being accessed cached or
uncached.

There are also sane forms of segmentation, not simply based on
multiplying a segment by some constant and adding the offset.

Jun 27 '08 #12
In article <64**********************************@t54g2000hsg. googlegroups.com>,
Kaz Kylheku <kk******@gmail.comwrote:
It is possible for a pointer value to have more than one object
representation. If p1 and p2 are two pointers to the same object,
but with different object representations,
Object in C means region of data storage isn't it ?
i am not getting your point,
*same object with different representations ?
>not possible on a sane architecture, but see the "Segmentation"
section ofhttp://en.wikipedia.org/wiki/Intel_8086
>Many sane architectures support virtual memory, by means of which you
can create aliases of the same object at different virtual addresses.

On some architectures, certain bits in an address determine whether,
for instance, the same address range is being accessed cached or
uncached.
This is true, but not really relevant to the question. Such different
representations will not arise as a result of standard C operations.
An implementation may well provide a way to get an uncached pointer
to an object, but it is under no obligation to make that compare
equal to the cached version.

-- Richard
--
:wq
Jun 27 '08 #13
In article <fu**********@news.xmission.com>,
Kenny McCormack <ga*****@xmission.xmission.comwrote:
>I doubt the MSDOS standards document uses the phrase "20 bit"...
There's an MSDOS standards document?

-- Richard

--
:wq
Jun 27 '08 #14
ri*****@cogsci.ed.ac.uk (Richard Tobin) wrote:
Kenny McCormack <ga*****@xmission.xmission.comwrote:
I doubt the MSDOS standards document uses the phrase "20 bit"...

There's an MSDOS standards document?
Erm, yes? I don't remember what colour it was, but IIRC burgundy.
Techref for the hardware was blue. They came in binders.

Richard
Jun 27 '08 #15
>>>>"MD" == Morris Dovey <mr*****@iedu.comwrites:

(quoting someone else, which attribution I have lost)
>If the top 4 bits are taken outside, they should be decoded
(eg. zeros). Otherwise extending the memory beyond 4K words
becomes difficult. And problems on those top 4 address lines
might be missed.
MDI'm almost embarassed to point out how easily any such
MDproblems are avoided. All that decoding unused address lines
MDgets is increased product cost. We already have enough
MDbloatware without building it into circuits, too.
>If not then the uP should insist those 4 bits were zero or
whatever. Then the same software can run on a version with more
address lines.
MDNah - it's a non-issue, and only worth mentioning as an
MDexample of multiple addresses pointing to the same memory
MDlocation.

Ask the people of Mac SE/30s who had to struggle with "32-bit clean"
software issues, particularly from Microsoft, if it's a "non-issue."

You see, in the early days of the Macintosh computer line, around the
time that the Macintosh II came out, it was obvious to anyone that
only 24 bits of memory addressing would ever be necessary.
Microsoft's products, most notably Word, used the upper 8 bits of the
32-bit pointer to hold information about the pointer.

Of course, like the famous 640K prediction, this one was also false,
and when Macs came out that actually had enough memory, virtual and
otherwise, so that full 32-bit addressing was useful, people had to
cope with the backwards Microsoft decision, and the resulting random
crashes of Word, destroying hours' worth of work, for several years
while it all got straightened out.

So yeah, if you are *sure* that you'll never need the full range of
pointers, don't bother with any sort of normalization. Just use
Microsoft as an object lesson.

Charlton
--
Charlton Wilbur
cw*****@chromatico.net
Jun 27 '08 #16
Charlton Wilbur <cw*****@chromatico.netwrote:
>>>>>"MD" == Morris Dovey <mr*****@iedu.comwrites:

(quoting someone else, which attribution I have lost)
>If the top 4 bits are taken outside, they should be decoded
>(eg. zeros). Otherwise extending the memory beyond 4K words
>becomes difficult. And problems on those top 4 address lines
>might be missed.

MDI'm almost embarassed to point out how easily any such
MDproblems are avoided. All that decoding unused address lines
MDgets is increased product cost. We already have enough
MDbloatware without building it into circuits, too.
>If not then the uP should insist those 4 bits were zero or
>whatever. Then the same software can run on a version with more
>address lines.

MDNah - it's a non-issue, and only worth mentioning as an
MDexample of multiple addresses pointing to the same memory
MDlocation.

Ask the people of Mac SE/30s who had to struggle with "32-bit clean"
software issues, particularly from Microsoft, if it's a "non-issue."

For a general purpose-computer with lots of third-party software it can
indeed be a problem.

For an embedded device (CPUs with only 4K words are not used in anything
except embedded devices nowadays) it is not a problem.
Here people can switch to a completely different CPU architecture (with
all the porting this entails) if they can save 50 cents per unit.

For embedded devices one usually does not need to care about binary
compatibility (or even source code compatibility) with previous or
future generations of the product.

>
You see, in the early days of the Macintosh computer line, around the
time that the Macintosh II came out, it was obvious to anyone that
only 24 bits of memory addressing would ever be necessary.
Microsoft's products, most notably Word, used the upper 8 bits of the
32-bit pointer to hold information about the pointer.

Of course, like the famous 640K prediction, this one was also false,
and when Macs came out that actually had enough memory, virtual and
otherwise, so that full 32-bit addressing was useful, people had to
cope with the backwards Microsoft decision, and the resulting random
crashes of Word, destroying hours' worth of work, for several years
while it all got straightened out.

So yeah, if you are *sure* that you'll never need the full range of
pointers, don't bother with any sort of normalization. Just use
Microsoft as an object lesson.

Charlton

--
<Insert your favourite quote here.>
Erik Trulsson
er******@student.uu.se
Jun 27 '08 #17
Charlton Wilbur wrote:
So yeah, if you are *sure* that you'll never need the full range of
pointers, don't bother with any sort of normalization. Just use
Microsoft as an object lesson.
Hmm. My choice would be to _not_ use M$ in /any/ context.

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
Jun 27 '08 #18
>>>>"MD" == Morris Dovey <mr*****@iedu.comwrites:

MDCharlton Wilbur wrote:
>So yeah, if you are *sure* that you'll never need the full
range of pointers, don't bother with any sort of normalization.
Just use Microsoft as an object lesson.
MDHmm. My choice would be to _not_ use M$ in /any/ context.

Even as an example of what not to do?

Charlton
--
Charlton Wilbur
cw*****@chromatico.net
Jun 27 '08 #19
Charlton Wilbur wrote:
>
>>>"MD" == Morris Dovey <mr*****@iedu.comwrites:

MDCharlton Wilbur wrote:
>So yeah, if you are *sure* that you'll never need the full
>range of pointers, don't bother with any sort of normalization.
>Just use Microsoft as an object lesson.

MDHmm. My choice would be to _not_ use M$ in /any/ context.

Even as an example of what not to do?
There're enough examples without their contributions.

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
Jun 27 '08 #20
On Apr 16, 5:52*pm, Richard Heathfield <r...@see.sig.invalidwrote:
sophia said:


On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.invalidwrote:
sophia said:
Dear all,
*can any one explain what is meant by pointer normalization
given here:-
http://c-faq.com/ansi/norml.html
It is possible for a pointer value to have more than one object
representation. If p1 and p2 are two pointers to the same object, >but
with different object representations,
Object in C means region of data storage isn't it ?
i am not getting your point,
*same object with different representations ?

Consider MS-DOS's 20-bit pointers, where logical addresses are described by
two 16-bit values, called "segment" and "offset" respectively. To get the
physical address, we left-shift the segment value by four bits, and then
add the offset value.

Logical * *Logical * *Physical
segment * *offset * * address
address * *address
* 0001 * * * 1030 * * 01040
* 0002 * * * 1020 * * 01040
* 0003 * * * 1010 * * 01040
* 0004 * * * 1000 * * 01040
* 0005 * * * 00F0 * * 01040

etc.

Five different pointer representations, all pointing to the same physical
object. All must compare equal when compared with ==. The implementation
is responsible for making this work.
Peter van der linden in his book says that

An address on the intel 8086 is formed by combining a 16- bit segment
with a 16 bit offset..........................
.................................................. ...
............................................

In general , there will be 4096 different segment/offset combinations
that point to the same address.

A C - compiler writer needs to make sure that pointers are compared in
canonical form on a P.C , otherwise two pointers that have different
bit patterns but designate the same address may wrongly compare un
equal. this will be done for you if you use the "huge" keyword, but
does not occur for the large model.

now question is

In present day 32 bit C compilers how this pointer normalization
done ?
Jun 27 '08 #21
sophia wrote:
Peter van der linden in his book says that

An address on the intel 8086 is formed by combining a 16- bit segment
with a 16 bit offset..........................
.................................................. ...
............................................

In general , there will be 4096 different segment/offset combinations
that point to the same address.
....
In present day 32 bit C compilers how this pointer normalization
done ?
If you're talking about common desktop PCs, there usually isn't any
normalisation needed, each pointer is a linear 32-bit value.

But there will always be a few odd machines with strange ways of addressing
memory. And with 64-bit machines, if 32-bit and 64-bit pointers are ever
mixed in the same application, some normalising is needed there (but the
situation is a little different: a short pointer with a long one).

That's the compiler's headache however not yours.

Are you researching an article or something?

--
Bart
Jun 27 '08 #22
>Peter van der linden in his book says that
>
An address on the intel 8086 is formed by combining a 16- bit segment
with a 16 bit offset..........................
>In general , there will be 4096 different segment/offset combinations
that point to the same address.

A C - compiler writer needs to make sure that pointers are compared in
canonical form on a P.C , otherwise two pointers that have different
bit patterns but designate the same address may wrongly compare un
equal. this will be done for you if you use the "huge" keyword, but
does not occur for the large model.
A compiler writer only needs to worry about normalizing pointers
if non-normalized pointers can occur by normal operation of C. For
example, in large model, pointer addition affects only the offset
and you can't have an object larger than 64k, so pointer arithmetic
won't generate un-normalized pointers, so a straight 32-bit comparison
can be used to compare pointers (assuming you've covered all the other
ways of generating un-normalized pointers). However, in huge model,
objects can be larger than 64k, and pointer arithmetic may alter
the segment, so you have a choice of pointer arithmetic always doing
normalizing, or comparing pointers doing normalizing.
>In present day 32 bit C compilers how this pointer normalization
done ?
Present day desktops use linear addresses (unless you're talking
about Pentium 48-bit pointers and a larger than 4GB address space
for an individual process). You can't have an un-normalized pointer,
so it's a non-issue.
Jun 27 '08 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JoeB | last post by:
I found an interesting thread on this from Nov., 2000, but it didn't fully answer my question. I understand normalization, but am trying to find the line between good database design and personal...
2
by: Kostas | last post by:
Hi all, I strived understanding the concepts of all normal forms up to the domain-key normal form but there are some issues I still am unsure of, and I will describe the first one in this post....
7
by: John Welch | last post by:
I have three tables and the way they are currently set up violates good normalization, but I'm having trouble figuring out a better way. Can someone suggest a more elegant solution? My tables...
26
by: Meenu | last post by:
Hi, Can two different far pointers contain two different addresses but refer to the same location in memory?
20
by: hippomedon | last post by:
Hello everyone, I'm looking for some advice on whether I should break the normalization rule. Normally, I would not consider it, but this seems to be a special case. I have created an...
1
by: weird0 | last post by:
I know that is not the appropriate group for asking this question, but I do not know of any better forum. Can anyone plz explain clearly what normalization is? The first three normal forms upto...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.