pointer normalization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sophia

    pointer normalization

    Dear all,

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


  • Richard Heathfield

    #2
    Re: pointer normalization

    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

    Comment

    • sophia

      #3
      Re: pointer normalization

      On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
      sophia said:
      >
      Dear all,
      >
      can any one explain what is meant by pointer normalization
      given here:-
      >>
      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 ?

      Comment

      • Nick Keighley

        #4
        Re: pointer normalization

        On 16 Apr, 13:33, sophia <sophia.ag...@g mail.comwrote:
        On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
         can any one explain what is meant by pointer normalization
        given here:-
        >>
        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 "Segmentati on"
        section of http://en.wikipedia.org/wiki/Intel_8086


        --
        Nick Keighley




        Comment

        • Richard Heathfield

          #5
          Re: pointer normalization

          sophia said:
          On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
          >sophia said:
          >>
          Dear all,
          >>
          can any one explain what is meant by pointer normalization
          given here:-
          >>>>
          >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

          Comment

          • Kenny McCormack

            #6
            Re: pointer normalization

            In article <aY2dnetnsYENaJ jVRVnyjwA@bt.co m>,
            Richard Heathfield <rjh@see.sig.in validwrote:
            ....
            >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).

            Comment

            • Kenny McCormack

              #7
              Re: pointer normalization

              In article <fu4vs5$42d$1@n ews.xmission.co m>,
              Kenny McCormack <gazelle@xmissi on.xmission.com wrote:
              >In article <aY2dnetnsYENaJ jVRVnyjwA@bt.co m>,
              >Richard Heathfield <rjh@see.sig.in validwrote:
              >...
              >>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...

              Comment

              • Kenneth Brody

                #8
                Re: pointer normalization

                sophia wrote:
                >
                On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
                sophia said:
                Dear all,
                can any one explain what is meant by pointer normalization
                given here:-
                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+offs et.) 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:ThisIsA SpamTrap@gmail. com>

                Comment

                • anoncoholic

                  #9
                  Re: pointer normalization

                  Kenny McCormack wrote:
                  In article <aY2dnetnsYENaJ jVRVnyjwA@bt.co m>,
                  Richard Heathfield <rjh@see.sig.in validwrote:
                  ...
                  >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.

                  Comment

                  • Kenny McCormack

                    #10
                    Re: pointer normalization

                    In article <480662d5$1@new s.acsalaska.net >, anoncoholic <no@no.netwrote :
                    >Kenny McCormack wrote:
                    >In article <aY2dnetnsYENaJ jVRVnyjwA@bt.co m>,
                    >Richard Heathfield <rjh@see.sig.in validwrote:
                    >...
                    >>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"...

                    Comment

                    • santosh

                      #11
                      Re: pointer normalization

                      Kenny McCormack wrote:
                      In article <aY2dnetnsYENaJ jVRVnyjwA@bt.co m>,
                      Richard Heathfield <rjh@see.sig.in validwrote:
                      ...
                      >>Consider MS-DOS's 20-bit pointers, where logical addresses are
                      >>described by two 16-bit values, called "segment" and "offset"
                      >>respectivel y. 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.

                      Comment

                      • Kaz Kylheku

                        #12
                        Re: pointer normalization

                        On Apr 16, 5:47 am, Nick Keighley <nick_keighley_ nos...@hotmail. com>
                        wrote:
                        On 16 Apr, 13:33, sophia <sophia.ag...@g mail.comwrote:
                        >
                        On Apr 16, 7:59 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
                         can any one explain what is meant by pointer normalization
                        given here:-
                        >>
                        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 "Segmentati on"
                        section ofhttp://en.wikipedia.or g/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.

                        Comment

                        • Richard Tobin

                          #13
                          Re: pointer normalization

                          In article <64de2778-0bab-4d92-aec1-de38c1c0f594@t5 4g2000hsg.googl egroups.com>,
                          Kaz Kylheku <kkylheku@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 "Segmentati on"
                          >section ofhttp://en.wikipedia.or g/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

                          Comment

                          • Richard Tobin

                            #14
                            Re: pointer normalization

                            In article <fu63st$tsq$1@n ews.xmission.co m>,
                            Kenny McCormack <gazelle@xmissi on.xmission.com wrote:
                            >I doubt the MSDOS standards document uses the phrase "20 bit"...
                            There's an MSDOS standards document?

                            -- Richard



                            --
                            :wq

                            Comment

                            • Richard Bos

                              #15
                              Re: pointer normalization

                              richard@cogsci. ed.ac.uk (Richard Tobin) wrote:
                              Kenny McCormack <gazelle@xmissi on.xmission.com wrote:
                              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

                              Comment

                              Working...