Article View: comp.sys.amiga.tech
Article #3229Re: What's an APTR, BPTR?
From: Dave Haynie
Date: Tue, 10 Apr 1990 00:58
Date: Tue, 10 Apr 1990 00:58
40 lines
2812 bytes
2812 bytes
In article <10712@cbmvax.commodore.com> valentin@cbmvax (Valentin Pepelea) writes:
>In article <3421@newton.physics.purdue.edu> murphy@newton.physics.purdue.edu.UUCP (William J. Murphy) writes:
>>BPTR = BCPL pointer = long-word aligned pointer.
>Way back when the evil language BCPL was invented, computers had no more than
>64K of addressing space. The BCPL language allowed the illusion of working with
>a contiguous 256K by using pointers that were shifted right by two bits.
>Thus a pointer to address 1024 would be represented as a 256 in BCPL.
Huh? BCPL was essentially designed for word-addressed machines, like the DEC-10
and DEC-20, rather than byte addressed machines, which comprise most of the rest
of the world. On a DEC-20, location 0 contains one 36 bit word, location 1
contains the next 36 bit word, etc. These machines actually only had 18 bits
of address space (eg, 1/2 a word), but that really didn't enter into the
picture. On the 68000, as most other popular computers, location 0 contains
one byte, location 1 contains the next byte, etc.
In order to rectify the difference between the word vs. byte addressing, the
BCPL compiler used for the original Amiga DOS subsystem mapped every longword as
one memory location, from its point of view. So location 0 would be a 32 bit
word, location 1 the next 32 bit word, etc. Just like the DEC machines, so
the BCPL language itself looked exactly the same. Only, to actually access a
reference to this logical mapping, the BCPL compiler had to produce code that
took (BCPL_pointer << 2) to create a working 68000 pointer. The actual BCPL
code in the Amiga's DOS subsystem has been on the way out for some time, but
the BCPL pointer lingers on for interface reasons here and there.
I've heard that there are alternative BCPL implementations without the evil
address mappings, probably on PDP-11s or VAXen. Apparently this changes the
BCPL language ever so slightly, and drastically improves the quality of the
produced code. I suppose the smartest thing would be to no use BCPL in the
first place.
>Valentin
--
Dave Haynie Commodore-Amiga (Systems Engineering) "The Crew That Never Rests"
{uunet|pyramid|rutgers}!cbmvax!daveh PLINK: hazy BIX: hazy
Too much of everything is just enough
Technical Details
Message-ID:
<10737@cbmvax.commodore.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cbmvax!davehReferences:
<3421@newton.physics.purdue.edu> <10712@cbmvax.commodore.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cbmvax!daveh From: daveh@cbmvax.commodore.com (Dave Haynie) Newsgroups: comp.sys.amiga.tech Subject: Re: What's an APTR, BPTR? Message-ID: <10737@cbmvax.commodore.com> Date: 10 Apr 90 00:58:17 GMT References: <3421@newton.physics.purdue.edu> <10712@cbmvax.commodore.com> Reply-To: daveh@cbmvax (Dave Haynie) Distribution: comp.amiga.tech Organization: Commodore, West Chester, PA Lines: 40